From e920b20fafe375eec15b24eb8cde4b1455dd01af Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 1 Nov 2026 20:11:41 +0100 Subject: v4.1.1: pointer-first betting and visible payouts in the GUI The felt snaps the hover to the shared fine lattice: inner half of a cell is a straight, an edge a split, a crossing a corner. A translucent chip previews the target and the covered cells tint. Left click adds the selected chip, right or middle click takes one back through the new Bets::reduce; C or CLEAR empties the slip, and SPIN stays disabled with no chips. The result now pays out: the wheel leaves the winning pocket under the pointer, the winning cell and pocket get a gold outline, and the sidebar reports the amount returned and the net for the round (NO WIN on a loss). Placing a chip after a result starts the next round without losing the wheel position. The column row now spans the full width like a real table instead of hugging the left edge. Adds tests for lattice snapping, target naming and taking chips back. --- src/roulette.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/roulette.rs') diff --git a/src/roulette.rs b/src/roulette.rs index 6b73c2a..b697e31 100644 --- a/src/roulette.rs +++ b/src/roulette.rs @@ -226,6 +226,16 @@ impl Bets { } } + /// Take `amount` back from one target, dropping the chip when it empties. + /// + /// This is the felt undo: a right or middle click removes one chip. + pub fn reduce(&mut self, target: &BetTarget, amount: u64) { + if let Some(chip) = self.chips.iter_mut().find(|chip| &chip.target == target) { + chip.amount = chip.amount.saturating_sub(amount); + } + self.chips.retain(|chip| chip.amount > 0); + } + /// Total returned for a winning number, including returned stakes. pub fn winnings(&self, number: u8) -> u64 { self.chips.iter().fold(0u64, |total, chip| { -- cgit v1.2.3