2021-12-03 18:03:29 +01:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct Dealer {
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a random assignment of 4 cards per 4 players for the initial round of doubling.
|
|
|
|
*/
|
|
|
|
static func dealFirstCards() -> [Hand] {
|
|
|
|
// Select 16 random cards for the first hands
|
|
|
|
Array(Card.allCards.shuffled()[0..<16])
|
|
|
|
.split(intoChunksOf: 4)
|
2021-12-06 11:43:30 +01:00
|
|
|
.map { $0.sortedCards(order: NormalCardOrder.self) }
|
2021-12-03 18:03:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static func dealRemainingCards(of initial: [Hand]) -> [Hand] {
|
|
|
|
Card.allCards
|
|
|
|
.subtracting(initial.reduce([], +))
|
|
|
|
.shuffled()
|
|
|
|
.split(intoChunksOf: 4)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|