From 1f04837b94524732b5ff12ef848d943dc70b51b4 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 2 May 2021 12:40:33 +0530 Subject: Add autoname feature It sets the player names automatically. --- lib/Antlia/CLI.rakumod | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/Antlia/CLI.rakumod') 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"; -- cgit 1.4.1-2-gfad0