commit
0e5ba02252
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Choose between the values stored in @choices
|
||||
# Choose between the values matched between 'or' in input
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
|
|
@ -4,6 +4,28 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $choices = 6;
|
||||
my $choice = int(rand($choices)) + 1;
|
||||
print "$choice\n";
|
||||
my $q_check_lc = 'throw 5 dice';
|
||||
my $answer_results = '';
|
||||
my $answer_type = 'dice_side';
|
||||
my $choices = 6; # To be replace with input string in the future
|
||||
|
||||
if ( $q_check_lc =~ m/^throw(?:\sdie|(\d{0,2}\s)*dice)$/ ) {
|
||||
my $rolls = 1; # If "die" is entered
|
||||
|
||||
if (defined($1)) { # Not defined if number of "dice" not specified
|
||||
if ($1 eq " ") {
|
||||
$rolls = 2;
|
||||
|
||||
}
|
||||
else {
|
||||
$rolls = $1;
|
||||
}
|
||||
}
|
||||
|
||||
for (1 .. $rolls) {
|
||||
my $roll = int(rand($choices)) + 1;
|
||||
$answer_results .= " $roll";
|
||||
}
|
||||
|
||||
print qq($answer_type\t$answer_results\n);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue