From 7d18a268547734daf19a740b6533e9c1697baf1a Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 28 Oct 2026 23:31:54 +0100 Subject: v1.2.1: track wrapped board lines and split the paytable --- src/client/games/slots.rs | 10 ++++++---- src/client/ui.rs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/client') diff --git a/src/client/games/slots.rs b/src/client/games/slots.rs index 7e59919..a417e7d 100644 --- a/src/client/games/slots.rs +++ b/src/client/games/slots.rs @@ -1,8 +1,8 @@ use super::traits::{Game, GamePhase, GameState}; -use crate::slots::{paytable_line, REELS, ROWS}; +use crate::slots::{paytable_lines, REELS, ROWS}; /// Height of the game board. It must never depend on the spin result. -pub const SLOT_BOARD_LINES: usize = 9; +pub const SLOT_BOARD_LINES: usize = 10; pub struct SlotsGame; @@ -102,15 +102,17 @@ impl Game for SlotsGame { .unwrap_or("?"); let winning = Self::highlighted_cells(state); let grid = self.render_grid(&reels, &winning); + let paytable = paytable_lines(); format!( - "=== SLOTS ===\r\nBet: {} PLN Balance: {} PLN\r\n{}\r\n{}\r\n{}\r\n{}\r\n{}\r\n{}\r\n[+/-] Bet [SPACE] Spin [Q] Quit", + "=== SLOTS ===\r\nBet: {} PLN Balance: {} PLN\r\n{}\r\n{}\r\n{}\r\n{}\r\n{}\r\n{}\r\n{}\r\n[+/-] Bet [SPACE] Spin [Q] Quit", state.bet_amount, balance, grid[0], grid[1], grid[2], - paytable_line(), + paytable[0], + paytable[1], self.render_status(state), self.render_win_lines(state) ) diff --git a/src/client/ui.rs b/src/client/ui.rs index 493f660..11cedc7 100644 --- a/src/client/ui.rs +++ b/src/client/ui.rs @@ -257,6 +257,23 @@ pub fn input_cursor_column(prompt_len: usize, input_len: usize) -> u16 { .min(u16::MAX as usize) as u16 } +/// Number of terminal rows a block of logical lines occupies after wrapping. +/// Empty lines still occupy one row. +pub fn visual_line_count(lines: &[String], width: usize) -> usize { + let width = width.max(1); + lines + .iter() + .map(|line| { + let columns = display_width(line); + if columns == 0 { + 1 + } else { + columns.div_ceil(width) + } + }) + .sum() +} + /// Format a ping round-trip time with one decimal place. pub fn format_pong(elapsed: std::time::Duration) -> String { format!("Pong ({:.1}ms)", elapsed.as_secs_f64() * 1000.0) -- cgit v1.2.3