summaryrefslogtreecommitdiffstats
path: root/src/client/games/response.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 23:19:52 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 23:19:52 +0100
commit2915d826f744612e0d975282f5bddf13270b9f3f (patch)
treea2864bfaef91070ac3b4e13b8b731e539a757cc8 /src/client/games/response.rs
parentv1.0.0: replace slots with 5x3 reels and five paylines (diff)
downloadzagan-bet-2915d826f744612e0d975282f5bddf13270b9f3f.tar.gz
zagan-bet-2915d826f744612e0d975282f5bddf13270b9f3f.zip
v1.1.0: highlight winning symbols on the slots board
Diffstat (limited to 'src/client/games/response.rs')
-rw-r--r--src/client/games/response.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/client/games/response.rs b/src/client/games/response.rs
index de22a75..d7f9d45 100644
--- a/src/client/games/response.rs
+++ b/src/client/games/response.rs
@@ -7,6 +7,7 @@ pub struct SpinResult {
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 pub win_lines: Vec<usize>,
10 pub win_cells: Vec<usize>,
10} 11}
11 12
12/// Parse one server reply to `PLAY_START`. 13/// Parse one server reply to `PLAY_START`.
@@ -52,11 +53,11 @@ pub fn parse_spin_response(response: &str) -> Result<SpinResult, String> {
52 53
53 let win_lines = parts 54 let win_lines = parts
54 .get(7) 55 .get(7)
55 .map(|raw| { 56 .map(|raw| parse_indices(raw))
56 raw.split(',') 57 .unwrap_or_default();
57 .filter_map(|value| value.trim().parse::<usize>().ok()) 58 let win_cells = parts
58 .collect() 59 .get(8)
59 }) 60 .map(|raw| parse_indices(raw))
60 .unwrap_or_default(); 61 .unwrap_or_default();
61 62
62 Ok(SpinResult { 63 Ok(SpinResult {
@@ -67,5 +68,12 @@ pub fn parse_spin_response(response: &str) -> Result<SpinResult, String> {
67 reels: parts[5].to_string(), 68 reels: parts[5].to_string(),
68 win_type: parts[6].to_string(), 69 win_type: parts[6].to_string(),
69 win_lines, 70 win_lines,
71 win_cells,
70 }) 72 })
71} 73}
74
75fn parse_indices(raw: &str) -> Vec<usize> {
76 raw.split(',')
77 .filter_map(|value| value.trim().parse::<usize>().ok())
78 .collect()
79}