OSRIC::Util::d exports correctly

This commit is contained in:
Alex Kerr 2015-01-22 14:16:32 +00:00
parent 30c4f4929d
commit 8f59c28565
2 changed files with 12 additions and 3 deletions

View File

@ -72,7 +72,7 @@ sub generate_stats
# * Class specific boosts.
# * Perhaps an alternate system where players can choose what number
# to allocate to what stat.
$self->{stats}->{$stat} = (d(6) + d(6) + d(6));
$self->{stats}->{$stat} = d(6, 3);
}
}

View File

@ -1,10 +1,19 @@
package OSRIC::Util;
use Exporter qw/import/;
our @EXPORT = qw/d/;
# Rolls a dice of the specified number:
sub d
{
my $n = shift;
return int(rand($n));
# The range of the dice:
my $range = shift;
# Optional: The number of dice thrown.
my $n = shift // 1;
my $i = 0;
$i += int(rand($range));
return $i;
}
1;