summaryrefslogtreecommitdiffstats
path: root/src/bin/server
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-24 18:16:28 +0200
committersalmonik <salmonik@tuta.io>2026-08-24 18:16:28 +0200
commitd4e2a5283f5c596c153318f6275bde59ac422922 (patch)
treeb51337b09a6b4650f9d13ae130e01cfe7e1657c6 /src/bin/server
parentFix second-game InvalidAction: reset phase after spin, allow re-spin in Finis... (diff)
downloadzagan-bet-d4e2a5283f5c596c153318f6275bde59ac422922.tar.gz
zagan-bet-d4e2a5283f5c596c153318f6275bde59ac422922.zip
Fix balance: only credit winnings, not refund the bet on every spin
Diffstat (limited to '')
-rw-r--r--src/bin/server/handler.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bin/server/handler.rs b/src/bin/server/handler.rs
index 5406e85..0a4934f 100644
--- a/src/bin/server/handler.rs
+++ b/src/bin/server/handler.rs
@@ -185,7 +185,7 @@ fn handle_play_start(user: &str, game_type: &str, bet_amount_str: &str) -> Strin
185 let session_id = SESSIONS.create_session(user, game_type.to_string(), new_state.clone()); 185 let session_id = SESSIONS.create_session(user, game_type.to_string(), new_state.clone());
186 186
187 // All balance mutations in a single transaction. 187 // All balance mutations in a single transaction.
188 let total_return = bet_amount + result.winnings as i64; 188 let total_return = result.winnings as i64;
189 let tx_result = db.execute_batch(&format!( 189 let tx_result = db.execute_batch(&format!(
190 "UPDATE users SET balance = balance - {bet_amount} WHERE username = '{user}'; 190 "UPDATE users SET balance = balance - {bet_amount} WHERE username = '{user}';
191 UPDATE users SET balance = balance + {total_return} WHERE username = '{user}';" 191 UPDATE users SET balance = balance + {total_return} WHERE username = '{user}';"