bjrs/
result.rs

1//! Round result types for showdown.
2
3extern crate alloc;
4
5use alloc::vec::Vec;
6
7/// Result of a single hand after showdown.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum HandOutcome {
10    /// Player wins (dealer busts or player has higher value).
11    Win,
12    /// Player loses (player busts or dealer has higher value).
13    Lose,
14    /// Push (tie).
15    Push,
16    /// Player has blackjack.
17    Blackjack,
18    /// Player surrendered.
19    Surrendered,
20}
21
22/// Result for a single hand.
23#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub struct HandResult {
25    /// The hand index (for split hands).
26    pub hand_index: usize,
27    /// The outcome of the hand.
28    pub outcome: HandOutcome,
29    /// The bet amount for this hand.
30    pub bet: usize,
31    /// The payout amount (winnings added to player money).
32    pub payout: usize,
33    /// The player's hand value.
34    pub player_value: u8,
35    /// The dealer's hand value.
36    pub dealer_value: u8,
37}
38
39/// Result for a single player after showdown.
40#[derive(Debug, Clone)]
41pub struct PlayerResult {
42    /// The player ID.
43    pub player_id: u8,
44    /// Results for each hand (multiple if split).
45    pub hands: Vec<HandResult>,
46    /// Total payout for all hands.
47    pub total_payout: usize,
48    /// Net result (positive = profit, negative = loss).
49    pub net: isize,
50    /// Insurance bet amount (0 if no insurance taken).
51    pub insurance_bet: usize,
52    /// Insurance payout (0 if dealer didn't have blackjack or no insurance taken).
53    pub insurance_payout: usize,
54}
55
56/// Result of the entire round after showdown.
57#[derive(Debug, Clone)]
58pub struct RoundResult {
59    /// Results for each player.
60    pub players: Vec<PlayerResult>,
61    /// The dealer's final hand value.
62    pub dealer_value: u8,
63    /// Whether the dealer busted.
64    pub dealer_bust: bool,
65    /// Whether the dealer had blackjack.
66    pub dealer_blackjack: bool,
67}