diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-24 18:11:08 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-24 18:11:08 +0200 |
| commit | fd8ba0d9c7317f24e0b655c6b15ca197d5a23daa (patch) | |
| tree | d9090d75d559c7f69a62958184db0692e50e9376 /src/bin/client/games/manager.rs | |
| parent | Fix critical game bugs: payout, sessions, balance type, render_lines; add AGE... (diff) | |
| download | zagan-bet-fd8ba0d9c7317f24e0b655c6b15ca197d5a23daa.tar.gz zagan-bet-fd8ba0d9c7317f24e0b655c6b15ca197d5a23daa.zip | |
Fix second-game InvalidAction: reset phase after spin, allow re-spin in Finished state
Diffstat (limited to '')
| -rw-r--r-- | src/bin/client/games/manager.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/bin/client/games/manager.rs b/src/bin/client/games/manager.rs index 6959214..0b5b4cb 100644 --- a/src/bin/client/games/manager.rs +++ b/src/bin/client/games/manager.rs | |||
| @@ -55,7 +55,7 @@ impl GameManager { | |||
| 55 | ) -> Result<(), GameError> { | 55 | ) -> Result<(), GameError> { |
| 56 | let game_type = self | 56 | let game_type = self |
| 57 | .pending_game_type | 57 | .pending_game_type |
| 58 | .take() | 58 | .as_ref() |
| 59 | .ok_or(GameError::InvalidAction)?; | 59 | .ok_or(GameError::InvalidAction)?; |
| 60 | 60 | ||
| 61 | let state = self | 61 | let state = self |
| @@ -63,7 +63,7 @@ impl GameManager { | |||
| 63 | .as_mut() | 63 | .as_mut() |
| 64 | .ok_or(GameError::InvalidAction)?; | 64 | .ok_or(GameError::InvalidAction)?; |
| 65 | 65 | ||
| 66 | if state.phase != GamePhase::WaitingToStart { | 66 | if state.phase != GamePhase::WaitingToStart && state.phase != GamePhase::Finished { |
| 67 | return Err(GameError::InvalidAction); | 67 | return Err(GameError::InvalidAction); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -103,6 +103,13 @@ impl GameManager { | |||
| 103 | .unwrap_or(false) | 103 | .unwrap_or(false) |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | pub fn reset_phase_to_waiting(&mut self) { | ||
| 107 | if let Some(ref mut session) = self.current_session { | ||
| 108 | session.phase = GamePhase::WaitingToStart; | ||
| 109 | session.data.clear(); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 106 | pub fn end_game(&mut self) { | 113 | pub fn end_game(&mut self) { |
| 107 | self.current_session = None; | 114 | self.current_session = None; |
| 108 | self.pending_game_type = None; | 115 | self.pending_game_type = None; |
