diff options
author | Andinus <andinus@nand.sh> | 2021-05-02 12:40:33 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-05-02 12:41:12 +0530 |
commit | 1f04837b94524732b5ff12ef848d943dc70b51b4 (patch) | |
tree | 78c615e8b2b6f19bad8f0f47a1ea98b9a5cf7ea0 /lib/Antlia/CLI.rakumod | |
parent | 9eb09662194df91a9c4adc3d017dfe6ce175382a (diff) | |
download | antlia-1f04837b94524732b5ff12ef848d943dc70b51b4.tar.gz |
Add autoname feature
It sets the player names automatically.
Diffstat (limited to 'lib/Antlia/CLI.rakumod')
-rw-r--r-- | lib/Antlia/CLI.rakumod | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Antlia/CLI.rakumod b/lib/Antlia/CLI.rakumod index 8261e57..4ea62d3 100644 --- a/lib/Antlia/CLI.rakumod +++ b/lib/Antlia/CLI.rakumod @@ -22,14 +22,18 @@ signal(SIGINT).tap({$end-loop = True;}); #| text based Rock paper scissors game multi sub MAIN( + Bool :$autoname, #= Autoname the players Int :$players where * >= 2 = 2, #= Number of players (default: 2) ) is export { say "Antlia - text based Rock paper scissors game"; say "--------------------------------------------\n"; my Player @players; - for 1 .. $players { - push @players, Player.new(name => prompt("[Player $_] Name: ").trim); + if $autoname { + push @players, Player.new(name => "Player $_") for 1 .. $players; + } else { + push @players, Player.new(name => prompt("[Player $_] Name: ").trim) + for 1 .. $players; } print "\n"; |