Fixed so that advantage dice do not get duplicated (#1929)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run

This commit is contained in:
WBHarry 2026-05-26 00:49:46 +02:00 committed by GitHub
parent 0e8c3dc74a
commit e529dd0f88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 15 deletions

View file

@ -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();
} }

View file

@ -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(