I figured it out!!!
I figured out a mathematical formula for determining the number of bonus spells per day a character gets, given their ability modifier and the spell level. Here is the code in C# but the math works anywhere
public static int CalculateBonusSpells ( int mod, int spellLvl )
public static int CalculateBonusSpells ( int mod, int spellLvl )
{
int newMod = mod - ( spellLvl - 1 );
if ( newMod > 0 )
{
int bonus;
if ( newMod % 4 != 0 )
{bonus = newMod / 4 + 1;}
else { bonus = newMod / 4;}
return bonus;
}
else {return 0; }
}
First, the modifier is adjusted by the spell level(-1 to get it right) then if the result of the division of the modifier and 4 returns a remainder, then the bonus is the result of the integer division(which drops remainders) plus 1. If the division is clean then that is the result.
I also found the (immensely simpler) formula for the bonus psionic powers per day given ability modifier and class level:
public static int CalculateBonusPowers ( int mod, int classLvl )
{
return ( mod / 2 ) * classLvl;
}
it is simply the modifier divided by 2 and then that multiplied by the class level.
public static int CalculateBonusSpells ( int mod, int spellLvl )
public static int CalculateBonusSpells ( int mod, int spellLvl )
{
int newMod = mod - ( spellLvl - 1 );
if ( newMod > 0 )
{
int bonus;
if ( newMod % 4 != 0 )
{bonus = newMod / 4 + 1;}
else { bonus = newMod / 4;}
return bonus;
}
else {return 0; }
}
First, the modifier is adjusted by the spell level(-1 to get it right) then if the result of the division of the modifier and 4 returns a remainder, then the bonus is the result of the integer division(which drops remainders) plus 1. If the division is clean then that is the result.
I also found the (immensely simpler) formula for the bonus psionic powers per day given ability modifier and class level:
public static int CalculateBonusPowers ( int mod, int classLvl )
{
return ( mod / 2 ) * classLvl;
}
it is simply the modifier divided by 2 and then that multiplied by the class level.