Skip to content

Commit

Permalink
use casting ability with best modifier if multiple available
Browse files Browse the repository at this point in the history
  • Loading branch information
Muttley committed Nov 2, 2024
1 parent 4aeade9 commit 0f1343d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions system/src/documents/ActorSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,28 @@ export default class ActorSD extends Actor {


async getSpellcastingAbility() {
const characterClass = await this.getClass();
const spellcasterClasses = await this.getSpellcasterClasses();

let chosenAbility = "";
let chosenAbilityModifier = 0;

for (const casterClass of spellcasterClasses) {
const ability = casterClass?.system?.spellcasting?.ability ?? "";

if (chosenAbility === "") {
chosenAbility = ability;
chosenAbilityModifier = this.abilityModifier(ability);
}
else {
const modifier = this.abilityModifier(ability);
if (modifier > chosenAbilityModifier) {
chosenAbility = ability;
chosenAbilityModifier = modifier;
}
}
}

return characterClass?.system?.spellcasting?.ability ?? "";
return chosenAbility;
}

async getTitle() {
Expand Down

0 comments on commit 0f1343d

Please sign in to comment.