From bc0de9955c375cf27d52c9934403964205afc182 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:16:15 +0100 Subject: formatting --- src/bin/client/repl.rs | 27 +++++++++----------------- src/bin/client/tls.rs | 17 ++++++++-------- src/bin/server/args.rs | 5 +---- src/bin/server/main.rs | 6 +++--- src/bin/server/tls.rs | 5 +---- src/client/core.rs | 43 +++++++++++++---------------------------- src/client/database.rs | 7 +++---- src/client/games/blackjack.rs | 11 +++++------ src/client/games/manager.rs | 8 ++++---- src/client/games/response.rs | 4 ++-- src/client/games/roulette.rs | 12 ++---------- src/client/games/slots.rs | 6 +----- src/client/ui.rs | 13 +++---------- src/crash.rs | 4 +--- src/roulette.rs | 10 ++++------ src/server/core.rs | 45 +++++++++++++++---------------------------- src/server/games/blackjack.rs | 4 +--- src/server/games/roulette.rs | 10 ++++------ src/server/games/slots.rs | 4 +--- src/server/setup.rs | 20 ++++--------------- src/slots.rs | 10 ++-------- src/tofu.rs | 5 +---- 22 files changed, 88 insertions(+), 188 deletions(-) (limited to 'src') diff --git a/src/bin/client/repl.rs b/src/bin/client/repl.rs index 7fa462a..9af4ea9 100644 --- a/src/bin/client/repl.rs +++ b/src/bin/client/repl.rs @@ -1,14 +1,14 @@ use rusqlite::Connection; -use std::io::{stdout, Write}; +use std::io::{Write, stdout}; use std::sync::{Arc, Mutex}; use std::time::Instant; use crossterm::{ cursor::{MoveToColumn, MoveUp, Show}, - event::{read, Event, KeyCode, KeyEventKind, KeyModifiers}, + event::{Event, KeyCode, KeyEventKind, KeyModifiers, read}, execute, style::Stylize, - terminal::{disable_raw_mode, enable_raw_mode, Clear, ClearType}, + terminal::{Clear, ClearType, disable_raw_mode, enable_raw_mode}, }; use sha2::{Digest, Sha256}; @@ -20,7 +20,7 @@ use zagan_bet::client::ui::{ visual_line_count, }; use zagan_bet::protocol::io_failure_message; -use zagan_bet::roulette::{color as roulette_color, WHEEL}; +use zagan_bet::roulette::{WHEEL, color as roulette_color}; use crate::connection::TlsStream; @@ -71,8 +71,7 @@ impl ClientState { self.core.set_connected(true); self.core.set_logged_in(authed_user); let fingerprint = database::get_fingerprint(&self.conn, addr); - self.core - .set_host_info(Some(addr.to_string()), fingerprint); + self.core.set_host_info(Some(addr.to_string()), fingerprint); database::save_host(&self.conn, addr); } Err(e) => { @@ -178,12 +177,9 @@ impl ClientState { Effect::Print(lines) => { self.commit_prompt_line(); for line in lines { - let rendered = if line.starts_with("ERROR") - || line.contains("failed") - { + let rendered = if line.starts_with("ERROR") || line.contains("failed") { line.as_str().red().to_string() - } else if line.starts_with("Logged in") - || line.starts_with("Successfully") + } else if line.starts_with("Logged in") || line.starts_with("Successfully") { line.as_str().green().to_string() } else if line.starts_with("Available commands:") @@ -249,10 +245,7 @@ impl ClientState { Effect::ForgetHost(target) => { self.commit_prompt_line(); match database::forget_host(&self.conn, &target) { - Ok(_) => println!( - "Cleared trust and stored credentials for {}.", - target - ), + Ok(_) => println!("Cleared trust and stored credentials for {}.", target), Err(error) => println!("Failed to forget host: {}", error), } } @@ -297,9 +290,7 @@ impl ClientState { let roulette = lines .first() .is_some_and(|first| first.contains("ROULETTE")); - let crash = lines - .first() - .is_some_and(|first| first.contains("CRASH")); + let crash = lines.first().is_some_and(|first| first.contains("CRASH")); let rendered: Vec = lines .iter() .map(|line| { diff --git a/src/bin/client/tls.rs b/src/bin/client/tls.rs index b46f52b..e14ed98 100644 --- a/src/bin/client/tls.rs +++ b/src/bin/client/tls.rs @@ -17,10 +17,10 @@ use std::net::TcpStream; use std::sync::Arc; use parking_lot::Mutex; -use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; use rustls::DigitallySignedStruct; +use rustls::client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; use zagan_bet::protocol::LineBuffer; -use zagan_bet::tofu::{decide, spki_fingerprint, TrustDecision}; +use zagan_bet::tofu::{TrustDecision, decide, spki_fingerprint}; pub struct TlsConnector { config: Arc, @@ -53,7 +53,10 @@ impl TlsConnector { }) } - pub fn connect(&self, stream: TcpStream) -> Result> { + pub fn connect( + &self, + stream: TcpStream, + ) -> Result> { let mut conn = rustls::ClientConnection::new(Arc::clone(&self.config), self.server_name.clone())?; let mut sock = stream; @@ -200,10 +203,7 @@ impl TlsStream { } /// Apply a read timeout to the underlying TCP socket. - pub fn set_read_timeout( - &self, - duration: Option, - ) -> std::io::Result<()> { + pub fn set_read_timeout(&self, duration: Option) -> std::io::Result<()> { let mut s = self.session.lock(); s.read_timeout = duration; s.sock.set_read_timeout(duration) @@ -235,8 +235,7 @@ impl TlsStream { Err(error) if matches!( error.kind(), - std::io::ErrorKind::WouldBlock - | std::io::ErrorKind::TimedOut + std::io::ErrorKind::WouldBlock | std::io::ErrorKind::TimedOut ) => { return Ok(()); diff --git a/src/bin/server/args.rs b/src/bin/server/args.rs index 1babd1d..1db2a28 100644 --- a/src/bin/server/args.rs +++ b/src/bin/server/args.rs @@ -31,10 +31,7 @@ pub fn parse_args() -> Args { if i + 1 < args.len() { ip = args[i + 1].clone(); if ip != "127.0.0.1" && ip != "0.0.0.0" { - eprintln!( - "Invalid IP address: {}. Must be 127.0.0.1 or 0.0.0.0", - ip - ); + eprintln!("Invalid IP address: {}. Must be 127.0.0.1 or 0.0.0.0", ip); std::process::exit(1); } i += 2; diff --git a/src/bin/server/main.rs b/src/bin/server/main.rs index 85e3134..f42574d 100644 --- a/src/bin/server/main.rs +++ b/src/bin/server/main.rs @@ -40,9 +40,9 @@ fn main() { let db_path = std::env::var("SERVER_DB").unwrap_or_else(|_| "server.db".to_string()); match zagan_bet::server::core::recover_orphaned_reservations(&db_path) { Ok(0) => {} - Ok(count) => println!( - "Settled {count} orphaned reservation(s) as abandoned after a restart" - ), + Ok(count) => { + println!("Settled {count} orphaned reservation(s) as abandoned after a restart") + } Err(error) => { eprintln!("Failed to settle orphaned reservations in {db_path}: {error}"); std::process::exit(1); diff --git a/src/bin/server/tls.rs b/src/bin/server/tls.rs index 5d84589..420b5b4 100644 --- a/src/bin/server/tls.rs +++ b/src/bin/server/tls.rs @@ -80,10 +80,7 @@ impl TlsStream { /// Read timeout for the socket. The connection loop uses a short one so it /// can advance crash rounds while no request is in flight. - pub fn set_read_timeout( - &self, - duration: Option, - ) -> std::io::Result<()> { + pub fn set_read_timeout(&self, duration: Option) -> std::io::Result<()> { self.stream.get_ref().set_read_timeout(duration) } } 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::{ parse_blackjack_response, parse_crash_response, parse_roulette_response, parse_spin_response, }; 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, input_cursor_column, parse_bet_arg, + record_history, }; use crate::crash::{multiplier_at, CrashState}; use crate::roulette::{Bets, NumberBet}; @@ -225,10 +225,7 @@ impl ClientCore { "Game exited. Active hand forfeited ({} PLN lost).", state.bet ); - vec![ - Effect::ClearRegion, - Effect::Print(vec![message]), - ] + vec![Effect::ClearRegion, Effect::Print(vec![message])] } Err(message) => { self.game.set_error(message); @@ -258,10 +255,7 @@ impl ClientCore { Ok(state) => { self.crash_started = None; self.game.end_game(); - let message = format!( - "Game exited. Round forfeited ({} PLN lost).", - state.bet - ); + let message = format!("Game exited. Round forfeited ({} PLN lost).", state.bet); vec![Effect::ClearRegion, Effect::Print(vec![message])] } Err(_) if self.game.crash_status() != "running" => { @@ -286,9 +280,7 @@ impl ClientCore { self.logged_in = None; vec![ Effect::Disconnect, - Effect::Print(vec![ - "Connection lost".to_string(), - ]), + Effect::Print(vec!["Connection lost".to_string()]), ] } } @@ -531,27 +523,20 @@ impl ClientCore { } } Key::Char(' ') => self.start_blackjack(), - Key::Char('h') - if hand.as_ref().is_some_and(|hand| hand.phase == "player") => - { + Key::Char('h') if hand.as_ref().is_some_and(|hand| hand.phase == "player") => { self.blackjack_action("hit") } - Key::Char('s') - if hand.as_ref().is_some_and(|hand| hand.phase == "player") => - { + Key::Char('s') if hand.as_ref().is_some_and(|hand| hand.phase == "player") => { self.blackjack_action("stand") } Key::Char('d') if hand.as_ref().is_some_and(|hand| { - hand.phase == "player" - && hand.actions.iter().any(|action| action == "double") + hand.phase == "player" && hand.actions.iter().any(|action| action == "double") }) => { self.blackjack_action("double") } - Key::Char('+') | Key::Char('=') - if matches!(status.as_str(), "ready" | "done") => - { + Key::Char('+') | Key::Char('=') if matches!(status.as_str(), "ready" | "done") => { let _ = self.game.adjust_bet(10); self.board_effects() } @@ -602,9 +587,7 @@ impl ClientCore { if hand.phase != "player" { return Vec::new(); } - if action == "double" - && !hand.actions.iter().any(|available| available == "double") - { + if action == "double" && !hand.actions.iter().any(|available| available == "double") { return Vec::new(); } self.pending = Some(Pending::BlackjackAction); @@ -914,9 +897,9 @@ impl ClientCore { Some(fingerprint) => { effects.push(Effect::Print(vec![format!("Fingerprint: {fingerprint}")])) } - None => effects.push(Effect::Print(vec![ - "Fingerprint: (not trusted)".to_string(), - ])), + None => effects.push(Effect::Print( + vec!["Fingerprint: (not trusted)".to_string()], + )), } self.pending = Some(Pending::Info); diff --git a/src/client/database.rs b/src/client/database.rs index e1fa42d..e1cedaf 100644 --- a/src/client/database.rs +++ b/src/client/database.rs @@ -110,9 +110,8 @@ pub fn get_all_hosts(conn: &Connection) -> Vec<(String, Option)> { let mut stmt = conn .prepare("SELECT host, fingerprint FROM hosts ORDER BY last_used DESC") .unwrap(); - let rows = stmt.query_map([], |row| { - Ok((row.get(0)?, row.get(1)?)) - }) - .unwrap(); + let rows = stmt + .query_map([], |row| Ok((row.get(0)?, row.get(1)?))) + .unwrap(); rows.filter_map(|r| r.ok()).collect() } diff --git a/src/client/games/blackjack.rs b/src/client/games/blackjack.rs index bad1781..d5f45b3 100644 --- a/src/client/games/blackjack.rs +++ b/src/client/games/blackjack.rs @@ -56,15 +56,14 @@ impl Game for BlackjackGame { .get("status") .map(String::as_str) .unwrap_or("ready"); - let balance = state - .data - .get("balance") - .map(String::as_str) - .unwrap_or("?"); + let balance = state.data.get("balance").map(String::as_str).unwrap_or("?"); let hand = Self::state(state); if let Some(error) = state.data.get("error") { - let bet = hand.as_ref().map(|hand| hand.bet).unwrap_or(state.bet_amount); + let bet = hand + .as_ref() + .map(|hand| hand.bet) + .unwrap_or(state.bet_amount); return format!( "=== BLACKJACK ===\r\nBalance: {balance} PLN Bet: {bet} PLN\r\n\r\n\r\nERROR: {error}\r\n[Q] Quit" ); diff --git a/src/client/games/manager.rs b/src/client/games/manager.rs index 4d9e6a8..b20ff44 100644 --- a/src/client/games/manager.rs +++ b/src/client/games/manager.rs @@ -138,9 +138,7 @@ impl GameManager { session.bet_amount = result.bet_amount; session.data.remove("error"); session.data.insert("reels".to_string(), result.reels); - session - .data - .insert("win_type".to_string(), result.win_type); + session.data.insert("win_type".to_string(), result.win_type); session.data.insert( "win_lines".to_string(), result @@ -339,7 +337,9 @@ impl GameManager { for key in ["crash_point", "payout"] { session.data.remove(key); } - session.data.insert("status".to_string(), state.phase.clone()); + session + .data + .insert("status".to_string(), state.phase.clone()); session .data .insert("session_id".to_string(), state.session_id); diff --git a/src/client/games/response.rs b/src/client/games/response.rs index 71e1fed..88df459 100644 --- a/src/client/games/response.rs +++ b/src/client/games/response.rs @@ -128,8 +128,8 @@ pub fn parse_roulette_response(response: &str) -> Result return Err(format!("Invalid roulette color: {color}")); } let bets = parts[7].to_string(); - let _: crate::roulette::Bets = serde_json::from_str(&bets) - .map_err(|error| format!("Invalid roulette bets: {error}"))?; + let _: crate::roulette::Bets = + serde_json::from_str(&bets).map_err(|error| format!("Invalid roulette bets: {error}"))?; Ok(RouletteResult { session_id: parts[1].to_string(), diff --git a/src/client/games/roulette.rs b/src/client/games/roulette.rs index 3379317..e80eca8 100644 --- a/src/client/games/roulette.rs +++ b/src/client/games/roulette.rs @@ -53,11 +53,7 @@ impl RouletteGame { match state.data.get("status").map(String::as_str) { Some("result") => { - let number = state - .data - .get("number") - .map(String::as_str) - .unwrap_or("?"); + let number = state.data.get("number").map(String::as_str).unwrap_or("?"); let color = state .data .get("color") @@ -102,11 +98,7 @@ impl Game for RouletteGame { fn render(&self, state: &GameState) -> String { let bets = Self::bets(state); let chip = state.data.get("chip").map(String::as_str).unwrap_or("10"); - let balance = state - .data - .get("balance") - .map(String::as_str) - .unwrap_or("?"); + let balance = state.data.get("balance").map(String::as_str).unwrap_or("?"); let input = state .data .get("number_input") diff --git a/src/client/games/slots.rs b/src/client/games/slots.rs index d34bf49..2ec354e 100644 --- a/src/client/games/slots.rs +++ b/src/client/games/slots.rs @@ -109,11 +109,7 @@ impl Game for SlotsGame { fn render(&self, state: &GameState) -> String { let reels = state.data.get("reels").cloned().unwrap_or_default(); - let balance = state - .data - .get("balance") - .map(String::as_str) - .unwrap_or("?"); + let balance = state.data.get("balance").map(String::as_str).unwrap_or("?"); let winning = Self::highlighted_cells(state); let grid = self.render_grid(&reels, &winning); let paytable = paytable_lines(); diff --git a/src/client/ui.rs b/src/client/ui.rs index 0fe78ae..4ab0759 100644 --- a/src/client/ui.rs +++ b/src/client/ui.rs @@ -94,10 +94,7 @@ pub fn command_names() -> Vec<&'static str> { pub fn help_lines() -> Vec { let mut lines = vec!["Available commands:".to_string()]; for command in COMMANDS { - lines.push(format!( - " {:<28} - {}", - command.usage, command.description - )); + lines.push(format!(" {:<28} - {}", command.usage, command.description)); } lines } @@ -291,16 +288,12 @@ pub fn host_lines(hosts: &[(String, Option)]) -> Vec { /// on the current line. `render()` has no trailing newline, so a 7-line board /// needs `MoveUp(6)`. pub fn lines_to_move_up(previous_lines: usize) -> u16 { - previous_lines - .saturating_sub(1) - .min(u16::MAX as usize) as u16 + previous_lines.saturating_sub(1).min(u16::MAX as usize) as u16 } /// Column (0-based) to move to after the given prompt and input text. pub fn input_cursor_column(prompt_len: usize, input_len: usize) -> u16 { - prompt_len - .saturating_add(input_len) - .min(u16::MAX as usize) as u16 + prompt_len.saturating_add(input_len).min(u16::MAX as usize) as u16 } /// Number of terminal rows a block of logical lines occupies after wrapping. diff --git a/src/crash.rs b/src/crash.rs index 55aab19..2936b99 100644 --- a/src/crash.rs +++ b/src/crash.rs @@ -24,9 +24,7 @@ pub fn multiplier_at_secs(seconds: f64) -> f64 { if !seconds.is_finite() || seconds <= 0.0 { return 1.0; } - (GROWTH_RATE * seconds) - .exp() - .clamp(1.0, MAX_MULTIPLIER) + (GROWTH_RATE * seconds).exp().clamp(1.0, MAX_MULTIPLIER) } /// How long a round runs before reaching `multiplier`. diff --git a/src/roulette.rs b/src/roulette.rs index b59f92e..426ecc3 100644 --- a/src/roulette.rs +++ b/src/roulette.rs @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize}; /// European wheel clockwise from zero. pub const WHEEL: [u8; 37] = [ - 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, - 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26, + 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, + 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26, ]; pub const RED_NUMBERS: [u8; 18] = [ @@ -92,8 +92,7 @@ impl Bets { if is_red(number) { winnings = winnings.saturating_add(self.red.saturating_mul(EVEN_MONEY_RETURN)); } else { - winnings = - winnings.saturating_add(self.black.saturating_mul(EVEN_MONEY_RETURN)); + winnings = winnings.saturating_add(self.black.saturating_mul(EVEN_MONEY_RETURN)); } if is_even(number) { winnings = winnings.saturating_add(self.even.saturating_mul(EVEN_MONEY_RETURN)); @@ -104,8 +103,7 @@ impl Bets { for bet in &self.numbers { if bet.number == number { - winnings = winnings - .saturating_add(bet.amount.saturating_mul(STRAIGHT_RETURN)); + winnings = winnings.saturating_add(bet.amount.saturating_mul(STRAIGHT_RETURN)); } } diff --git a/src/server/core.rs b/src/server/core.rs index e0f0ff2..4b68ccb 100644 --- a/src/server/core.rs +++ b/src/server/core.rs @@ -49,11 +49,7 @@ impl ServerCore { Self::with_registry(conn, GameRegistry::with_defaults(), DEFAULT_COST) } - pub fn with_registry( - conn: Connection, - registry: GameRegistry, - bcrypt_cost: u32, - ) -> Self { + pub fn with_registry(conn: Connection, registry: GameRegistry, bcrypt_cost: u32) -> Self { Self { conn, sessions: SessionManager::new(), @@ -115,8 +111,7 @@ impl ServerCore { } "GAME_INFO" => { if parts.len() != 2 { - "ERROR Invalid GAME_INFO format. Usage: GAME_INFO " - .to_string() + "ERROR Invalid GAME_INFO format. Usage: GAME_INFO ".to_string() } else { match self.registry.get_game(parts[1]) { Some(game) => format!( @@ -143,16 +138,14 @@ impl ServerCore { } "CRASH_CASHOUT" => { if parts.len() != 2 { - "ERROR Invalid CRASH_CASHOUT format. Usage: CRASH_CASHOUT " - .to_string() + "ERROR Invalid CRASH_CASHOUT format. Usage: CRASH_CASHOUT ".to_string() } else { self.handle_crash_end(state, parts[1], false) } } "CRASH_FORFEIT" => { if parts.len() != 2 { - "ERROR Invalid CRASH_FORFEIT format. Usage: CRASH_FORFEIT " - .to_string() + "ERROR Invalid CRASH_FORFEIT format. Usage: CRASH_FORFEIT ".to_string() } else { self.handle_crash_end(state, parts[1], true) } @@ -351,12 +344,8 @@ impl ServerCore { if hand.player.len() != 2 { return "ERROR Double is only allowed on the first two cards".to_string(); } - if database::extend_reservation( - &mut self.conn, - session_id, - hand.base_bet as i64, - ) - .is_err() + if database::extend_reservation(&mut self.conn, session_id, hand.base_bet as i64) + .is_err() { return "ERROR Insufficient balance".to_string(); } @@ -515,7 +504,12 @@ impl ServerCore { /// Cash out or forfeit. The multiplier comes from the server clock at the /// moment the request is handled; the client never supplies one. - fn handle_crash_end(&mut self, state: &ConnectionState, session_id: &str, forfeit: bool) -> String { + fn handle_crash_end( + &mut self, + state: &ConnectionState, + session_id: &str, + forfeit: bool, + ) -> String { let Some(user) = state.user.as_deref() else { return "ERROR Not logged in".to_string(); }; @@ -698,11 +692,7 @@ impl ServerCore { .get("number") .cloned() .unwrap_or_default(); - let color = result - .result_data - .get("color") - .cloned() - .unwrap_or_default(); + let color = result.result_data.get("color").cloned().unwrap_or_default(); let bets = result .result_data .get("bets") @@ -712,11 +702,7 @@ impl ServerCore { "ROULETTE_RESULT {session_id} {winnings} {bet_amount} {new_balance} {number} {color} {bets}" ) } else { - let reels = result - .result_data - .get("reels") - .cloned() - .unwrap_or_default(); + let reels = result.result_data.get("reels").cloned().unwrap_or_default(); let win_type = result .result_data .get("win_type") @@ -753,8 +739,7 @@ impl ServerCore { if let Ok(mut hand) = BlackjackHand::from_json(raw) { if !hand.is_done() { hand.forfeit(); - let balance = - database::get_balance(&self.conn, user).unwrap_or(0); + let balance = database::get_balance(&self.conn, user).unwrap_or(0); let final_state = hand.state(&session.session_id, balance); let details = serde_json::to_string(&final_state) .unwrap_or_else(|_| "{}".to_string()); diff --git a/src/server/games/blackjack.rs b/src/server/games/blackjack.rs index df5a6ac..cea817a 100644 --- a/src/server/games/blackjack.rs +++ b/src/server/games/blackjack.rs @@ -1,7 +1,5 @@ use super::traits::{Game, GameError, GamePhase, GameResult, GameState}; -use crate::blackjack::{ - card_value, fresh_shoe, hand_total, is_blackjack, BlackjackState, -}; +use crate::blackjack::{card_value, fresh_shoe, hand_total, is_blackjack, BlackjackState}; use rand::seq::SliceRandom; use rand::thread_rng; use serde::{Deserialize, Serialize}; diff --git a/src/server/games/roulette.rs b/src/server/games/roulette.rs index 7beb8c9..0a58323 100644 --- a/src/server/games/roulette.rs +++ b/src/server/games/roulette.rs @@ -65,17 +65,15 @@ impl Game for RouletteGame { match action { "spin" => { - if state.phase != GamePhase::WaitingToStart - && state.phase != GamePhase::Playing - { + if state.phase != GamePhase::WaitingToStart && state.phase != GamePhase::Playing { return Err(GameError::InvalidAction( "Cannot spin in current phase".to_string(), )); } - let payload = params - .first() - .ok_or(GameError::InvalidAction("Missing roulette bets".to_string()))?; + let payload = params.first().ok_or(GameError::InvalidAction( + "Missing roulette bets".to_string(), + ))?; let bets: Bets = serde_json::from_str(payload) .map_err(|error| GameError::InvalidAction(format!("Invalid bets: {error}")))?; diff --git a/src/server/games/slots.rs b/src/server/games/slots.rs index 298cd4c..caced24 100644 --- a/src/server/games/slots.rs +++ b/src/server/games/slots.rs @@ -175,9 +175,7 @@ impl Game for SlotsGame { match action { "spin" => { - if state.phase != GamePhase::WaitingToStart - && state.phase != GamePhase::Playing - { + if state.phase != GamePhase::WaitingToStart && state.phase != GamePhase::Playing { return Err(GameError::InvalidAction( "Cannot spin in current phase".to_string(), )); diff --git a/src/server/setup.rs b/src/server/setup.rs index 96982c5..023e6ed 100644 --- a/src/server/setup.rs +++ b/src/server/setup.rs @@ -47,19 +47,8 @@ pub fn init_identity(dir: &Path, common_name: &str) -> Result Result