mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
.
This commit is contained in:
parent
f5a4d8cf94
commit
5d6fac39fe
2 changed files with 16 additions and 4 deletions
|
|
@ -471,6 +471,12 @@ export default class DhCharacter extends BaseDataActor {
|
|||
};
|
||||
}
|
||||
|
||||
get basicAttackDamageDice() {
|
||||
const diceTypes = Object.keys(CONFIG.DH.GENERAL.diceTypes);
|
||||
const attackDiceIndex = Math.max(Math.min(this.rules.attack.damage.diceIndex, 5), 0);
|
||||
return diceTypes[attackDiceIndex];
|
||||
}
|
||||
|
||||
static async unequipBeforeEquip(itemToEquip) {
|
||||
const primary = this.primaryWeapon,
|
||||
secondary = this.secondaryWeapon;
|
||||
|
|
@ -557,15 +563,15 @@ export default class DhCharacter extends BaseDataActor {
|
|||
this.resources.hope.value = Math.min(baseHope, this.resources.hope.max);
|
||||
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
||||
|
||||
const diceTypes = Object.keys(CONFIG.DH.GENERAL.diceTypes);
|
||||
const attackDiceIndex = Math.max(Math.min(this.rules.attack.damage.diceIndex, 5), 0);
|
||||
this.attack.damage.parts[0].value.custom.formula = `@prof${diceTypes[attackDiceIndex]}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
|
||||
this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`;
|
||||
}
|
||||
|
||||
getRollData() {
|
||||
const data = super.getRollData();
|
||||
|
||||
return {
|
||||
...data,
|
||||
basicAttackDamageDice: this.basicAttackDamageDice,
|
||||
tier: this.tier,
|
||||
level: this.levelData.level.current
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,13 @@ export default class FormulaField extends foundry.data.fields.StringField {
|
|||
|
||||
/** @inheritDoc */
|
||||
_validateType(value) {
|
||||
const roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, '1'));
|
||||
/* A bit suss, but seems to work */
|
||||
let roll = null;
|
||||
try {
|
||||
roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, '1'));
|
||||
} catch (_) {
|
||||
roll = new Roll(value.replace(/@([a-z.0-9_-]+)/gi, 'd6'));
|
||||
}
|
||||
roll.evaluateSync({ strict: false });
|
||||
if (this.options.deterministic && !roll.isDeterministic)
|
||||
throw new Error(`must not contain dice terms: ${value}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue