mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 20:51:07 +01:00
Initial
This commit is contained in:
parent
9564edb244
commit
80595f4e79
12 changed files with 182 additions and 25 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
|
||||
import { BonusFields } from '../data/actor/character.mjs';
|
||||
|
||||
export default class DHRoll extends Roll {
|
||||
baseTerms = [];
|
||||
constructor(formula, data = {}, options = {}) {
|
||||
super(formula, data, options);
|
||||
options.bonusEffects = this.bonusEffectBuilder();
|
||||
if (!this.data || !Object.keys(this.data).length) this.data = options.data;
|
||||
}
|
||||
|
||||
|
|
@ -164,12 +166,18 @@ export default class DHRoll extends Roll {
|
|||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||
...this.constructor.parse(modifier.join(' + '), this.options.data)
|
||||
];
|
||||
} else {
|
||||
} else if (Number.isNumeric(modifier)) {
|
||||
const numTerm = modifier < 0 ? '-' : '+';
|
||||
return [
|
||||
new foundry.dice.terms.OperatorTerm({ operator: numTerm }),
|
||||
new foundry.dice.terms.NumericTerm({ number: Math.abs(modifier) })
|
||||
];
|
||||
} else {
|
||||
const numTerm = modifier < 0 ? '-' : '+';
|
||||
return [
|
||||
new foundry.dice.terms.OperatorTerm({ operator: numTerm }),
|
||||
...this.constructor.parse(modifier, this.options.data)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -185,18 +193,22 @@ export default class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
getBonus(path, label) {
|
||||
const bonus = foundry.utils.getProperty(this.data.bonuses, path),
|
||||
modifiers = [];
|
||||
if (bonus?.bonus)
|
||||
modifiers.push({
|
||||
label: label,
|
||||
value: bonus?.bonus
|
||||
});
|
||||
if (bonus?.dice?.length)
|
||||
modifiers.push({
|
||||
label: label,
|
||||
value: bonus?.dice
|
||||
});
|
||||
const modifiers = [];
|
||||
for (const effect of Object.values(this.options.bonusEffects)) {
|
||||
if (effect.selected) {
|
||||
for (const change of effect.changes) {
|
||||
if (change.key.includes(path)) {
|
||||
const changeValue = game.system.api.documents.DhActiveEffect.getChangeValue(
|
||||
this.data,
|
||||
change,
|
||||
effect.origEffect
|
||||
);
|
||||
modifiers.push({ label: label, value: changeValue });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
|
|
@ -235,4 +247,8 @@ export default class DHRoll extends Roll {
|
|||
static temporaryModifierBuilder(config) {
|
||||
return {};
|
||||
}
|
||||
|
||||
bonusEffectBuilder() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue