diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 23:06:22 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 23:06:22 +0100 |
| commit | 810e212b4b255914cfa73e85b52ec23db281c0e3 (patch) | |
| tree | 01e8035ce2945112af5ef41ef8959890bb0ef722 /src/client/core.rs | |
| parent | v3.0.0: cursor-driven roulette felt with splits and corners; drop schema migr... (diff) | |
| download | zagan-bet-810e212b4b255914cfa73e85b52ec23db281c0e3.tar.gz zagan-bet-810e212b4b255914cfa73e85b52ec23db281c0e3.zip | |
v3.1.0: warn on shrink, but let a live round finish
Diffstat (limited to '')
| -rw-r--r-- | src/client/core.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/client/core.rs b/src/client/core.rs index 8411d47..95fa050 100644 --- a/src/client/core.rs +++ b/src/client/core.rs | |||
| @@ -138,6 +138,28 @@ impl ClientCore { | |||
| 138 | self.game.is_in_game() | 138 | self.game.is_in_game() |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | /// True while a round is running and leaving would forfeit a reserved bet. | ||
| 142 | /// The terminal may shrink during one of these without interrupting it. | ||
| 143 | pub fn is_live_game(&self) -> bool { | ||
| 144 | match self | ||
| 145 | .game | ||
| 146 | .get_current_state() | ||
| 147 | .map(|state| state.game_type.as_str()) | ||
| 148 | { | ||
| 149 | Some("blackjack") => self | ||
| 150 | .game | ||
| 151 | .blackjack_state() | ||
| 152 | .is_some_and(|hand| hand.phase == "player"), | ||
| 153 | Some("crash") => self.crash_started.is_some(), | ||
| 154 | _ => false, | ||
| 155 | } | ||
| 156 | } | ||
| 157 | |||
| 158 | /// Redraw the current board, for terminal resizes. | ||
| 159 | pub fn refresh_board(&self) -> Vec<Effect> { | ||
| 160 | self.board_effects() | ||
| 161 | } | ||
| 162 | |||
| 141 | pub fn prompt_effect(&self) -> Option<Effect> { | 163 | pub fn prompt_effect(&self) -> Option<Effect> { |
| 142 | if self.is_in_game() { | 164 | if self.is_in_game() { |
| 143 | return None; | 165 | return None; |
