mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-05 20:34:15 +02:00
Fixed so that advantage dice do not get duplicated (#1929)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
This commit is contained in:
parent
0e8c3dc74a
commit
e529dd0f88
2 changed files with 23 additions and 15 deletions
|
|
@ -175,14 +175,14 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
this.disadvantage = advantage === -1;
|
this.disadvantage = advantage === -1;
|
||||||
|
|
||||||
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
|
this.config.roll.advantage = this.config.roll.advantage === advantage ? 0 : advantage;
|
||||||
|
if (this.config.roll.advantage === 0) return this.render();
|
||||||
|
|
||||||
if (this.config.roll.advantage === 1 && this.config.data.rules.roll.defaultAdvantageDice) {
|
const defaultFaces =
|
||||||
const faces = Number.parseInt(this.config.data.rules.roll.defaultAdvantageDice);
|
this.config.roll.advantage === 1
|
||||||
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
|
? this.config.data.rules.roll.defaultAdvantageDice
|
||||||
} else if (this.config.roll.advantage === -1 && this.config.data.rules.roll.defaultDisadvantageDice) {
|
: this.config.data.rules.roll.defaultDisadvantageDice;
|
||||||
const faces = Number.parseInt(this.config.data.rules.roll.defaultDisadvantageDice);
|
const faces = Number.parseInt(defaultFaces);
|
||||||
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
|
this.roll.advantageFaces = Number.isNaN(faces) ? this.roll.advantageFaces : faces;
|
||||||
}
|
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,14 +148,22 @@ export default class DualityRoll extends D20Roll {
|
||||||
}
|
}
|
||||||
|
|
||||||
applyAdvantage() {
|
applyAdvantage() {
|
||||||
if (this.hasAdvantage || this.hasDisadvantage) {
|
const advDieClass = this.hasAdvantage
|
||||||
const dieFaces = this.advantageFaces,
|
? game.system.api.dice.diceTypes.AdvantageDie
|
||||||
advDie = new foundry.dice.terms.Die({ faces: dieFaces, number: this.advantageNumber });
|
: this.hasDisadvantage
|
||||||
if (this.advantageNumber > 1) advDie.modifiers = ['kh'];
|
? game.system.api.dice.diceTypes.DisadvantageDie
|
||||||
this.terms.push(
|
: null;
|
||||||
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
|
if (advDieClass) {
|
||||||
advDie
|
const advDie = new advDieClass({ faces: this.advantageFaces, number: this.advantageNumber });
|
||||||
);
|
if (this.terms.length < 4) {
|
||||||
|
if (this.advantageNumber > 1) advDie.modifiers = ['kh'];
|
||||||
|
this.terms.push(
|
||||||
|
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
|
||||||
|
advDie
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.terms[4] = advDie;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this.rallyFaces)
|
if (this.rallyFaces)
|
||||||
this.terms.push(
|
this.terms.push(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue