Play cards, select game, player actions
This commit is contained in:
@ -106,6 +106,13 @@ final class Database {
|
||||
return tables.performAction(player: player, action: action)
|
||||
}
|
||||
|
||||
func select(game: GameType, playerToken: SessionToken) -> PlayerActionResult {
|
||||
guard let player = players.registeredPlayerExists(withSessionToken: playerToken) else {
|
||||
return .invalidToken
|
||||
}
|
||||
return tables.select(game: game, player: player)
|
||||
}
|
||||
|
||||
func play(card: Card, playerToken: SessionToken) -> PlayCardResult {
|
||||
guard let player = players.registeredPlayerExists(withSessionToken: playerToken) else {
|
||||
return .invalidToken
|
||||
|
@ -167,11 +167,20 @@ final class TableManagement: DiskWriter {
|
||||
|
||||
func performAction(player: PlayerName, action: Player.Action) -> PlayerActionResult {
|
||||
guard let table = currentTable(for: player) else {
|
||||
print("Player \(player) wants to \(action.path), but no table joined")
|
||||
return .noTableJoined
|
||||
}
|
||||
return table.perform(action: action, forPlayer: player)
|
||||
}
|
||||
|
||||
func select(game: GameType, player: PlayerName) -> PlayerActionResult {
|
||||
guard let table = currentTable(for: player) else {
|
||||
print("Player \(player) wants to play \(game.rawValue), but no table joined")
|
||||
return .noTableJoined
|
||||
}
|
||||
return table.select(game: game, player: player)
|
||||
}
|
||||
|
||||
func play(card: Card, player: PlayerName) -> PlayCardResult {
|
||||
guard let table = currentTable(for: player) else {
|
||||
return .noTableJoined
|
||||
|
Reference in New Issue
Block a user