From cb5ad74a71f2b1dc7b5dad16f0d74da32cb93105 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 22 Mar 2021 10:28:37 +0100 Subject: [PATCH] Remove some unnecessary casts and fallbacks --- src/module/actor/actor.ts | 20 +++++++++----------- src/module/item/item.ts | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index bccfe3c..a851544 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -75,7 +75,7 @@ export class DS4Actor extends Actor return changes.concat( e.data.changes.filter(predicate).flatMap((c) => { - const duplicatedChange = duplicate(c) as ActiveEffect.Change; + const duplicatedChange = duplicate(c); duplicatedChange.priority = duplicatedChange.priority ?? duplicatedChange.mode * 10; return Array(factor).fill({ ...duplicatedChange, @@ -172,19 +172,17 @@ export class DS4Actor extends Actor const data = this.data.data; const armorValueOfEquippedItems = this._calculateArmorValueOfEquippedItems(); - data.combatValues.hitPoints.base = - (data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + 10; + data.combatValues.hitPoints.base = data.attributes.body.total + data.traits.constitution.total + 10; data.combatValues.defense.base = - (data.attributes.body.total ?? 0) + (data.traits.constitution.total ?? 0) + armorValueOfEquippedItems; - data.combatValues.initiative.base = (data.attributes.mobility.total ?? 0) + (data.traits.agility.total ?? 0); - data.combatValues.movement.base = (data.attributes.mobility.total ?? 0) / 2 + 1; - data.combatValues.meleeAttack.base = (data.attributes.body.total ?? 0) + (data.traits.strength.total ?? 0); - data.combatValues.rangedAttack.base = - (data.attributes.mobility.total ?? 0) + (data.traits.dexterity.total ?? 0); + data.attributes.body.total + data.traits.constitution.total + armorValueOfEquippedItems; + data.combatValues.initiative.base = data.attributes.mobility.total + data.traits.agility.total; + data.combatValues.movement.base = data.attributes.mobility.total / 2 + 1; + data.combatValues.meleeAttack.base = data.attributes.body.total + data.traits.strength.total; + data.combatValues.rangedAttack.base = data.attributes.mobility.total + data.traits.dexterity.total; data.combatValues.spellcasting.base = - (data.attributes.mind.total ?? 0) + (data.traits.aura.total ?? 0) - armorValueOfEquippedItems; + data.attributes.mind.total + data.traits.aura.total - armorValueOfEquippedItems; data.combatValues.targetedSpellcasting.base = - (data.attributes.mind.total ?? 0) + (data.traits.dexterity.total ?? 0) - armorValueOfEquippedItems; + data.attributes.mind.total + data.traits.dexterity.total - armorValueOfEquippedItems; Object.values(data.combatValues).forEach( (combatValue: ModifiableDataBaseTotal) => (combatValue.total = combatValue.base + combatValue.mod), diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 1c93e68..68a1ffb 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -94,7 +94,7 @@ export class DS4Item extends Item { const ownerDataData = actor.data.data; const weaponBonus = this.data.data.weaponBonus; const combatValue = await this.getCombatValueKeyForAttackType(this.data.data.attackType); - const checkTargetNumber = (ownerDataData.combatValues[combatValue].total as number) + weaponBonus; + const checkTargetNumber = ownerDataData.combatValues[combatValue].total + weaponBonus; await createCheckRoll(checkTargetNumber, { rollMode: game.settings.get("core", "rollMode") as Const.DiceRollMode, // TODO(types): Type this setting in upstream @@ -138,7 +138,7 @@ export class DS4Item extends Item { ); } const spellType = this.data.data.spellType; - const checkTargetNumber = (ownerDataData.combatValues[spellType].total as number) + (spellBonus ?? 0); + const checkTargetNumber = ownerDataData.combatValues[spellType].total + (spellBonus ?? 0); await createCheckRoll(checkTargetNumber, { rollMode: game.settings.get("core", "rollMode") as Const.DiceRollMode, // TODO(types): Type this setting in upstream