From 49df948de25d28601469e9ca993f33530989ebd0 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 29 Oct 2026 22:55:49 +0100 Subject: v3.0.0: cursor-driven roulette felt with splits and corners; drop schema migrations; require 80x24 --- tests/client_core.rs | 86 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 34 deletions(-) (limited to 'tests/client_core.rs') diff --git a/tests/client_core.rs b/tests/client_core.rs index 176791e..dea6808 100644 --- a/tests/client_core.rs +++ b/tests/client_core.rs @@ -591,26 +591,34 @@ fn rejects_a_grid_with_the_wrong_size() { } #[test] -fn roulette_split_bets_spin_and_show_the_result() { +fn roulette_cursor_places_bets_and_spins() { let mut h = Harness::new(); h.enter_roulette(); - assert_eq!(h.board().len(), 8); + assert_eq!(h.board().len(), 12); assert_eq!(h.board()[0], "=== ROULETTE ==="); assert!(h.board()[1].contains("Balance: 1000 PLN")); assert!(h.board()[1].contains("Chip: 10 PLN")); - assert!(h.board()[2].contains("Bets: (none)")); + assert!(h.board()[9].contains("Bets: (none)")); + // The cursor starts on number 1, the bottom-left corner. + assert!(h.board()[5].contains("[ 1 ]")); + + // Up twice: straight 2, then the split between 2 and 3. + h.key(Key::Up); + h.key(Key::Up); + assert!(h.board()[4].contains("[ 2 ]")); + assert!(h.board()[3].contains("[ 3 ]")); - h.key(Key::Char('r')); - h.key(Key::Char('e')); - h.key(Key::Char('1')); - h.key(Key::Char('7')); h.key(Key::Enter); + assert!(h.board()[9].contains("2/3 10")); + assert!(h.board()[9].contains("Total: 10 PLN")); - assert!(h.board()[2].contains("RED 10")); - assert!(h.board()[2].contains("EVEN 10")); - assert!(h.board()[2].contains("#17 10")); - assert!(h.board()[2].contains("Total: 30 PLN")); + // Back down to number 1 and place a straight. + h.key(Key::Down); + h.key(Key::Down); + h.key(Key::Enter); + assert!(h.board()[9].contains("1 10")); + assert!(h.board()[9].contains("Total: 20 PLN")); h.key(Key::Char(' ')); let request = h @@ -620,18 +628,41 @@ fn roulette_split_bets_spin_and_show_the_result() { .expect("roulette request"); assert_eq!( request, - "PLAY_START roulette 30 {\"red\":10,\"black\":0,\"even\":10,\"odd\":0,\"numbers\":[{\"number\":17,\"amount\":10}]}" + "PLAY_START roulette 20 {\"chips\":[{\"target\":{\"bet\":\"split\",\"a\":2,\"b\":3},\"amount\":10},{\"target\":{\"bet\":\"straight\",\"number\":1},\"amount\":10}]}" ); - let bets = r#"{"red":10,"black":0,"even":10,"odd":0,"numbers":[{"number":17,"amount":10}]}"#; + let bets = r#"{"chips":[{"target":{"bet":"split","a":2,"b":3},"amount":10},{"target":{"bet":"straight","number":1},"amount":10}]}"#; h.reply(&format!( - "ROULETTE_RESULT session-1 360 30 1330 17 black {bets}" + "ROULETTE_RESULT session-1 180 20 1160 3 red {bets}" )); - assert_eq!(h.board().len(), 8); - assert!(h.board()[1].contains("Balance: 1330 PLN")); - assert!(h.board()[4].contains("Winning: 17 BLACK ODD")); - assert!(h.board()[5].contains("Won 360 PLN")); + assert_eq!(h.board().len(), 12); + assert!(h.board()[1].contains("Balance: 1160 PLN")); + assert!(h.board()[10].contains("Won 180 PLN at 3 RED ODD")); + assert!(h.board()[10].contains("+160")); +} + +#[test] +fn roulette_cursor_reaches_the_outside_rows() { + let mut h = Harness::new(); + h.enter_roulette(); + + h.key(Key::Down); + assert!(h.board()[6].starts_with("[") && h.board()[6].contains("1st 12")); + h.key(Key::Down); + assert!(h.board()[7].starts_with("[") && h.board()[7].contains("2:1")); + h.key(Key::Down); + assert!(h.board()[8].starts_with("[") && h.board()[8].contains("1-18")); + + h.key(Key::Enter); + assert!(h.board()[9].contains("1-18 10")); + + // Back up to the felt: the bottom edge of the first dozen is the 1/4 split. + h.key(Key::Up); + h.key(Key::Up); + h.key(Key::Up); + assert!(h.board()[5].contains("[ 1 ]")); + assert!(h.board()[5].contains("[ 4 ]")); } #[test] @@ -640,7 +671,7 @@ fn roulette_rejects_an_empty_spin_and_accepts_the_equals_chip_key() { h.enter_roulette(); h.key(Key::Char(' ')); - assert!(h.board()[4].contains("ERROR: Place at least one bet")); + assert!(h.board()[10].contains("ERROR: Place at least one bet")); assert!(!h .sent .iter() @@ -648,22 +679,9 @@ fn roulette_rejects_an_empty_spin_and_accepts_the_equals_chip_key() { h.key(Key::Char('=')); assert!(h.board()[1].contains("Chip: 20 PLN")); - h.key(Key::Char('r')); - assert!(h.board()[2].contains("RED 20")); - assert!(h.board()[2].contains("Total: 20 PLN")); -} - -#[test] -fn roulette_rejects_an_out_of_range_number() { - let mut h = Harness::new(); - h.enter_roulette(); - - h.key(Key::Char('9')); - h.key(Key::Char('9')); h.key(Key::Enter); - - assert!(h.board()[4].contains("ERROR: Number must be 0-36")); - assert!(h.board()[2].contains("Bets: (none)")); + assert!(h.board()[9].contains("1 20")); + assert!(h.board()[9].contains("Total: 20 PLN")); } fn bj_state( -- cgit v1.2.3