Adjust table info generation

This commit is contained in:
Christoph Hagen 2021-12-09 11:17:11 +01:00
parent 3e85c01809
commit 445363307b
3 changed files with 11 additions and 5 deletions

View File

@ -27,15 +27,16 @@ struct TableInfo: Codable {
init(id: String, name: String, init(id: String, name: String,
own: PlayerInfo, left: PlayerInfo?, own: PlayerInfo, left: PlayerInfo?,
across: PlayerInfo?, right: PlayerInfo?, across: PlayerInfo?, right: PlayerInfo?,
games: [GameId] = [], actions: [PlayerAction], games: [GameType] = [], actions: [PlayerAction],
cards: [PlayableCard], selectGame: Bool = false) { cards: [PlayableCard],
selectGame: Bool = false) {
self.id = id self.id = id
self.name = name self.name = name
self.player = own self.player = own
self.playerLeft = left self.playerLeft = left
self.playerAcross = across self.playerAcross = across
self.playerRight = right self.playerRight = right
self.playableGames = games self.playableGames = games.map { $0.id }
self.actions = actions.map { $0.path } self.actions = actions.map { $0.path }
self.cards = cards.map { $0.cardInfo } self.cards = cards.map { $0.cardInfo }
self.playerSelectsGame = selectGame self.playerSelectsGame = selectGame

View File

@ -1,7 +1,5 @@
import Foundation import Foundation
typealias GameId = String
extension GameType { extension GameType {
var gameClass: GameClass { var gameClass: GameClass {

View File

@ -1,5 +1,8 @@
import Foundation import Foundation
/// The string id of a game
typealias GameId = String
enum GameType: String, CaseIterable, Codable { enum GameType: String, CaseIterable, Codable {
case rufEichel = "ruf-eichel" case rufEichel = "ruf-eichel"
@ -14,6 +17,10 @@ enum GameType: String, CaseIterable, Codable {
case soloHerz = "solo-herz" case soloHerz = "solo-herz"
case soloSchelln = "solo-schelln" case soloSchelln = "solo-schelln"
init?(id: GameId) {
self.init(rawValue: id)
}
var isCall: Bool { var isCall: Bool {
switch self { switch self {
case .rufEichel, .rufBlatt, .rufSchelln: case .rufEichel, .rufBlatt, .rufSchelln: