Schafkopf-Server/Sources/App/Model/Tables/DealingTable.swift

40 lines
996 B
Swift
Raw Normal View History

import Foundation
final class DealingTable: AbstractTable {
var players: [DealingPlayer]
init(table: WaitingTable) {
self.players = table.players.map(DealingPlayer.init)
super.init(table: table)
let cards = Dealer.dealFirstCards()
for (index, player) in players.enumerated() {
player.cards = cards[index].map { .init(card: $0, isPlayable: false) }
}
}
}
extension DealingTable: Table {
var allPlayers: [Player] {
players
}
var indexOfNextActor: Int {
// TODO: Implement
return 0
}
func perform(action: PlayerAction, forPlayer: PlayerName) -> (result: PlayerActionResult, table: Table?) {
// TODO: Implement doubling, additional cards
return (.tableStateInvalid, nil)
}
func play(card: Card, player name: PlayerName) -> (result: PlayerActionResult, table: Table?) {
// No cards playable while dealing
(.tableStateInvalid, nil)
}
}