diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 22:16:15 +0100 |
| commit | bc0de9955c375cf27d52c9934403964205afc182 (patch) | |
| tree | 42799fb426fb0ec164f44c92a63525003c582f35 /src/client/core.rs | |
| parent | initial connection timeout set to 10s (diff) | |
| download | zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.tar.gz zagan-bet-bc0de9955c375cf27d52c9934403964205afc182.zip | |
formatting
Diffstat (limited to '')
| -rw-r--r-- | src/client/core.rs | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/src/client/core.rs b/src/client/core.rs index 5f8c513..06d9c42 100644 --- a/src/client/core.rs +++ b/src/client/core.rs | |||
| @@ -3,8 +3,8 @@ use crate::client::games::response::{ | |||
| 3 | parse_blackjack_response, parse_crash_response, parse_roulette_response, parse_spin_response, | 3 | parse_blackjack_response, parse_crash_response, parse_roulette_response, parse_spin_response, |
| 4 | }; | 4 | }; |
| 5 | use crate::client::ui::{ | 5 | use crate::client::ui::{ |
| 6 | command_names, completion_lines, display_width, help_lines, input_cursor_column, | 6 | command_names, completion_lines, display_width, help_lines, input_cursor_column, parse_bet_arg, |
| 7 | parse_bet_arg, record_history, | 7 | record_history, |
| 8 | }; | 8 | }; |
| 9 | use crate::crash::{multiplier_at, CrashState}; | 9 | use crate::crash::{multiplier_at, CrashState}; |
| 10 | use crate::roulette::{Bets, NumberBet}; | 10 | use crate::roulette::{Bets, NumberBet}; |
| @@ -225,10 +225,7 @@ impl ClientCore { | |||
| 225 | "Game exited. Active hand forfeited ({} PLN lost).", | 225 | "Game exited. Active hand forfeited ({} PLN lost).", |
| 226 | state.bet | 226 | state.bet |
| 227 | ); | 227 | ); |
| 228 | vec![ | 228 | vec![Effect::ClearRegion, Effect::Print(vec![message])] |
| 229 | Effect::ClearRegion, | ||
| 230 | Effect::Print(vec![message]), | ||
| 231 | ] | ||
| 232 | } | 229 | } |
| 233 | Err(message) => { | 230 | Err(message) => { |
| 234 | self.game.set_error(message); | 231 | self.game.set_error(message); |
| @@ -258,10 +255,7 @@ impl ClientCore { | |||
| 258 | Ok(state) => { | 255 | Ok(state) => { |
| 259 | self.crash_started = None; | 256 | self.crash_started = None; |
| 260 | self.game.end_game(); | 257 | self.game.end_game(); |
| 261 | let message = format!( | 258 | let message = format!("Game exited. Round forfeited ({} PLN lost).", state.bet); |
| 262 | "Game exited. Round forfeited ({} PLN lost).", | ||
| 263 | state.bet | ||
| 264 | ); | ||
| 265 | vec![Effect::ClearRegion, Effect::Print(vec![message])] | 259 | vec![Effect::ClearRegion, Effect::Print(vec![message])] |
| 266 | } | 260 | } |
| 267 | Err(_) if self.game.crash_status() != "running" => { | 261 | Err(_) if self.game.crash_status() != "running" => { |
| @@ -286,9 +280,7 @@ impl ClientCore { | |||
| 286 | self.logged_in = None; | 280 | self.logged_in = None; |
| 287 | vec![ | 281 | vec![ |
| 288 | Effect::Disconnect, | 282 | Effect::Disconnect, |
| 289 | Effect::Print(vec![ | 283 | Effect::Print(vec!["Connection lost".to_string()]), |
| 290 | "Connection lost".to_string(), | ||
| 291 | ]), | ||
| 292 | ] | 284 | ] |
| 293 | } | 285 | } |
| 294 | } | 286 | } |
| @@ -531,27 +523,20 @@ impl ClientCore { | |||
| 531 | } | 523 | } |
| 532 | } | 524 | } |
| 533 | Key::Char(' ') => self.start_blackjack(), | 525 | Key::Char(' ') => self.start_blackjack(), |
| 534 | Key::Char('h') | 526 | Key::Char('h') if hand.as_ref().is_some_and(|hand| hand.phase == "player") => { |
| 535 | if hand.as_ref().is_some_and(|hand| hand.phase == "player") => | ||
| 536 | { | ||
| 537 | self.blackjack_action("hit") | 527 | self.blackjack_action("hit") |
| 538 | } | 528 | } |
| 539 | Key::Char('s') | 529 | Key::Char('s') if hand.as_ref().is_some_and(|hand| hand.phase == "player") => { |
| 540 | if hand.as_ref().is_some_and(|hand| hand.phase == "player") => | ||
| 541 | { | ||
| 542 | self.blackjack_action("stand") | 530 | self.blackjack_action("stand") |
| 543 | } | 531 | } |
| 544 | Key::Char('d') | 532 | Key::Char('d') |
| 545 | if hand.as_ref().is_some_and(|hand| { | 533 | if hand.as_ref().is_some_and(|hand| { |
| 546 | hand.phase == "player" | 534 | hand.phase == "player" && hand.actions.iter().any(|action| action == "double") |
| 547 | && hand.actions.iter().any(|action| action == "double") | ||
| 548 | }) => | 535 | }) => |
| 549 | { | 536 | { |
| 550 | self.blackjack_action("double") | 537 | self.blackjack_action("double") |
| 551 | } | 538 | } |
| 552 | Key::Char('+') | Key::Char('=') | 539 | Key::Char('+') | Key::Char('=') if matches!(status.as_str(), "ready" | "done") => { |
| 553 | if matches!(status.as_str(), "ready" | "done") => | ||
| 554 | { | ||
| 555 | let _ = self.game.adjust_bet(10); | 540 | let _ = self.game.adjust_bet(10); |
| 556 | self.board_effects() | 541 | self.board_effects() |
| 557 | } | 542 | } |
| @@ -602,9 +587,7 @@ impl ClientCore { | |||
| 602 | if hand.phase != "player" { | 587 | if hand.phase != "player" { |
| 603 | return Vec::new(); | 588 | return Vec::new(); |
| 604 | } | 589 | } |
| 605 | if action == "double" | 590 | if action == "double" && !hand.actions.iter().any(|available| available == "double") { |
| 606 | && !hand.actions.iter().any(|available| available == "double") | ||
| 607 | { | ||
| 608 | return Vec::new(); | 591 | return Vec::new(); |
| 609 | } | 592 | } |
| 610 | self.pending = Some(Pending::BlackjackAction); | 593 | self.pending = Some(Pending::BlackjackAction); |
| @@ -914,9 +897,9 @@ impl ClientCore { | |||
| 914 | Some(fingerprint) => { | 897 | Some(fingerprint) => { |
| 915 | effects.push(Effect::Print(vec![format!("Fingerprint: {fingerprint}")])) | 898 | effects.push(Effect::Print(vec![format!("Fingerprint: {fingerprint}")])) |
| 916 | } | 899 | } |
| 917 | None => effects.push(Effect::Print(vec![ | 900 | None => effects.push(Effect::Print( |
| 918 | "Fingerprint: (not trusted)".to_string(), | 901 | vec!["Fingerprint: (not trusted)".to_string()], |
| 919 | ])), | 902 | )), |
| 920 | } | 903 | } |
| 921 | 904 | ||
| 922 | self.pending = Some(Pending::Info); | 905 | self.pending = Some(Pending::Info); |
