Play cards, select game, player actions

This commit is contained in:
Christoph Hagen
2021-12-06 18:28:35 +01:00
parent ca7fc858c2
commit fa3aaadef8
11 changed files with 304 additions and 128 deletions

View File

@ -26,7 +26,7 @@ extension CardOrder {
static func highCardIndex(cards: [Card]) -> Int {
let high: Card
if isTrump(cards[0]) {
if hasTrump(in: cards) {
high = sort(cards).first!
} else {
let suit = cards.first!.suit
@ -66,4 +66,8 @@ extension CardOrder {
static func cards(with suit: Card.Suit, in cards: [Card]) -> [Card] {
cards.filter { !isTrump($0) && $0.suit == suit }
}
static func hasCardToCall(_ suit: Card.Suit, in cards: [Card]) -> Bool {
cards.contains { $0.symbol != .ass && $0.suit == suit && !isTrump($0) }
}
}