From b07ee31b38648db5f565a3b911d02b4fa06236a9 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Thu, 4 Mar 2021 00:41:57 +0100 Subject: [PATCH] Add maximumCoupResult and minimumFumbleResult to actor data --- src/module/actor/actor-data.ts | 6 ++++++ src/module/actor/actor.ts | 3 +++ src/module/item/item.ts | 10 +++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/module/actor/actor-data.ts b/src/module/actor/actor-data.ts index 9f12ef3e..7fcb8398 100644 --- a/src/module/actor/actor-data.ts +++ b/src/module/actor/actor-data.ts @@ -17,6 +17,7 @@ interface DS4ActorDataDataBase { attributes: DS4ActorDataDataAttributes; traits: DS4ActorDataDataTraits; combatValues: DS4ActorDataDataCombatValues; + rolling: DS4ActorDataDataRolling; } interface DS4ActorDataDataAttributes { @@ -45,6 +46,11 @@ interface DS4ActorDataDataCombatValues { targetedSpellcasting: ModifiableData; } +interface DS4ActorDataDataRolling { + maximumCoupResult?: number; + minimumFumbleResult?: number; +} + interface DS4CharacterDataData extends DS4ActorDataDataBase { baseInfo: DS4CharacterDataDataBaseInfo; progression: DS4CharacterDataDataProgression; diff --git a/src/module/actor/actor.ts b/src/module/actor/actor.ts index 305ca04e..e28effdc 100644 --- a/src/module/actor/actor.ts +++ b/src/module/actor/actor.ts @@ -25,6 +25,9 @@ export class DS4Actor extends Actor { prepareBaseData(): void { const data = this.data; + data.data.rolling.minimumFumbleResult = 20; + data.data.rolling.maximumCoupResult = 1; + const attributes = data.data.attributes; Object.values(attributes).forEach( (attribute: ModifiableData) => (attribute.total = attribute.base + attribute.mod), diff --git a/src/module/item/item.ts b/src/module/item/item.ts index cbea7431..211f7720 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -65,11 +65,15 @@ export class DS4Item extends Item { ); } - const owner = (this.actor as unknown) as DS4Actor; // TODO(types): Improve so that the concrete Actor type is known here + const ownerDataData = ((this.actor as unknown) as DS4Actor).data.data; // TODO(types): Improve so that the concrete Actor type is known here const weaponBonus = this.data.data.weaponBonus; const combatValue = await this.getCombatValueKeyForAttackType(this.data.data.attackType); - const checkTargetValue = (owner.data.data.combatValues[combatValue].total as number) + weaponBonus; - await createCheckRoll(checkTargetValue, { rollMode: game.settings.get("core", "rollMode") }); // TODO: Get maxCritSuccess and minCritFailure from Actor once we store them there + const checkTargetValue = (ownerDataData.combatValues[combatValue].total as number) + weaponBonus; + await createCheckRoll(checkTargetValue, { + rollMode: game.settings.get("core", "rollMode"), + maxCritSuccess: ownerDataData.rolling.maximumCoupResult, + minCritFailure: ownerDataData.rolling.minimumFumbleResult, + }); } private async getCombatValueKeyForAttackType(attackType: AttackType): Promise<"meleeAttack" | "rangedAttack"> {