Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#5003] Add ability attack, spell attack, & spell ability labels #5004

Open
wants to merge 1 commit into
base: 4.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions module/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3470,9 +3470,9 @@ preLocalize("cover");
* @deprecated since v10
*/
DND5E.trackableAttributes = [
"attributes.ac.value", "attributes.init.bonus", "attributes.movement", "attributes.senses", "attributes.spelldc",
"attributes.spellLevel", "details.cr", "details.spellLevel", "details.xp.value", "skills.*.passive",
"abilities.*.value"
"attributes.ac.value", "attributes.init.bonus", "attributes.movement", "attributes.senses",
"attributes.spell.attack", "attributes.spell.dc", "attributes.spellLevel", "details.cr",
"details.spellLevel", "details.xp.value", "skills.*.passive", "abilities.*.value"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a bit weird that spellLevel is under details for NPCs (and attributes.spellLevel doesn't seem to exist?). Maybe we should move it under attributes.spell.level for consistency.

];

/* -------------------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions module/data/actor/templates/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export default class CommonTemplate extends ActorDataModel.mixin(CurrencyTemplat

abl.save = abl.mod + abl.saveBonus;
if ( Number.isNumeric(abl.saveProf.term) ) abl.save += abl.saveProf.flat;
abl.attack = abl.mod + prof;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is meant only for display purposes, should it not rather be a string? A numeric value won't support proficiency dice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a number on ClassData#spellcasting also, so we should be consistent. And speaking of consistency, we have ClassData#spellcasting#save rather than dc. Not sure which one we should align on, but I think I'd lean towards dc personally.

abl.dc = 8 + abl.mod + prof + dcBonus;

if ( !Number.isFinite(abl.max) ) abl.max = CONFIG.DND5E.maxAbilityScore;
Expand Down
2 changes: 1 addition & 1 deletion module/documents/activity/summon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export default class SummonActivity extends ActivityMixin(SummonActivityData) {

// Match saves
if ( this.match.saves && item.hasSave ) {
let dc = rollData.abilities?.[this.ability]?.dc ?? rollData.attributes.spelldc;
let dc = rollData.abilities?.[this.ability]?.dc ?? rollData.attributes.spell.dc;
if ( this.item.type === "spell" ) {
const ability = this.item.system.availableAbilities?.first();
if ( ability ) dc = rollData.abilities[ability]?.dc ?? dc;
Expand Down
28 changes: 25 additions & 3 deletions module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,31 @@ export default class Actor5e extends SystemDocumentMixin(Actor) {
* Prepare spellcasting DC & modifier.
*/
_prepareSpellcastingAbility() {
const spellcastingAbility = this.system.abilities[this.system.attributes.spellcasting];
this.system.attributes.spelldc = spellcastingAbility ? spellcastingAbility.dc : 8 + this.system.attributes.prof;
this.system.attributes.spellmod = spellcastingAbility ? spellcastingAbility.mod : 0;
const ability = this.system.abilities[this.system.attributes.spellcasting];
this.system.attributes.spell = {
abilityLabel: CONFIG.DND5E.abilities[this.system.attributes.spellcasting]?.label ?? "",
attack: ability ? ability.attack : this.system.attributes.prof,
dc: ability ? ability.dc : 8 + this.system.attributes.prof,
mod: ability ? ability.mod : 0
};
Object.defineProperty(this.system.attributes, "spelldc", {
get() {
foundry.utils.logCompatibilityWarning(
"The `attributes.spelldc` property on actors has been moved to `attributes.spell.dc`.",
{ since: "DnD5e 4.2", until: "DnD5e 5.0" }
);
return this.spell.dc;
}
});
Object.defineProperty(this.system.attributes, "spellmod", {
get() {
foundry.utils.logCompatibilityWarning(
"The `attributes.spellmod` property on actors has been moved to `attributes.spell.mod`.",
{ since: "DnD5e 4.2", until: "DnD5e 5.0" }
);
return this.spell.mod;
}
});
}

/* -------------------------------------------- */
Expand Down
4 changes: 2 additions & 2 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,8 +1549,8 @@ export default class Item5e extends SystemDocumentMixin(Item) {
values.bonus = spellcastingClass.spellcasting.attack;
values.dc = spellcastingClass.spellcasting.save;
} else {
values.bonus = spell.actor.system.attributes?.spellmod;
values.dc = spell.actor.system.attributes?.spelldc;
values.bonus = spell.actor.system.attributes?.spell?.mod;
values.dc = spell.actor.system.attributes?.spell?.dc;
}
}

Expand Down
2 changes: 1 addition & 1 deletion module/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ export function getHumanReadableAttributeLabel(attr, { actor }={}) {
// Derived fields.
if ( attr === "attributes.init.total" ) label = "DND5E.InitiativeBonus";
else if ( (attr === "attributes.ac.value") || (attr === "attributes.ac.flat") ) label = "DND5E.ArmorClass";
else if ( attr === "attributes.spelldc" ) label = "DND5E.SpellDC";
else if ( attr === "attributes.spell.dc" ) label = "DND5E.SpellDC";

// Abilities.
else if ( attr.startsWith("abilities.") ) {
Expand Down
2 changes: 1 addition & 1 deletion templates/actors/character-sheet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<span>{{system.attributes.ac.value}}</span>
</div>
<footer class="attribute-footer">
<span class="spell-dc">{{localize "DND5E.SpellDC"}} {{system.attributes.spelldc}}</span>
<span class="spell-dc">{{localize "DND5E.SpellDC"}} {{system.attributes.spell.dc}}</span>
</footer>
</li>

Expand Down
2 changes: 1 addition & 1 deletion templates/actors/parts/actor-spellbook.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{ selectOptions config.abilities selected=system.attributes.spellcasting labelAttr="label"
blank=(localize "DND5E.None") }}
</select>
<span>{{localize "DND5E.AbbreviationDC"}} {{system.attributes.spelldc}}</span>
<span>{{localize "DND5E.AbbreviationDC"}} {{system.attributes.spell.dc}}</span>
</div>

<ul class="filter-list flexrow" data-filter="spellbook">
Expand Down