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) .map { $0.sortedCards(order: NormalCardOrder.self) } } static func dealRemainingCards(of initial: [Hand]) -> [Hand] { Card.allCards .subtracting(initial.reduce([], +)) .shuffled() .split(intoChunksOf: 4) } }