feat: update for v10

This commit is contained in:
Johannes Loher 2022-11-21 03:00:46 +01:00
parent 6277e27056
commit f25b46a226
63 changed files with 41349 additions and 24332 deletions

View file

@ -11,10 +11,10 @@ import { calculateSpellPrice } from "./calculate-spell-price";
export class DS4Spell extends DS4Item {
/** @override */
prepareDerivedData() {
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;
this.system.rollable = this.system.equipped;
this.system.price = calculateSpellPrice(this.system);
if (this.system.allowsDefense) {
this.system.opponentDefense = 0;
}
}
@ -22,12 +22,12 @@ export class DS4Spell extends DS4Item {
async roll(options = {}) {
const game = getGame();
if (!this.data.data.equipped) {
if (!this.system.equipped) {
return notifications.warn(
game.i18n.format("DS4.WarningItemMustBeEquippedToBeRolled", {
name: this.name,
id: this.id,
type: this.data.type,
type: this.type,
}),
);
}
@ -36,21 +36,21 @@ export class DS4Spell extends DS4Item {
throw new Error(game.i18n.format("DS4.ErrorCannotRollUnownedItem", { name: this.name, id: this.id }));
}
const ownerDataData = this.actor.data.data;
const hasComplexModifier = this.data.data.spellModifier.complex !== "";
const ownerSystemData = this.actor.system;
const hasComplexModifier = this.system.spellModifier.complex !== "";
if (hasComplexModifier === undefined) {
notifications.info(
game.i18n.format("DS4.InfoManuallyEnterSpellModifier", {
name: this.name,
spellModifier: this.data.data.spellModifier.complex,
spellModifier: this.system.spellModifier.complex,
}),
);
}
const spellType = this.data.data.spellType;
const opponentDefense = this.data.data.opponentDefense;
const spellType = this.system.spellType;
const opponentDefense = this.system.opponentDefense;
const checkTargetNumber =
ownerDataData.combatValues[spellType].total +
(hasComplexModifier ? 0 : this.data.data.spellModifier.numerical);
ownerSystemData.combatValues[spellType].total +
(hasComplexModifier ? 0 : this.system.spellModifier.numerical);
const speaker = ChatMessage.getSpeaker({ actor: this.actor, ...options.speaker });
const flavor =
opponentDefense !== undefined && opponentDefense !== 0
@ -67,8 +67,8 @@ export class DS4Spell extends DS4Item {
await createCheckRoll(checkTargetNumber, {
rollMode: game.settings.get("core", "rollMode"),
maximumCoupResult: ownerDataData.rolling.maximumCoupResult,
minimumFumbleResult: ownerDataData.rolling.minimumFumbleResult,
maximumCoupResult: ownerSystemData.rolling.maximumCoupResult,
minimumFumbleResult: ownerSystemData.rolling.minimumFumbleResult,
flavor: flavor,
flavorData: flavorData,
speaker,