diff --git a/Sources/App/Infos/TableInfo.swift b/Sources/App/Infos/TableInfo.swift index 33c0d5a..f598fb2 100644 --- a/Sources/App/Infos/TableInfo.swift +++ b/Sources/App/Infos/TableInfo.swift @@ -27,15 +27,16 @@ struct TableInfo: Codable { init(id: String, name: String, own: PlayerInfo, left: PlayerInfo?, across: PlayerInfo?, right: PlayerInfo?, - games: [GameId] = [], actions: [PlayerAction], - cards: [PlayableCard], selectGame: Bool = false) { + games: [GameType] = [], actions: [PlayerAction], + cards: [PlayableCard], + selectGame: Bool = false) { self.id = id self.name = name self.player = own self.playerLeft = left self.playerAcross = across self.playerRight = right - self.playableGames = games + self.playableGames = games.map { $0.id } self.actions = actions.map { $0.path } self.cards = cards.map { $0.cardInfo } self.playerSelectsGame = selectGame diff --git a/Sources/App/Model/GameClass.swift b/Sources/App/Model/GameClass.swift index 8225bbe..fa45cd7 100644 --- a/Sources/App/Model/GameClass.swift +++ b/Sources/App/Model/GameClass.swift @@ -1,7 +1,5 @@ import Foundation -typealias GameId = String - extension GameType { var gameClass: GameClass { diff --git a/Sources/App/Model/GameType.swift b/Sources/App/Model/GameType.swift index 93ea4a2..42b9a86 100644 --- a/Sources/App/Model/GameType.swift +++ b/Sources/App/Model/GameType.swift @@ -1,5 +1,8 @@ import Foundation +/// The string id of a game +typealias GameId = String + enum GameType: String, CaseIterable, Codable { case rufEichel = "ruf-eichel" @@ -14,6 +17,10 @@ enum GameType: String, CaseIterable, Codable { case soloHerz = "solo-herz" case soloSchelln = "solo-schelln" + init?(id: GameId) { + self.init(rawValue: id) + } + var isCall: Bool { switch self { case .rufEichel, .rufBlatt, .rufSchelln: