summaryrefslogtreecommitdiffstats
path: root/src/client/games/response.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 23:13:24 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 23:13:24 +0100
commitfc59ef77cda14d97d854dfcaa848307cfa512b69 (patch)
treeb0fc97390b96078e0a0538e76d7c76f7c04135f1 /src/client/games/response.rs
parentv0.4.0: add first-time TLS setup and server help (diff)
downloadzagan-bet-fc59ef77cda14d97d854dfcaa848307cfa512b69.tar.gz
zagan-bet-fc59ef77cda14d97d854dfcaa848307cfa512b69.zip
v1.0.0: replace slots with 5x3 reels and five paylines
Diffstat (limited to 'src/client/games/response.rs')
-rw-r--r--src/client/games/response.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client/games/response.rs b/src/client/games/response.rs
index 6948805..de22a75 100644
--- a/src/client/games/response.rs
+++ b/src/client/games/response.rs
@@ -6,6 +6,7 @@ pub struct SpinResult {
6 pub balance: i64, 6 pub balance: i64,
7 pub reels: String, 7 pub reels: String,
8 pub win_type: String, 8 pub win_type: String,
9 pub win_lines: Vec<usize>,
9} 10}
10 11
11/// Parse one server reply to `PLAY_START`. 12/// Parse one server reply to `PLAY_START`.
@@ -45,10 +46,19 @@ pub fn parse_spin_response(response: &str) -> Result<SpinResult, String> {
45 .parse::<i64>() 46 .parse::<i64>()
46 .map_err(|_| format!("Invalid balance from server: {}", parts[4]))?; 47 .map_err(|_| format!("Invalid balance from server: {}", parts[4]))?;
47 48
48 if parts[5].chars().count() != 3 { 49 if parts[5].chars().count() != 3 && parts[5].chars().count() != 15 {
49 return Err(format!("Invalid reels from server: {}", parts[5])); 50 return Err(format!("Invalid reels from server: {}", parts[5]));
50 } 51 }
51 52
53 let win_lines = parts
54 .get(7)
55 .map(|raw| {
56 raw.split(',')
57 .filter_map(|value| value.trim().parse::<usize>().ok())
58 .collect()
59 })
60 .unwrap_or_default();
61
52 Ok(SpinResult { 62 Ok(SpinResult {
53 session_id: parts[1].to_string(), 63 session_id: parts[1].to_string(),
54 winnings, 64 winnings,
@@ -56,5 +66,6 @@ pub fn parse_spin_response(response: &str) -> Result<SpinResult, String> {
56 balance, 66 balance,
57 reels: parts[5].to_string(), 67 reels: parts[5].to_string(),
58 win_type: parts[6].to_string(), 68 win_type: parts[6].to_string(),
69 win_lines,
59 }) 70 })
60} 71}