summaryrefslogtreecommitdiffstats
path: root/src/roulette.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/roulette.rs10
1 files changed, 10 insertions, 0 deletions
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 {
226 } 226 }
227 } 227 }
228 228
229 /// Take `amount` back from one target, dropping the chip when it empties.
230 ///
231 /// This is the felt undo: a right or middle click removes one chip.
232 pub fn reduce(&mut self, target: &BetTarget, amount: u64) {
233 if let Some(chip) = self.chips.iter_mut().find(|chip| &chip.target == target) {
234 chip.amount = chip.amount.saturating_sub(amount);
235 }
236 self.chips.retain(|chip| chip.amount > 0);
237 }
238
229 /// Total returned for a winning number, including returned stakes. 239 /// Total returned for a winning number, including returned stakes.
230 pub fn winnings(&self, number: u8) -> u64 { 240 pub fn winnings(&self, number: u8) -> u64 {
231 self.chips.iter().fold(0u64, |total, chip| { 241 self.chips.iter().fold(0u64, |total, chip| {