Skip to content

Commit 35ebab6

Browse files
committed
Replace print/$*IN with prompt in yahtzee.p6
Now this example works again with current Rakudo
1 parent 8fb82a3 commit 35ebab6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

games/yahtzee.p6

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#!/usr/bin/env perl6
22

3+
use v6;
4+
35
sub roll-dice { map { (1..6).pick }, 1..$^rolls };
46

57
sub round {
68
my @roll = roll-dice(5);
79
my $rolls = 1;
810
repeat {
911
say "Dice: { @roll }";
10-
print q{Which dice do you want to roll again (1-5)? };
11-
my @dice = split(/\s+/, =$*IN);
12-
if "{@dice}" eq "" { $rolls = 3 } # XXX: why doesn't ! @dice.elems work?
12+
my @dice = prompt("Which dice do you want to roll again (1-5)? ").split(/\s+/);
13+
if @dice[0] eq "" {
14+
$rolls = 3;
15+
}
1316
else {
1417
@roll[map { $^index - 1 }, @dice] = roll-dice(@dice.elems);
1518
$rolls++;
@@ -22,4 +25,5 @@ sub round {
2225
}
2326

2427
my @round = round;
25-
# vim: ft=perl6
28+
29+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)