summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/client/core.rs18
-rw-r--r--src/client/games/blackjack.rs9
2 files changed, 16 insertions, 11 deletions
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 {
65 RouletteSpin, 65 RouletteSpin,
66 BlackjackStart, 66 BlackjackStart,
67 BlackjackAction, 67 BlackjackAction,
68 BlackjackCancel, 68 BlackjackForfeit,
69 Ping, 69 Ping,
70 Echo, 70 Echo,
71 Info, 71 Info,
@@ -209,12 +209,16 @@ impl ClientCore {
209 } 209 }
210 } 210 }
211 } 211 }
212 Some(Pending::BlackjackCancel) => match parse_blackjack_response(reply) { 212 Some(Pending::BlackjackForfeit) => match parse_blackjack_response(reply) {
213 Ok(_) => { 213 Ok(state) => {
214 self.game.end_game(); 214 self.game.end_game();
215 let message = format!(
216 "Game exited. Active hand forfeited ({} PLN lost).",
217 state.bet
218 );
215 vec![ 219 vec![
216 Effect::ClearRegion, 220 Effect::ClearRegion,
217 Effect::Print(vec!["Game exited.".to_string()]), 221 Effect::Print(vec![message]),
218 ] 222 ]
219 } 223 }
220 Err(message) => { 224 Err(message) => {
@@ -457,10 +461,10 @@ impl ClientCore {
457 Key::CtrlC => vec![Effect::Quit], 461 Key::CtrlC => vec![Effect::Quit],
458 Key::Char('q') => { 462 Key::Char('q') => {
459 if let Some(hand) = hand.filter(|hand| hand.phase == "player") { 463 if let Some(hand) = hand.filter(|hand| hand.phase == "player") {
460 self.game.set_blackjack_status("cancelling"); 464 self.game.set_blackjack_status("forfeiting");
461 self.pending = Some(Pending::BlackjackCancel); 465 self.pending = Some(Pending::BlackjackForfeit);
462 vec![Effect::SendLine(format!( 466 vec![Effect::SendLine(format!(
463 "BLACKJACK_ACTION {} cancel", 467 "BLACKJACK_ACTION {} forfeit",
464 hand.session_id 468 hand.session_id
465 ))] 469 ))]
466 } else { 470 } 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 {
38 "push" => "Push. Bet returned.".to_string(), 38 "push" => "Push. Bet returned.".to_string(),
39 "lose" => "Dealer wins.".to_string(), 39 "lose" => "Dealer wins.".to_string(),
40 "bust" => "Bust.".to_string(), 40 "bust" => "Bust.".to_string(),
41 "forfeit" => "Forfeited. Bet lost.".to_string(),
41 "cancelled" => "Cancelled.".to_string(), 42 "cancelled" => "Cancelled.".to_string(),
42 _ => "Hand complete.".to_string(), 43 _ => "Hand complete.".to_string(),
43 } 44 }
@@ -85,15 +86,15 @@ impl Game for BlackjackGame {
85 } 86 }
86 } 87 }
87 "dealing" => "Dealing...".to_string(), 88 "dealing" => "Dealing...".to_string(),
88 "cancelling" => "Cancelling...".to_string(), 89 "forfeiting" => "Forfeiting...".to_string(),
89 "done" => Self::result_text(&hand.result, hand.winnings), 90 "done" => Self::result_text(&hand.result, hand.winnings),
90 _ => "Press [SPACE] to deal.".to_string(), 91 _ => "Press [SPACE] to deal.".to_string(),
91 }; 92 };
92 let controls = if status == "player" { 93 let controls = if status == "player" {
93 if hand.actions.iter().any(|action| action == "double") { 94 if hand.actions.iter().any(|action| action == "double") {
94 "[H]it [S]tand [D]ouble [Q]uit".to_string() 95 "[H]it [S]tand [D]ouble [Q] Forfeit".to_string()
95 } else { 96 } else {
96 "[H]it [S]tand [Q]uit".to_string() 97 "[H]it [S]tand [Q] Forfeit".to_string()
97 } 98 }
98 } else { 99 } else {
99 "[SPACE] New hand [+/-] Bet [Q] Quit".to_string() 100 "[SPACE] New hand [+/-] Bet [Q] Quit".to_string()
@@ -142,7 +143,7 @@ impl Game for BlackjackGame {
142 D - double (when available)\n\ 143 D - double (when available)\n\
143 SPACE - deal a new hand\n\ 144 SPACE - deal a new hand\n\
144 +/- - change the next hand's bet\n\ 145 +/- - change the next hand's bet\n\
145 Q - leave the table" 146 Q - forfeit an active hand (bet is lost), or leave when no hand is active"
146 .to_string() 147 .to_string()
147 } 148 }
148} 149}