Clarify action id

This commit is contained in:
Christoph Hagen
2021-12-09 11:18:26 +01:00
parent 445363307b
commit 577a60c1d1
4 changed files with 8 additions and 6 deletions

View File

@ -269,7 +269,7 @@ final class OldTable {
func perform(action: PlayerAction, forPlayer player: PlayerName) -> PlayerActionResult {
let player = select(player: player)!
guard player.canPerform(action) else {
print("Player \(player) wants to \(action.path), but only allowed: \(player.actions)")
print("Player \(player) wants to \(action.id), but only allowed: \(player.actions)")
return .tableStateInvalid
}
defer { sendUpdateToAllPlayers() }

View File

@ -1,5 +1,7 @@
import Foundation
typealias ActionId = String
enum PlayerAction: String, Codable {
/// The player can request cards to be dealt
case deal = "deal"
@ -24,9 +26,9 @@ enum PlayerAction: String, Codable {
/// The player claims to win and doubles the game cost ("schießen")
case doubleDuringGame = "raise"
/// The url path for the client to call (e.g. /player/deal)
var path: String {
var id: ActionId {
rawValue
}
}