feat: display opponent defense in attack/spell rolls and make it adjustable via effects
This makes it so that the Talents “Verletzen” and “Verheerer” can sort of be automated. Compendium packs have been updated accordingly.
This commit is contained in:
parent
e55da9a0e6
commit
1e094691ff
20 changed files with 2801 additions and 1670 deletions
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { createCheckRoll } from "../../../dice/check-factory";
|
||||
import { createCheckRoll, DS4CheckFactoryOptions } from "../../../dice/check-factory";
|
||||
import { notifications } from "../../../ui/notifications";
|
||||
import { getGame } from "../../../utils/utils";
|
||||
import { DS4Item } from "../item";
|
||||
|
@ -12,6 +12,9 @@ export class DS4Spell extends DS4Item {
|
|||
override prepareDerivedData(): void {
|
||||
this.data.data.rollable = this.data.data.equipped;
|
||||
this.data.data.price = calculateSpellPrice(this.data.data);
|
||||
if (this.data.data.allowsDefense) {
|
||||
this.data.data.opponentDefense = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override async roll(options: { speaker?: { token?: TokenDocument; alias?: string } } = {}): Promise<void> {
|
||||
|
@ -42,17 +45,29 @@ export class DS4Spell extends DS4Item {
|
|||
);
|
||||
}
|
||||
const spellType = this.data.data.spellType;
|
||||
const opponentDefense = this.data.data.opponentDefense;
|
||||
const checkTargetNumber =
|
||||
ownerDataData.combatValues[spellType].total +
|
||||
(hasComplexModifier ? 0 : this.data.data.spellModifier.numerical);
|
||||
|
||||
const speaker = ChatMessage.getSpeaker({ actor: this.actor, ...options.speaker });
|
||||
const flavor =
|
||||
opponentDefense !== undefined && opponentDefense !== 0
|
||||
? "DS4.ItemSpellCheckFlavorWithOpponentDefense"
|
||||
: "DS4.ItemSpellCheckFlavor";
|
||||
const flavorData: DS4CheckFactoryOptions["flavorData"] = {
|
||||
actor: speaker.alias ?? this.actor.name,
|
||||
spell: this.name,
|
||||
};
|
||||
if (opponentDefense !== undefined && opponentDefense !== 0) {
|
||||
flavorData.opponentDefense = (opponentDefense < 0 ? "" : "+") + opponentDefense;
|
||||
}
|
||||
|
||||
await createCheckRoll(checkTargetNumber, {
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
maximumCoupResult: ownerDataData.rolling.maximumCoupResult,
|
||||
minimumFumbleResult: ownerDataData.rolling.minimumFumbleResult,
|
||||
flavor: "DS4.ItemSpellCheckFlavor",
|
||||
flavorData: { actor: speaker.alias ?? this.actor.name, spell: this.name },
|
||||
flavor: flavor,
|
||||
flavorData: flavorData,
|
||||
speaker,
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue