First working version

This commit is contained in:
Christoph Hagen
2021-12-18 15:08:43 +01:00
parent c9853dee28
commit 49787db1aa
32 changed files with 1416 additions and 415 deletions

View File

@ -6,6 +6,14 @@ typealias Hand = [Card]
extension Array where Element == Card {
var unplayable: [PlayableCard] {
map { $0.unplayable }
}
var playable: [PlayableCard] {
map { $0.playable }
}
var points: Int {
map { $0.points }
.reduce(0, +)

View File

@ -10,6 +10,10 @@ struct Card: Codable {
case blatt = "B"
case herz = "H"
case schelln = "S"
var ace: Card {
.init(self, .ass)
}
}
let symbol: Symbol
@ -45,6 +49,18 @@ struct Card: Codable {
var points: Int {
symbol.points
}
var playable: PlayableCard {
.init(card: self, isPlayable: true)
}
var unplayable: PlayableCard {
.init(card: self, isPlayable: false)
}
func playable(_ isPlayable: Bool) -> PlayableCard {
.init(card: self, isPlayable: isPlayable)
}
static let allCards: Set<Card> = {
let all = Card.Suit.allCases.map { suit in