aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-05-02 15:13:24 +0530
committerAndinus <andinus@nand.sh>2021-05-02 15:13:24 +0530
commitac56b702b22c3116e3638b5358dcf513986d6736 (patch)
tree743776d5a8a7e92d4b134e60482b7d9c15962203
parent77c11d9115e6a3384a6570e39aa27073df03f5b8 (diff)
downloadantlia-ac56b702b22c3116e3638b5358dcf513986d6736.tar.gz
Add rounds option
User can limit the number of rounds.
-rw-r--r--lib/Antlia/CLI.rakumod5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Antlia/CLI.rakumod b/lib/Antlia/CLI.rakumod
index 14dc8ca..3313a4c 100644
--- a/lib/Antlia/CLI.rakumod
+++ b/lib/Antlia/CLI.rakumod
@@ -20,6 +20,7 @@ class Player is export {
#| text based Rock paper scissors game
multi sub MAIN(
Bool :$autoname, #= Autoname the players
+ Int :$rounds, #= Number of rounds (default: Inf)
Int :$players where * >= 2 = 2, #= Number of players (default: 2)
) is export {
say "Antlia - text based Rock paper scissors game";
@@ -31,8 +32,8 @@ multi sub MAIN(
} else {
push @players, Player.new(name => prompt("[Player $_] Name: ").trim)
for 1 .. $players;
+ print "\n";
}
- print "\n";
my %score-against = (
rock => "scissor",
@@ -61,7 +62,9 @@ multi sub MAIN(
say "[Round {++$round}]";
say ss-box(col => $columns, :20cw, @players.map(*.throw-art));
+
last if $end-loop;
+ last if ($round == * with $rounds);
}
with @players.sort(*.score).reverse -> @players-sorted {