Swiftpack.co - Package - koher/swifty-reversi

SwiftyReversi

A Reversi library for Swift.

var game = Game(board: Board("""
--------
--------
--------
---ox---
---xo---
--------
--------
--------
"""), turn: .dark)
try game.placeDiskAt(x: 3, y: 2)

License

MIT

Github

link
Stars: 6

Dependencies

Used By

Total: 0

Releases

Introduce `Game.pass` - 2020-09-05 04:26:16

Passes had been executed automatically with 0.1.0. Now, with 0.2.x, the pass method of the Game instances must be executed explicitly for clarity.

// With 0.2.x

var game: Game = Game(board: Board("""
xxxx
-xo-
-xo-
x---
"""), turn: .light)
            
try game.placeDiskAt(x: 0, y: 1)

XCTAssertEqual(game.board, Board("""
xxxx
ooo-
-xo-
x---
"""))
XCTAssertEqual(game.state, .beingPlayed(turn: .dark))

try game.placeDiskAt(x: 0, y: 2)

XCTAssertEqual(game.board, Board("""
xxxx
xxo-
xxo-
x---
"""))
XCTAssertEqual(game.state, .beingPlayed(turn: .light))

try game.pass() // calling `pass` is required

XCTAssertEqual(game.board, Board("""
xxxx
xxo-
xxo-
x---
"""))
XCTAssertEqual(game.state, .beingPlayed(turn: .dark))