inner roll now works ! :)
This commit is contained in:
@@ -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 `<img src="${CONFIG.L5r5e.paths.assets}dices/default/${this.FACES[result].image}.png" alt="${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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user