-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCGameLogic.swift
41 lines (31 loc) · 1.09 KB
/
SCGameLogic.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/// The logic of the simple client.
class SCGameLogic: SCGameHandlerDelegate {
// MARK: - Properties
/// The current game state.
private var gameState: SCGameState!
/// The color of the player using this game logic.
private let player: SCPlayerColor
// MARK: - Initializers
/// Creates a new game logic with the given player color.
///
/// - Parameter player: The color of the player using this game logic.
init(player: SCPlayerColor) {
self.player = player
}
// MARK: - SCGameHandlerDelegate
func onGameEnded() {
print("*** The game has been ended!")
}
func onGameResultReceived(_ gameResult: SCGameResult) {
print("*** The game result has been received!")
}
func onGameStateUpdated(_ gameState: SCGameState) {
print("*** The game state has been updated!")
self.gameState = gameState
}
func onMoveRequested() -> SCMove? {
print("*** A move is requested by the game server!")
// TODO: Add your own logic here.
return self.gameState.possibleMoves().randomElement()
}
}