We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8fb82a3 commit 35ebab6Copy full SHA for 35ebab6
games/yahtzee.p6
@@ -1,15 +1,18 @@
1
#!/usr/bin/env perl6
2
3
+use v6;
4
+
5
sub roll-dice { map { (1..6).pick }, 1..$^rolls };
6
7
sub round {
8
my @roll = roll-dice(5);
9
my $rolls = 1;
10
repeat {
11
say "Dice: { @roll }";
- print q{Which dice do you want to roll again (1-5)? };
- my @dice = split(/\s+/, =$*IN);
12
- if "{@dice}" eq "" { $rolls = 3 } # XXX: why doesn't ! @dice.elems work?
+ my @dice = prompt("Which dice do you want to roll again (1-5)? ").split(/\s+/);
13
+ if @dice[0] eq "" {
14
+ $rolls = 3;
15
+ }
16
else {
17
@roll[map { $^index - 1 }, @dice] = roll-dice(@dice.elems);
18
$rolls++;
@@ -22,4 +25,5 @@ sub round {
22
25
}
23
26
24
27
my @round = round;
-# vim: ft=perl6
28
29
+# vim: expandtab shiftwidth=4 ft=perl6
0 commit comments