27 lines
620 B
Swift
27 lines
620 B
Swift
import Foundation
|
|
|
|
enum SwapSource: Equatable {
|
|
case deck
|
|
case discard
|
|
}
|
|
|
|
struct HandCard: Equatable {
|
|
var value: UInt8
|
|
var faceUp: Bool
|
|
}
|
|
|
|
enum CardDisplay {
|
|
static let ranks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]
|
|
static let suits = ["♠", "♥", "♦", "♣"]
|
|
|
|
static func label(for value: UInt8) -> String {
|
|
let rank = Int(value) % 13
|
|
let suit = Int(value) / 13
|
|
return "\(ranks[rank])\(suits[suit])"
|
|
}
|
|
|
|
static func isRed(value: UInt8) -> Bool {
|
|
let suit = Int(value) / 13
|
|
return suit == 1 || suit == 2
|
|
}
|
|
}
|