Add maximumCoupResult and minimumFumbleResult to actor data

This commit is contained in:
Johannes Loher 2021-03-04 00:41:57 +01:00
parent 87205f6193
commit b07ee31b38
3 changed files with 16 additions and 3 deletions

View file

@ -17,6 +17,7 @@ interface DS4ActorDataDataBase {
attributes: DS4ActorDataDataAttributes; attributes: DS4ActorDataDataAttributes;
traits: DS4ActorDataDataTraits; traits: DS4ActorDataDataTraits;
combatValues: DS4ActorDataDataCombatValues; combatValues: DS4ActorDataDataCombatValues;
rolling: DS4ActorDataDataRolling;
} }
interface DS4ActorDataDataAttributes { interface DS4ActorDataDataAttributes {
@ -45,6 +46,11 @@ interface DS4ActorDataDataCombatValues {
targetedSpellcasting: ModifiableData<number>; targetedSpellcasting: ModifiableData<number>;
} }
interface DS4ActorDataDataRolling {
maximumCoupResult?: number;
minimumFumbleResult?: number;
}
interface DS4CharacterDataData extends DS4ActorDataDataBase { interface DS4CharacterDataData extends DS4ActorDataDataBase {
baseInfo: DS4CharacterDataDataBaseInfo; baseInfo: DS4CharacterDataDataBaseInfo;
progression: DS4CharacterDataDataProgression; progression: DS4CharacterDataDataProgression;

View file

@ -25,6 +25,9 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
prepareBaseData(): void { prepareBaseData(): void {
const data = this.data; const data = this.data;
data.data.rolling.minimumFumbleResult = 20;
data.data.rolling.maximumCoupResult = 1;
const attributes = data.data.attributes; const attributes = data.data.attributes;
Object.values(attributes).forEach( Object.values(attributes).forEach(
(attribute: ModifiableData<number>) => (attribute.total = attribute.base + attribute.mod), (attribute: ModifiableData<number>) => (attribute.total = attribute.base + attribute.mod),

View file

@ -65,11 +65,15 @@ export class DS4Item extends Item<DS4ItemData> {
); );
} }
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 weaponBonus = this.data.data.weaponBonus;
const combatValue = await this.getCombatValueKeyForAttackType(this.data.data.attackType); const combatValue = await this.getCombatValueKeyForAttackType(this.data.data.attackType);
const checkTargetValue = (owner.data.data.combatValues[combatValue].total as number) + weaponBonus; const checkTargetValue = (ownerDataData.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 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"> { private async getCombatValueKeyForAttackType(attackType: AttackType): Promise<"meleeAttack" | "rangedAttack"> {