Skip to content

Commit 31d0cdf

Browse files
committed
Allow "spellcasting" as ability option in check/save enrichers
Adaptation of Zhell's PR in light of the new `spellcastingAbility` property on actors and support for `spellcasting` as an ability option in rolling methods. Original PR: #4883
1 parent 32b290e commit 31d0cdf

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

module/config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4850,6 +4850,8 @@ Object.defineProperty(DND5E, "enrichmentLookup", {
48504850
addFullKeys("skills");
48514851
addFullKeys("spellSchools");
48524852
Object.entries(DND5E.vehicleTypes).forEach(([k, label]) => _enrichmentLookup.tools[k] = { label });
4853+
4854+
_enrichmentLookup.abilities.spellcasting = { label: _loc("DND5E.Spellcasting") };
48534855
}
48544856
return _enrichmentLookup;
48554857
},

module/enrichers.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ function createSaveRequestButtons(dataset) {
763763
async function rollCheckSave(config, event) {
764764
const { type, ability, skill, tool, dc } = config;
765765
const options = { event };
766-
if ( ability in CONFIG.DND5E.abilities ) options.ability = ability;
766+
if ( (ability in CONFIG.DND5E.abilities) || (ability === "spellcasting") ) options.ability = ability;
767767
if ( dc ) options.target = Number(dc);
768768

769769
const actors = getSceneTargets().map(t => t.actor);
@@ -1444,8 +1444,8 @@ function createPassiveTag(label, dataset) {
14441444
* @returns {string}
14451445
*/
14461446
export function createRollLabel(config) {
1447-
const { label: ability, abbreviation } = CONFIG.DND5E.abilities[config.ability] ?? {};
1448-
const skill = CONFIG.DND5E.skills[config.skill]?.label;
1447+
const { label: ability, abbreviation } = CONFIG.DND5E.enrichmentLookup.abilities[config.ability] ?? {};
1448+
const skill = CONFIG.DND5E.enrichmentLookup.skills[config.skill]?.label;
14491449
const toolUUID = CONFIG.DND5E.enrichmentLookup.tools[config.tool];
14501450
const tool = toolUUID?.id ? Trait.getBaseItem(toolUUID.id, { indexOnly: true })?.name : toolUUID?.label ?? null;
14511451
const longSuffix = config.format === "long" ? "Long" : "Short";

module/tooltips.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,19 @@ export default class Tooltips5e {
152152
const abilityConfig = CONFIG.DND5E.abilities[ability ?? skillConfig.ability];
153153

154154
let label;
155+
const isSpellcasting = ability === "spellcasting";
156+
const abilityLabel = isSpellcasting ? _loc("DND5E.Spellcasting") : abilityConfig.label;
155157
if ( skillConfig ) {
156-
label = _loc("DND5E.SkillPassiveSpecificHint", { skill: skillConfig.label, ability: abilityConfig.label });
158+
label = _loc("DND5E.SkillPassiveSpecificHint", { skill: skillConfig.label, ability: abilityLabel });
157159
} else {
158160
// If no skill was provided, we're doing a passive ability check.
159161
// This isn't technically a thing in the rules, but we can support it anyway if people want to use it.
160-
label = _loc("DND5E.SkillPassiveHint", { skill: abilityConfig.label });
162+
label = _loc("DND5E.SkillPassiveHint", { skill: abilityLabel });
161163
}
162164

163165
this._onHoverPassive({ label }, actor => {
164166
const systemData = actor.system;
167+
if ( isSpellcasting ) ability = actor.spellcastingAbility;
165168
let passive;
166169
if ( skill && (!ability || (ability === skillConfig.ability)) ) {
167170
// Default passive skill check

0 commit comments

Comments
 (0)