diff --git a/system/scripts/dice/dietype/l5r-base-die.js b/system/scripts/dice/dietype/l5r-base-die.js index 0056538..2cc7e98 100644 --- a/system/scripts/dice/dietype/l5r-base-die.js +++ b/system/scripts/dice/dietype/l5r-base-die.js @@ -12,7 +12,6 @@ export class L5rBaseDie extends DiceTerm { constructor(termData) { super(termData); this.l5r5e = { success: 0, explosive: 0, opportunity: 0, strife: 0 }; - console.log("L5rBaseDie.constructor", termData, this); // TODO tmp } /** @@ -31,6 +30,15 @@ export class L5rBaseDie extends DiceTerm { return `${result}`; } + /** + * Return the total result of the DiceTerm if it has been evaluated + * Always zero for L5R dices to not count in total for regular dices + * @override + */ + get total() { + return 0; + } + /** * Evaluate the roll term, populating the results Array * @override @@ -61,8 +69,6 @@ export class L5rBaseDie extends DiceTerm { this._evaluated = true; this.result = 0; - console.log("L5rBaseDie.evaluate.out", this); // TODO tmp - return this; } @@ -75,8 +81,6 @@ export class L5rBaseDie extends DiceTerm { //roll.l5r5e = this.l5r5e; - console.log("L5rBaseDie.roll", roll); // TODO tmp - return roll; } @@ -86,7 +90,6 @@ export class L5rBaseDie extends DiceTerm { roll.l5r5e = data.l5r5e; - console.log("L5rBaseDie.fromData", roll); // TODO tmp return roll; } @@ -99,7 +102,6 @@ export class L5rBaseDie extends DiceTerm { json.l5r5e = this.l5r5e; - console.log("L5rBaseDie.toJSON", json); // TODO tmp return json; } } diff --git a/system/scripts/dice/roll.js b/system/scripts/dice/roll.js index dcf0338..6857154 100644 --- a/system/scripts/dice/roll.js +++ b/system/scripts/dice/roll.js @@ -47,20 +47,16 @@ export class RollL5r5e extends Roll { throw new Error("This Roll object has already been rolled."); } - // console.log('RollL5r5e.evaluate.in', this); return; // TODO tmp + console.log("RollL5r5e.evaluate.in", this); // TODO tmp - // Split L5R dices / regulars + // Split L5R dices / regulars for non inners let l5rDices = this.terms.filter((term) => term instanceof L5rBaseDie); this.terms = this.terms.filter((t) => !(t instanceof L5rBaseDie)); this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms)); - // Roll regular dices + // Roll regular dices / inner dices this._total = 0; if (this.terms.length > 0) { - this.l5r5e.dicesTypes.std = true; - - console.log("this.terms", this.terms); - // clean terms (trim symbols) this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms)); @@ -68,10 +64,19 @@ export class RollL5r5e extends Roll { super.evaluate({ minimize, maximize }); } - // Roll L5R dices - if (l5rDices.length > 0) { - this.l5r5e.dicesTypes.l5r = true; + // Check inner L5R rolls + this._dice.forEach((term) => { + if (term instanceof L5rBaseDie) { + // Add results to total + ["success", "explosive", "opportunity", "strife"].forEach((props) => { + this.l5r5e.summary[props] += parseInt(term.l5r5e[props]); + }); + this.l5r5e.summary.success_total += parseInt(term.l5r5e.success); + } + }); + // Roll non inner L5R dices + if (l5rDices.length > 0) { l5rDices.forEach((term) => { // Roll term.evaluate({ minimize, maximize }); @@ -80,8 +85,9 @@ export class RollL5r5e extends Roll { ["success", "explosive", "opportunity", "strife"].forEach((props) => { this.l5r5e.summary[props] += parseInt(term.l5r5e[props]); }); - this.l5r5e.summary.success_total += parseInt(term.l5r5e.success) + parseInt(term.l5r5e.explosive); + this.l5r5e.summary.success_total += parseInt(term.l5r5e.success); + // re-inject L5R dices this.terms.push("+"); this.terms.push(term); }); @@ -92,14 +98,12 @@ export class RollL5r5e extends Roll { } // TODO Others advantage/disadvantage - - // re-inject L5R dices - // this.terms = this.terms.concat(l5rTerms); } // Store final outputs - //this._total = total; this._rolled = true; + this.l5r5e.dicesTypes.std = this.dice.some((term) => term instanceof DiceTerm && !(term instanceof L5rBaseDie)); + this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof L5rBaseDie); console.log("RollL5r5e.evaluate.out", this); // TODO tmp @@ -111,8 +115,6 @@ export class RollL5r5e extends Roll { * @override */ getTooltip() { - console.log("RollL5r5e.getTooltip", this); // TODO tmp - const parts = this.dice .filter((t) => !(t instanceof L5rBaseDie)) .map((d) => { @@ -150,8 +152,6 @@ export class RollL5r5e extends Roll { * @override */ async render(chatOptions = {}) { - console.log("RollL5r5e.render", chatOptions, this); // TODO tmp - chatOptions = mergeObject( { user: game.user._id, @@ -195,8 +195,6 @@ export class RollL5r5e extends Roll { }, }; - console.log("RollL5r5e.render", chatOptions, chatData, this); // TODO tmp - // Render the roll display template return renderTemplate(chatOptions.template, chatData); } @@ -249,8 +247,6 @@ export class RollL5r5e extends Roll { roll.data = data.data; roll.l5r5e = data.l5r5e; - console.log("RollL5r5e.fromData", roll); // TODO tmp - return roll; } diff --git a/system/styles/l5r5e.css b/system/styles/l5r5e.css index c8bd4b5..f9bf63d 100644 --- a/system/styles/l5r5e.css +++ b/system/styles/l5r5e.css @@ -1 +1 @@ -.testing{width:14.28571%}.testing{width:28.57143%}.testing{width:14.28571%}.testing{width:28.57143%}.testing{width:14.28571%}.testing{width:28.57143%}.l5r5e.chat-dice>img{border:1px solid transparent;background-repeat:no-repeat;background-position:center;background-size:100%;height:40px;width:40px;outline:none;margin:0;flex:0 0 20px;display:inline-block}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%} +.testing{width:14.28571%}.testing{width:28.57143%}.testing{width:14.28571%}.testing{width:28.57143%}.testing{width:14.28571%}.testing{width:28.57143%}.l5r5e.chat-dice>img{border:1px solid transparent;background-repeat:no-repeat;background-position:center;background-size:100%;height:44px;width:44px;outline:none;margin:0;flex:0 0 20px;display:inline-block}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%}.l5r5e .testing{width:14.28571%}.l5r5e .testing{width:28.57143%} diff --git a/system/styles/scss/dices.scss b/system/styles/scss/dices.scss index dc05005..ae08a2b 100644 --- a/system/styles/scss/dices.scss +++ b/system/styles/scss/dices.scss @@ -7,8 +7,8 @@ background-repeat: no-repeat; background-position: center; background-size: 100%; - height: 40px; - width: 40px; + height: 44px; + width: 44px; //cursor: pointer; //-webkit-appearance: none; //appearance: none;