diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-29 23:08:25 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-29 23:08:25 +0100 |
| commit | 80d9aa13251f7f5c3d3eeaa877bc79dac4435341 (patch) | |
| tree | 62e8b341749fa0644b9877ae621583929a9c1a29 /src/client/games/roulette.rs | |
| parent | v3.1.0: warn on shrink, but let a live round finish (diff) | |
| download | zagan-bet-80d9aa13251f7f5c3d3eeaa877bc79dac4435341.tar.gz zagan-bet-80d9aa13251f7f5c3d3eeaa877bc79dac4435341.zip | |
PLN changed to Kromer
Diffstat (limited to 'src/client/games/roulette.rs')
| -rw-r--r-- | src/client/games/roulette.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/client/games/roulette.rs b/src/client/games/roulette.rs index 3cb1c58..96f8791 100644 --- a/src/client/games/roulette.rs +++ b/src/client/games/roulette.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use super::traits::{Game, GameState}; | 1 | use super::traits::{Game, GameState}; |
| 2 | use crate::roulette::{is_even, is_odd, BetTarget, Bets, Outside}; | 2 | use crate::roulette::{BetTarget, Bets, Outside, is_even, is_odd}; |
| 3 | 3 | ||
| 4 | pub const ROULETTE_BOARD_LINES: usize = 12; | 4 | pub const ROULETTE_BOARD_LINES: usize = 12; |
| 5 | 5 | ||
| @@ -96,7 +96,9 @@ impl Cursor { | |||
| 96 | 96 | ||
| 97 | /// Numbers the cursor would cover, for highlighting the felt. | 97 | /// Numbers the cursor would cover, for highlighting the felt. |
| 98 | pub fn numbers(&self) -> Vec<u8> { | 98 | pub fn numbers(&self) -> Vec<u8> { |
| 99 | self.target().map(|target| target.numbers()).unwrap_or_default() | 99 | self.target() |
| 100 | .map(|target| target.numbers()) | ||
| 101 | .unwrap_or_default() | ||
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | pub fn moved(&self, direction: Direction) -> Cursor { | 104 | pub fn moved(&self, direction: Direction) -> Cursor { |
| @@ -130,9 +132,7 @@ impl Cursor { | |||
| 130 | (Cursor::Column(index), Direction::Up) => Cursor::Dozen(index), | 132 | (Cursor::Column(index), Direction::Up) => Cursor::Dozen(index), |
| 131 | (Cursor::Column(index), Direction::Down) => Cursor::Outside(index * 2), | 133 | (Cursor::Column(index), Direction::Down) => Cursor::Outside(index * 2), |
| 132 | 134 | ||
| 133 | (Cursor::Outside(index), Direction::Left) => { | 135 | (Cursor::Outside(index), Direction::Left) => Cursor::Outside(index.saturating_sub(1)), |
| 134 | Cursor::Outside(index.saturating_sub(1)) | ||
| 135 | } | ||
| 136 | (Cursor::Outside(index), Direction::Right) => { | 136 | (Cursor::Outside(index), Direction::Right) => { |
| 137 | Cursor::Outside((index + 1).min(OUTSIDE_ORDER.len() - 1)) | 137 | Cursor::Outside((index + 1).min(OUTSIDE_ORDER.len() - 1)) |
| 138 | } | 138 | } |
| @@ -249,7 +249,11 @@ impl RouletteGame { | |||
| 249 | .iter() | 249 | .iter() |
| 250 | .enumerate() | 250 | .enumerate() |
| 251 | .map(|(index, kind)| { | 251 | .map(|(index, kind)| { |
| 252 | Self::wide_cell(kind.label(), OUTSIDE_WIDTH, cursor == Cursor::Outside(index)) | 252 | Self::wide_cell( |
| 253 | kind.label(), | ||
| 254 | OUTSIDE_WIDTH, | ||
| 255 | cursor == Cursor::Outside(index), | ||
| 256 | ) | ||
| 253 | }) | 257 | }) |
| 254 | .collect() | 258 | .collect() |
| 255 | } | 259 | } |
| @@ -268,7 +272,7 @@ impl RouletteGame { | |||
| 268 | if list.chars().count() > 40 { | 272 | if list.chars().count() > 40 { |
| 269 | list = list.chars().take(39).collect::<String>() + "…"; | 273 | list = list.chars().take(39).collect::<String>() + "…"; |
| 270 | } | 274 | } |
| 271 | format!("Bets: {list} Total: {} PLN", bets.total()) | 275 | format!("Bets: {list} Total: {} Kr", bets.total()) |
| 272 | } | 276 | } |
| 273 | 277 | ||
| 274 | fn status_line(state: &GameState) -> String { | 278 | fn status_line(state: &GameState) -> String { |
| @@ -309,7 +313,7 @@ impl RouletteGame { | |||
| 309 | format!("No win at {number} {color}{parity}") | 313 | format!("No win at {number} {color}{parity}") |
| 310 | } else { | 314 | } else { |
| 311 | let profit = winnings.parse::<u64>().unwrap_or(0).saturating_sub(stake); | 315 | let profit = winnings.parse::<u64>().unwrap_or(0).saturating_sub(stake); |
| 312 | format!("Won {winnings} PLN at {number} {color}{parity} (+{profit})") | 316 | format!("Won {winnings} Kr at {number} {color}{parity} (+{profit})") |
| 313 | } | 317 | } |
| 314 | } | 318 | } |
| 315 | Some("spinning") => "Spinning...".to_string(), | 319 | Some("spinning") => "Spinning...".to_string(), |
| @@ -332,7 +336,7 @@ impl Game for RouletteGame { | |||
| 332 | 336 | ||
| 333 | let lines = [ | 337 | let lines = [ |
| 334 | "=== ROULETTE ===".to_string(), | 338 | "=== ROULETTE ===".to_string(), |
| 335 | format!("Balance: {balance} PLN Chip: {chip} PLN"), | 339 | format!("Balance: {balance} Kr Chip: {chip} Kr"), |
| 336 | Self::zero_cell(cursor), | 340 | Self::zero_cell(cursor), |
| 337 | Self::number_row(0, &covered), | 341 | Self::number_row(0, &covered), |
| 338 | Self::number_row(1, &covered), | 342 | Self::number_row(1, &covered), |
| @@ -342,8 +346,7 @@ impl Game for RouletteGame { | |||
| 342 | Self::outside_row(cursor), | 346 | Self::outside_row(cursor), |
| 343 | Self::bets_line(&bets), | 347 | Self::bets_line(&bets), |
| 344 | Self::status_line(state), | 348 | Self::status_line(state), |
| 345 | "[ARROWS] Move [ENTER] Bet [C]lear [+/-] Chip [SPACE] Spin [Q] Quit" | 349 | "[ARROWS] Move [ENTER] Bet [C]lear [+/-] Chip [SPACE] Spin [Q] Quit".to_string(), |
| 346 | .to_string(), | ||
| 347 | ]; | 350 | ]; |
| 348 | lines.join("\r\n") | 351 | lines.join("\r\n") |
| 349 | } | 352 | } |
