112 lines
3.4 KiB
Swift
112 lines
3.4 KiB
Swift
//
|
|
// BaccaratStats.swift
|
|
// Baccarat
|
|
//
|
|
// Baccarat-specific statistics that conform to CasinoKit's GameSpecificStats.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
import CasinoKit
|
|
|
|
/// Baccarat-specific session statistics.
|
|
/// Tracks naturals, banker/player wins, ties, pairs, and dragon bonus wins.
|
|
public struct BaccaratStats: GameSpecificStats {
|
|
/// Number of natural hands (8 or 9 on initial deal).
|
|
public var naturals: Int = 0
|
|
|
|
/// Number of banker win rounds.
|
|
public var bankerWins: Int = 0
|
|
|
|
/// Number of player win rounds.
|
|
public var playerWins: Int = 0
|
|
|
|
/// Number of tie rounds.
|
|
public var ties: Int = 0
|
|
|
|
/// Number of player pair occurrences.
|
|
public var playerPairs: Int = 0
|
|
|
|
/// Number of banker pair occurrences.
|
|
public var bankerPairs: Int = 0
|
|
|
|
/// Number of dragon bonus wins (player side).
|
|
public var dragonBonusPlayerWins: Int = 0
|
|
|
|
/// Number of dragon bonus wins (banker side).
|
|
public var dragonBonusBankerWins: Int = 0
|
|
|
|
// MARK: - GameSpecificStats
|
|
|
|
public init() {}
|
|
|
|
/// Display items for the statistics UI.
|
|
public var displayItems: [StatDisplayItem] {
|
|
[
|
|
StatDisplayItem(
|
|
icon: "sparkles",
|
|
iconColor: .yellow,
|
|
label: String(localized: "Naturals"),
|
|
value: "\(naturals)",
|
|
valueColor: .yellow
|
|
),
|
|
StatDisplayItem(
|
|
icon: "person.fill",
|
|
iconColor: .blue,
|
|
label: String(localized: "Player Wins"),
|
|
value: "\(playerWins)",
|
|
valueColor: .blue
|
|
),
|
|
StatDisplayItem(
|
|
icon: "building.columns.fill",
|
|
iconColor: .red,
|
|
label: String(localized: "Banker Wins"),
|
|
value: "\(bankerWins)",
|
|
valueColor: .red
|
|
),
|
|
StatDisplayItem(
|
|
icon: "equal.circle.fill",
|
|
iconColor: .green,
|
|
label: String(localized: "Ties"),
|
|
value: "\(ties)",
|
|
valueColor: .green
|
|
),
|
|
StatDisplayItem(
|
|
icon: "suit.diamond.fill",
|
|
iconColor: .purple,
|
|
label: String(localized: "Pairs"),
|
|
value: "\(playerPairs + bankerPairs)",
|
|
valueColor: .purple
|
|
)
|
|
]
|
|
}
|
|
}
|
|
|
|
// MARK: - Aggregation Extension
|
|
|
|
extension Array where Element == GameSession<BaccaratStats> {
|
|
/// Aggregates Baccarat-specific stats from all sessions.
|
|
func aggregatedBaccaratStats() -> BaccaratStats {
|
|
var combined = BaccaratStats()
|
|
|
|
for session in self {
|
|
combined.naturals += session.gameStats.naturals
|
|
combined.bankerWins += session.gameStats.bankerWins
|
|
combined.playerWins += session.gameStats.playerWins
|
|
combined.ties += session.gameStats.ties
|
|
combined.playerPairs += session.gameStats.playerPairs
|
|
combined.bankerPairs += session.gameStats.bankerPairs
|
|
combined.dragonBonusPlayerWins += session.gameStats.dragonBonusPlayerWins
|
|
combined.dragonBonusBankerWins += session.gameStats.dragonBonusBankerWins
|
|
}
|
|
|
|
return combined
|
|
}
|
|
}
|
|
|
|
// MARK: - Type Aliases for Convenience
|
|
|
|
/// Baccarat session type alias.
|
|
public typealias BaccaratSession = GameSession<BaccaratStats>
|
|
|