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"> {