You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
519 B
24 lines
519 B
public protocol Rules {
|
|
var state: GameState { get }
|
|
|
|
var history: [Move] { get }
|
|
|
|
mutating func createBoard() -> Board
|
|
|
|
func isValid(board: Board) -> Bool
|
|
|
|
func isValid(board: Board, move: Move) -> Bool
|
|
|
|
func validMoves(board: Board) -> [Move]
|
|
|
|
func validMoves(board: Board, for_player player: Player) -> [Move.Action]
|
|
|
|
mutating func onMoveDone(move: Move, board: Board) -> Void
|
|
}
|
|
|
|
public enum GameState: Equatable {
|
|
case Playing(turn: Player)
|
|
|
|
case Finished(winner: Player?)
|
|
}
|