summaryrefslogtreecommitdiffstats
path: root/gui/tests/layout.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-01 21:09:56 +0100
committersalmonik <salmonik@tuta.io>2026-11-01 21:09:56 +0100
commitbf4cf78ab26896faf457273e37d30fc96381c4a4 (patch)
tree71d67c300b6be191016a988ed5338e15c8b1bdd3 /gui/tests/layout.rs
parentv4.1.1: pointer-first betting and visible payouts in the GUI (diff)
downloadzagan-bet-bf4cf78ab26896faf457273e37d30fc96381c4a4.tar.gz
zagan-bet-bf4cf78ab26896faf457273e37d30fc96381c4a4.zip
v4.2.0: wire the GUI to the core, transport and all four games
Phase 4. The egui frontend now shares ClientCore and the client database with the terminal: one background worker owns TLS, trust answers go through a channel, and a 10 s request deadline mirrors the terminal socket timeout. First contact, a changed key and a version mismatch are explicit screens; login can remember the credential and auto-login signs in before the login form appears. Adds the lobby with an update notice, a full-width scrollable history table, and the four games painted from View: slots with reel animation and win lines that stop at the last matching reel, roulette with the hover lattice and wheel spin, blackjack with vector-drawn suits, and a smooth crash curve. Sidebars pin their action block; leaving a live hand or round asks before forfeiting. The header balance holds the staked amount while the reels or wheel turn and only shows the payout when they stop. Refused spins cancel the animation. Live crash multipliers keep full precision for the chart; the terminal still displays two decimals. Verified live against a 4.2.0 server: register, login, auto-login, trust, all four games settling, history (50 rows), logout, disconnect, forfeit confirmation, and the version-mismatch screen. Release: 8.3 MB Linux, 6.8 MB Windows, 61 ms to window, 131 MB idle RSS.
Diffstat (limited to 'gui/tests/layout.rs')
-rw-r--r--gui/tests/layout.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/gui/tests/layout.rs b/gui/tests/layout.rs
index ab5a62e..5678665 100644
--- a/gui/tests/layout.rs
+++ b/gui/tests/layout.rs
@@ -5,8 +5,10 @@
5use std::f32::consts::TAU; 5use std::f32::consts::TAU;
6 6
7use eframe::egui::{Pos2, Rect, pos2, vec2}; 7use eframe::egui::{Pos2, Rect, pos2, vec2};
8use zagan_bet::client::view::{SlotsPhase, SlotsView};
8use zagan_bet::roulette::{BetTarget, Outside}; 9use zagan_bet::roulette::{BetTarget, Outside};
9use zagan_bet_gui::roulette::{Felt, number_under, size_for, target_name}; 10use zagan_bet_gui::roulette::{Felt, number_under, size_for, target_name};
11use zagan_bet_gui::slots::winning_columns;
10use zagan_bet_gui::theme::{group_digits, money}; 12use zagan_bet_gui::theme::{group_digits, money};
11 13
12#[test] 14#[test]
@@ -154,3 +156,36 @@ fn targets_read_as_bet_slips() {
154 "Black" 156 "Black"
155 ); 157 );
156} 158}
159
160fn slots_view(win_cells: Vec<usize>, win_lines: Vec<usize>) -> SlotsView {
161 SlotsView {
162 bet: 10,
163 balance: Some(1000),
164 reels: "OOOOODDDDDOOOOOD".chars().collect(),
165 win_cells,
166 win_lines,
167 win_type: "win".to_string(),
168 winnings: Some(30),
169 phase: SlotsPhase::Result,
170 error: None,
171 }
172}
173
174#[test]
175fn a_payline_stops_at_the_last_matching_reel() {
176 // Middle line (line 2), four Os from reel 0: cells 1, 4, 7, 10.
177 let view = slots_view(vec![1, 4, 7, 10], vec![2]);
178 assert_eq!(winning_columns(&view, 2), vec![0, 1, 2, 3]);
179
180 // Three of a kind stops after reel 2.
181 let view = slots_view(vec![1, 4, 7], vec![2]);
182 assert_eq!(winning_columns(&view, 2), vec![0, 1, 2]);
183
184 // Cells on another line do not extend this one.
185 let view = slots_view(vec![0, 1, 4, 7], vec![2]);
186 assert_eq!(winning_columns(&view, 2), vec![0, 1, 2]);
187
188 // A line number that does not exist draws nothing.
189 let view = slots_view(vec![1, 4, 7], vec![9]);
190 assert!(winning_columns(&view, 9).is_empty());
191}