From bc0de9955c375cf27d52c9934403964205afc182 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:16:15 +0100 Subject: formatting --- src/server/core.rs | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'src/server/core.rs') 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()); -- cgit v1.2.3