diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index fbb3d545..1bdf17d5 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -12,7 +12,7 @@ export default class DualityRoll extends D20Roll { constructor(formula, data = {}, options = {}) { super(formula, data, options); this.rallyChoices = this.setRallyChoices(); - this.guaranteedCritical = this.setGuaranteedCritical(); + this.guaranteedCritical = options.guaranteedCritical; } static messageType = 'dualityRoll'; @@ -26,33 +26,23 @@ export default class DualityRoll extends D20Roll { } get dHope() { - console.log("dHope", this.dice, this.terms); - // if ( !(this.terms[0] instanceof foundry.dice.terms.Die) ) return; if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice(); return this.dice[0]; - // return this.#hopeDice; } set dHope(faces) { - console.log("set dHope", this.dice, this.terms); if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice(); this.dice[0].faces = this.getFaces(faces); - // this.#hopeDice = `d${face}`; } get dFear() { - console.log("dFear", this.dice, this.terms); - // if ( !(this.terms[1] instanceof foundry.dice.terms.Die) ) return; if (!(this.dice[1] instanceof foundry.dice.terms.Die)) this.createBaseDice(); return this.dice[1]; - // return this.#fearDice; } set dFear(faces) { - console.log("set dFear", this.dice, this.terms); if (!(this.dice[1] instanceof foundry.dice.terms.Die)) this.createBaseDice(); this.dice[1].faces = this.getFaces(faces); - // this.#fearDice = `d${face}`; } get dAdvantage() { @@ -75,14 +65,6 @@ export default class DualityRoll extends D20Roll { this._advantageNumber = Number(value); } - setGuaranteedCritical() { - return this.data?.parent?.appliedEffects.reduce((a, c) => { - const change = c.changes.find(ch => ch.key === 'system.rules.roll.guaranteedCritical'); - if (change) a = true; - return a; - }, false); - } - setRallyChoices() { return this.data?.parent?.appliedEffects.reduce((a, c) => { const change = c.changes.find(ch => ch.key === 'system.bonuses.rally'); @@ -135,21 +117,19 @@ export default class DualityRoll extends D20Roll { /** @inheritDoc */ static fromData(data) { console.log("fromData", data); + console.log("fromData, options, roll", data?.options?.roll); + console.log("fromData, options, roll, fear", data?.options?.roll?.fear); + console.log("fromData, options, roll, hope", data?.options?.roll?.hope); + console.log("fromData, terms", data.terms); + if (data.options.guaranteedCritical) { + + } data.terms[0].class = foundry.dice.terms.Die.name; data.terms[2].class = foundry.dice.terms.Die.name; return super.fromData(data); } createBaseDice() { - if (this.guaranteedCritical) { - console.log("gc - createBaseDice"); - this.terms[0] = new foundry.dice.terms.Die({ faces: 1, number: 1 }); - this.terms[1] = new foundry.dice.terms.OperatorTerm({ operator: '+' }); - this.terms[2] = new foundry.dice.terms.Die({ faces: 1, number: 1 }); - this.terms = [this.terms[0], this.terms[1], this.terms[2]]; - return; - } - if (this.dice[0] instanceof foundry.dice.terms.Die && this.dice[1] instanceof foundry.dice.terms.Die) { this.terms = [this.terms[0], this.terms[1], this.terms[2]]; return; @@ -159,13 +139,6 @@ export default class DualityRoll extends D20Roll { this.terms[2] = new foundry.dice.terms.Die({ faces: 12 }); } - configureModifiers() { - console.log("this.guaranteedCritical", this.guaranteedCritical); - if (!this.guaranteedCritical) { - super.configureModifiers(); - } - } - applyAdvantage() { if (this.hasAdvantage || this.hasDisadvantage) { const dieFaces = this.advantageFaces, @@ -204,6 +177,23 @@ export default class DualityRoll extends D20Roll { return modifiers; } + static async buildConfigure(config = {}, message = {}) { + console.log("buildConfigure, config", config); + config.dialog ??= {}; + config.guaranteedCritical = config.data?.parent?.appliedEffects.reduce((a, c) => { + const change = c.changes.find(ch => ch.key === 'system.rules.roll.guaranteedCritical'); + if (change) a = true; + return a; + }, false); + + if (config.guaranteedCritical) { + config.dialog.configure = false; + } + + return super.buildConfigure(config, message); + } + + static async buildEvaluate(roll, config = {}, message = {}) { await super.buildEvaluate(roll, config, message);