118 lines
4.2 KiB
Swift
118 lines
4.2 KiB
Swift
//
|
|
// ChipDenomination.swift
|
|
// Baccarat
|
|
//
|
|
// The available chip denominations with their properties.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
/// The available chip denominations.
|
|
enum ChipDenomination: Int, CaseIterable, Identifiable {
|
|
case ten = 10
|
|
case twentyFive = 25
|
|
case fifty = 50
|
|
case hundred = 100
|
|
case fiveHundred = 500
|
|
case thousand = 1_000
|
|
case fiveThousand = 5_000
|
|
case tenThousand = 10_000
|
|
case twentyFiveThousand = 25_000
|
|
case fiftyThousand = 50_000
|
|
case hundredThousand = 100_000
|
|
|
|
var id: Int { rawValue }
|
|
|
|
/// The display text for this denomination.
|
|
var displayText: String {
|
|
switch self {
|
|
case .ten: return "10"
|
|
case .twentyFive: return "25"
|
|
case .fifty: return "50"
|
|
case .hundred: return "100"
|
|
case .fiveHundred: return "500"
|
|
case .thousand: return "1K"
|
|
case .fiveThousand: return "5K"
|
|
case .tenThousand: return "10K"
|
|
case .twentyFiveThousand: return "25K"
|
|
case .fiftyThousand: return "50K"
|
|
case .hundredThousand: return "100K"
|
|
}
|
|
}
|
|
|
|
/// The minimum balance required to show this chip in the selector.
|
|
/// Higher chips unlock as you win more!
|
|
var unlockBalance: Int {
|
|
switch self {
|
|
case .ten, .twentyFive, .fifty, .hundred: return 0 // Always available
|
|
case .fiveHundred: return 500
|
|
case .thousand: return 1_000
|
|
case .fiveThousand: return 5_000
|
|
case .tenThousand: return 10_000
|
|
case .twentyFiveThousand: return 25_000
|
|
case .fiftyThousand: return 50_000
|
|
case .hundredThousand: return 100_000
|
|
}
|
|
}
|
|
|
|
/// Whether this chip should be shown based on the player's balance.
|
|
func isUnlocked(forBalance balance: Int) -> Bool {
|
|
balance >= unlockBalance
|
|
}
|
|
|
|
/// Returns chips that should be visible for a given balance.
|
|
static func availableChips(forBalance balance: Int) -> [ChipDenomination] {
|
|
allCases.filter { $0.isUnlocked(forBalance: balance) }
|
|
}
|
|
|
|
/// The primary color for this chip.
|
|
var primaryColor: Color {
|
|
switch self {
|
|
case .ten: return Color.Chip.tenBase
|
|
case .twentyFive: return Color.Chip.twentyFiveBase
|
|
case .fifty: return Color.Chip.fiftyBase
|
|
case .hundred: return Color.Chip.hundredBase
|
|
case .fiveHundred: return Color.Chip.fiveHundredBase
|
|
case .thousand: return Color.Chip.thousandBase
|
|
case .fiveThousand: return Color.Chip.fiveThousandBase
|
|
case .tenThousand: return Color.Chip.tenThousandBase
|
|
case .twentyFiveThousand: return Color.Chip.twentyFiveThousandBase
|
|
case .fiftyThousand: return Color.Chip.fiftyThousandBase
|
|
case .hundredThousand: return Color.Chip.hundredThousandBase
|
|
}
|
|
}
|
|
|
|
/// The secondary/accent color for this chip.
|
|
var secondaryColor: Color {
|
|
switch self {
|
|
case .ten: return Color.Chip.tenHighlight
|
|
case .twentyFive: return Color.Chip.twentyFiveHighlight
|
|
case .fifty: return Color.Chip.fiftyHighlight
|
|
case .hundred: return Color.Chip.hundredHighlight
|
|
case .fiveHundred: return Color.Chip.fiveHundredHighlight
|
|
case .thousand: return Color.Chip.thousandHighlight
|
|
case .fiveThousand: return Color.Chip.fiveThousandHighlight
|
|
case .tenThousand: return Color.Chip.tenThousandHighlight
|
|
case .twentyFiveThousand: return Color.Chip.twentyFiveThousandHighlight
|
|
case .fiftyThousand: return Color.Chip.fiftyThousandHighlight
|
|
case .hundredThousand: return Color.Chip.hundredThousandHighlight
|
|
}
|
|
}
|
|
|
|
/// The edge stripe color for this chip.
|
|
var stripeColor: Color {
|
|
switch self {
|
|
case .ten, .twentyFive, .fifty: return .white
|
|
case .hundred: return Color.Chip.goldStripe
|
|
case .fiveHundred: return .white
|
|
case .thousand: return .black
|
|
case .fiveThousand: return Color.Chip.goldStripe
|
|
case .tenThousand: return .white
|
|
case .twentyFiveThousand: return Color.Chip.goldStripe
|
|
case .fiftyThousand: return Color.Chip.darkStripe
|
|
case .hundredThousand: return Color.Chip.goldRubyStripe
|
|
}
|
|
}
|
|
}
|
|
|