From f07221b4e1d8aa464a44fe566884ccc0565406e9 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 1 Nov 2026 16:17:19 +0100 Subject: v3.2.0: straight and split bets anywhere on the felt; add history command --- src/client/core.rs | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/client/core.rs') diff --git a/src/client/core.rs b/src/client/core.rs index 54a6434..0b2e683 100644 --- a/src/client/core.rs +++ b/src/client/core.rs @@ -1,13 +1,15 @@ use crate::client::games::manager::GameManager; use crate::client::games::response::{ - parse_blackjack_response, parse_crash_response, parse_roulette_response, parse_spin_response, + parse_blackjack_response, parse_crash_response, parse_history_response, + parse_roulette_response, parse_spin_response, }; use crate::client::games::roulette::Direction; use crate::client::ui::{ - command_names, completion_lines, display_width, help_lines, input_cursor_column, parse_bet_arg, - record_history, + command_names, completion_lines, display_width, help_lines, history_lines, + input_cursor_column, parse_bet_arg, record_history, }; use crate::crash::{CrashState, multiplier_at}; +use crate::history::MAX_HISTORY; use crate::roulette::Bets; use std::time::{Duration, Instant}; @@ -74,6 +76,7 @@ enum Pending { CrashStart, CrashCashout, CrashForfeit, + History, Ping, Echo, Info, @@ -290,6 +293,10 @@ impl ClientCore { self.board_effects() } }, + Some(Pending::History) => match parse_history_response(reply) { + Ok(records) => vec![Effect::Print(history_lines(&records))], + Err(message) => print_line(message), + }, Some(Pending::Ping) => { if reply.trim() == "PONG" { print_line("Pong") @@ -782,6 +789,7 @@ impl ClientCore { } } "info" => self.cmd_info(), + "history" => self.cmd_history(&parts), "hosts" => vec![Effect::ListHosts], "forget-host" => { let target = parts @@ -851,6 +859,26 @@ impl ClientCore { vec![Effect::Print(lines)] } + fn cmd_history(&mut self, parts: &[&str]) -> Vec { + if !self.connected { + return print_line("Not connected. Use 'connect :' first."); + } + if self.logged_in.is_none() { + return print_line("Not logged in. Use 'login' first."); + } + + let request = match parts.get(1) { + Some(raw) => match raw.parse::() { + Ok(count) if (1..=MAX_HISTORY).contains(&count) => format!("HISTORY {count}"), + _ => return print_line(format!("Usage: history [1-{MAX_HISTORY}]")), + }, + None => "HISTORY".to_string(), + }; + + self.pending = Some(Pending::History); + vec![Effect::SendLine(request)] + } + fn cmd_info(&mut self) -> Vec { if !self.connected { return print_line("Not connected to any host."); -- cgit v1.2.3