diff options
Diffstat (limited to '')
| -rw-r--r-- | src/client/games/response.rs | 13 |
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 | } |
