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 | |
| 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 'src/client')
| -rw-r--r-- | src/client/core.rs | 22 | ||||
| -rw-r--r-- | src/client/ui.rs | 10 |
2 files changed, 32 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; |
diff --git a/src/client/ui.rs b/src/client/ui.rs index 6161166..ca001c2 100644 --- a/src/client/ui.rs +++ b/src/client/ui.rs | |||
| @@ -261,6 +261,16 @@ pub fn terminal_too_small(columns: u16, rows: u16) -> Option<String> { | |||
| 261 | )) | 261 | )) |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | /// One-line warning for a terminal that shrank while the client is running. | ||
| 265 | pub fn terminal_size_warning(columns: u16, rows: u16) -> Option<String> { | ||
| 266 | if columns >= MIN_COLUMNS && rows >= MIN_ROWS { | ||
| 267 | return None; | ||
| 268 | } | ||
| 269 | Some(format!( | ||
| 270 | "WARNING: terminal is {columns}x{rows}; zagan.bet needs at least {MIN_COLUMNS}x{MIN_ROWS}. Resize to fit." | ||
| 271 | )) | ||
| 272 | } | ||
| 273 | |||
| 264 | /// Render remembered hosts. | 274 | /// Render remembered hosts. |
| 265 | /// | 275 | /// |
| 266 | /// Two addresses that present the same certificate key are the same server, so | 276 | /// Two addresses that present the same certificate key are the same server, so |
