Created
November 18, 2023 17:26
-
-
Save Kadajett/4f3614f48f6c8fc78eaa45f630ad4215 to your computer and use it in GitHub Desktop.
Calculate Bonus Spells Pathfinder 1e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calculateAbilityModifier(abilityScore: number): number { | |
return Math.floor((abilityScore - 10) / 2); | |
} | |
function generateBonusSpellTable(abilityScore: number): { | |
[level: number]: number; | |
} { | |
const modifier = calculateAbilityModifier(abilityScore); | |
let bonusSpells: { [level: number]: number } = {}; | |
for (let spellLevel = 1; spellLevel <= 9; spellLevel++) { | |
if (modifier >= spellLevel) { | |
// Calculate bonus spells for this level | |
bonusSpells[spellLevel] = Math.floor((modifier - spellLevel) / 4) + 1; | |
} else { | |
bonusSpells[spellLevel] = 0; | |
} | |
} | |
return bonusSpells; | |
} | |
// Example usage | |
const abilityScore = 44; | |
const bonusSpells = generateBonusSpellTable(abilityScore); | |
console.log(`Bonus spells for ability score ${abilityScore}:`, bonusSpells); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment