From 08269639606c0481037cbde7ebaf2e0455460883 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 18:43:09 +0100 Subject: v2.2.1: forfeit blackjack bets when leaving or disconnecting --- src/client/core.rs | 18 +++++++++++------- src/client/games/blackjack.rs | 9 +++++---- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/client') diff --git a/src/client/core.rs b/src/client/core.rs index 6e9c28b..77761b4 100644 --- a/src/client/core.rs +++ b/src/client/core.rs @@ -65,7 +65,7 @@ enum Pending { RouletteSpin, BlackjackStart, BlackjackAction, - BlackjackCancel, + BlackjackForfeit, Ping, Echo, Info, @@ -209,12 +209,16 @@ impl ClientCore { } } } - Some(Pending::BlackjackCancel) => match parse_blackjack_response(reply) { - Ok(_) => { + Some(Pending::BlackjackForfeit) => match parse_blackjack_response(reply) { + Ok(state) => { self.game.end_game(); + let message = format!( + "Game exited. Active hand forfeited ({} PLN lost).", + state.bet + ); vec![ Effect::ClearRegion, - Effect::Print(vec!["Game exited.".to_string()]), + Effect::Print(vec![message]), ] } Err(message) => { @@ -457,10 +461,10 @@ impl ClientCore { Key::CtrlC => vec![Effect::Quit], Key::Char('q') => { if let Some(hand) = hand.filter(|hand| hand.phase == "player") { - self.game.set_blackjack_status("cancelling"); - self.pending = Some(Pending::BlackjackCancel); + self.game.set_blackjack_status("forfeiting"); + self.pending = Some(Pending::BlackjackForfeit); vec![Effect::SendLine(format!( - "BLACKJACK_ACTION {} cancel", + "BLACKJACK_ACTION {} forfeit", hand.session_id ))] } else { diff --git a/src/client/games/blackjack.rs b/src/client/games/blackjack.rs index a34eb63..bad1781 100644 --- a/src/client/games/blackjack.rs +++ b/src/client/games/blackjack.rs @@ -38,6 +38,7 @@ impl BlackjackGame { "push" => "Push. Bet returned.".to_string(), "lose" => "Dealer wins.".to_string(), "bust" => "Bust.".to_string(), + "forfeit" => "Forfeited. Bet lost.".to_string(), "cancelled" => "Cancelled.".to_string(), _ => "Hand complete.".to_string(), } @@ -85,15 +86,15 @@ impl Game for BlackjackGame { } } "dealing" => "Dealing...".to_string(), - "cancelling" => "Cancelling...".to_string(), + "forfeiting" => "Forfeiting...".to_string(), "done" => Self::result_text(&hand.result, hand.winnings), _ => "Press [SPACE] to deal.".to_string(), }; let controls = if status == "player" { if hand.actions.iter().any(|action| action == "double") { - "[H]it [S]tand [D]ouble [Q]uit".to_string() + "[H]it [S]tand [D]ouble [Q] Forfeit".to_string() } else { - "[H]it [S]tand [Q]uit".to_string() + "[H]it [S]tand [Q] Forfeit".to_string() } } else { "[SPACE] New hand [+/-] Bet [Q] Quit".to_string() @@ -142,7 +143,7 @@ impl Game for BlackjackGame { D - double (when available)\n\ SPACE - deal a new hand\n\ +/- - change the next hand's bet\n\ - Q - leave the table" + Q - forfeit an active hand (bet is lost), or leave when no hand is active" .to_string() } } -- cgit v1.2.3