From 4b8db3661bf9bac752f099f99577dd836c53fd0d Mon Sep 17 00:00:00 2001 From: Andinus Date: Tue, 27 Apr 2021 21:49:33 +0530 Subject: Fix betting, winning logic - The bet amount can be equal to the wallet. - Winning logic was flawed. --- lib/Caelum/CLI.rakumod | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Caelum/CLI.rakumod b/lib/Caelum/CLI.rakumod index a7b1e4f..ab2b6e9 100644 --- a/lib/Caelum/CLI.rakumod +++ b/lib/Caelum/CLI.rakumod @@ -36,7 +36,7 @@ multi sub MAIN( # Reset points. $player.points = 0; - unless $player.wallet > $bet { + unless $player.wallet >= $bet { say "==> Cannot place bet. All amount goes to pot."; $pot += $player.wallet; $player.wallet = 0; @@ -81,7 +81,7 @@ multi sub MAIN( } } - with @players.sort(*.wallet)[0] -> $player { + with @players.sort(*.wallet).reverse[0] -> $player { say "{$player.name} wins $pot!"; $player.wallet += $pot; } -- cgit 1.4.1-2-gfad0