diff --git a/lib/OSRIC/Character.pm b/lib/OSRIC/Character.pm index b5f8931..e8ccc26 100644 --- a/lib/OSRIC/Character.pm +++ b/lib/OSRIC/Character.pm @@ -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); } } diff --git a/lib/OSRIC/Util.pm b/lib/OSRIC/Util.pm index 1a5c079..633cd93 100644 --- a/lib/OSRIC/Util.pm +++ b/lib/OSRIC/Util.pm @@ -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;