// // Card.swift // Baccarat // // A playing card model with suit, rank, and baccarat value calculation. // import Foundation /// Represents the four suits in a standard deck of cards. enum Suit: String, CaseIterable, Identifiable { case hearts = "♥" case diamonds = "♦" case clubs = "♣" case spades = "♠" var id: String { rawValue } /// Whether this suit is red (hearts or diamonds). var isRed: Bool { self == .hearts || self == .diamonds } } /// Represents the rank of a card from Ace through King. enum Rank: Int, CaseIterable, Identifiable { case ace = 1 case two = 2 case three = 3 case four = 4 case five = 5 case six = 6 case seven = 7 case eight = 8 case nine = 9 case ten = 10 case jack = 11 case queen = 12 case king = 13 var id: Int { rawValue } /// The display symbol for this rank. var symbol: String { switch self { case .ace: return "A" case .jack: return "J" case .queen: return "Q" case .king: return "K" default: return String(rawValue) } } /// The baccarat point value for this rank. /// Aces = 1, 2-9 = face value, 10/J/Q/K = 0 var baccaratValue: Int { switch self { case .ace: return 1 case .two, .three, .four, .five, .six, .seven, .eight, .nine: return rawValue case .ten, .jack, .queen, .king: return 0 } } } /// Represents a single playing card with a suit and rank. struct Card: Identifiable, Equatable { let id = UUID() let suit: Suit let rank: Rank /// The baccarat point value of this card. var baccaratValue: Int { rank.baccaratValue } /// Display string showing rank and suit together. var display: String { "\(rank.symbol)\(suit.rawValue)" } }