2015-01-07 11:13:22 -05:00
|
|
|
package OSRIC::Util;
|
2015-01-22 09:16:32 -05:00
|
|
|
use Exporter qw/import/;
|
2015-02-10 11:07:42 -05:00
|
|
|
our @EXPORT = qw/d con_mod/;
|
2015-01-07 11:13:22 -05:00
|
|
|
|
|
|
|
# Rolls a dice of the specified number:
|
|
|
|
sub d
|
|
|
|
{
|
2015-01-22 09:16:32 -05:00
|
|
|
# The range of the dice:
|
|
|
|
my $range = shift;
|
|
|
|
|
|
|
|
# Optional: The number of dice thrown.
|
|
|
|
my $n = shift // 1;
|
|
|
|
|
|
|
|
my $i = 0;
|
2015-01-27 06:27:19 -05:00
|
|
|
$i += (int(rand($range)) + 1) for(1..$n);
|
2015-01-22 09:16:32 -05:00
|
|
|
return $i;
|
2015-01-07 11:13:22 -05:00
|
|
|
}
|
|
|
|
|
2015-02-10 11:07:42 -05:00
|
|
|
# Returns the constitution hp modifier (at level 1):
|
|
|
|
sub con_mod
|
|
|
|
{
|
|
|
|
my $con = shift;
|
|
|
|
my $class = shift;
|
|
|
|
|
|
|
|
# Get the constitution modifier:
|
|
|
|
my $mod;
|
|
|
|
if($con <= 3)
|
|
|
|
{
|
|
|
|
$mod = -2;
|
|
|
|
}
|
|
|
|
elsif(($con > 3) && ($con <= 6))
|
|
|
|
{
|
|
|
|
$mod = -1;
|
|
|
|
}
|
|
|
|
elsif(($con > 6) && ($con <= 14))
|
|
|
|
{
|
|
|
|
$mod = 0;
|
|
|
|
}
|
|
|
|
elsif(($con > 14) && ($con <= 15))
|
|
|
|
{
|
|
|
|
$mod = 1;
|
|
|
|
}
|
|
|
|
elsif(($con > 15) && ($con <= 16))
|
|
|
|
{
|
|
|
|
$mod = 2;
|
|
|
|
}
|
|
|
|
elsif(($con > 16) && ($con <= 17))
|
|
|
|
{
|
|
|
|
if(($class eq "Fighter") || ($class eq "Paladin")
|
|
|
|
|| ($class eq "Ranger"))
|
|
|
|
{
|
|
|
|
$mod = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mod = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif(($con > 17) && ($con <= 18))
|
|
|
|
{
|
|
|
|
if(($class eq "Fighter") || ($class eq "Paladin")
|
|
|
|
|| ($class eq "Ranger"))
|
|
|
|
{
|
|
|
|
$mod = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mod = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif(($con > 18) && ($con <= 19))
|
|
|
|
{
|
|
|
|
if(($class eq "Fighter") || ($class eq "Paladin")
|
|
|
|
|| ($class eq "Ranger"))
|
|
|
|
{
|
|
|
|
$mod = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$mod = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $mod;
|
|
|
|
}
|
|
|
|
|
2015-01-07 11:13:22 -05:00
|
|
|
1;
|