inner roll now works ! :)
This commit is contained in:
@@ -12,7 +12,6 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
constructor(termData) {
|
constructor(termData) {
|
||||||
super(termData);
|
super(termData);
|
||||||
this.l5r5e = { success: 0, explosive: 0, opportunity: 0, strife: 0 };
|
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 `<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
|
* Evaluate the roll term, populating the results Array
|
||||||
* @override
|
* @override
|
||||||
@@ -61,8 +69,6 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
this._evaluated = true;
|
this._evaluated = true;
|
||||||
this.result = 0;
|
this.result = 0;
|
||||||
|
|
||||||
console.log("L5rBaseDie.evaluate.out", this); // TODO tmp
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +81,6 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
|
|
||||||
//roll.l5r5e = this.l5r5e;
|
//roll.l5r5e = this.l5r5e;
|
||||||
|
|
||||||
console.log("L5rBaseDie.roll", roll); // TODO tmp
|
|
||||||
|
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +90,6 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
|
|
||||||
roll.l5r5e = data.l5r5e;
|
roll.l5r5e = data.l5r5e;
|
||||||
|
|
||||||
console.log("L5rBaseDie.fromData", roll); // TODO tmp
|
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +102,6 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
|
|
||||||
json.l5r5e = this.l5r5e;
|
json.l5r5e = this.l5r5e;
|
||||||
|
|
||||||
console.log("L5rBaseDie.toJSON", json); // TODO tmp
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,20 +47,16 @@ export class RollL5r5e extends Roll {
|
|||||||
throw new Error("This Roll object has already been rolled.");
|
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);
|
let l5rDices = this.terms.filter((term) => term instanceof L5rBaseDie);
|
||||||
this.terms = this.terms.filter((t) => !(t instanceof L5rBaseDie));
|
this.terms = this.terms.filter((t) => !(t instanceof L5rBaseDie));
|
||||||
this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms));
|
this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms));
|
||||||
|
|
||||||
// Roll regular dices
|
// Roll regular dices / inner dices
|
||||||
this._total = 0;
|
this._total = 0;
|
||||||
if (this.terms.length > 0) {
|
if (this.terms.length > 0) {
|
||||||
this.l5r5e.dicesTypes.std = true;
|
|
||||||
|
|
||||||
console.log("this.terms", this.terms);
|
|
||||||
|
|
||||||
// clean terms (trim symbols)
|
// clean terms (trim symbols)
|
||||||
this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms));
|
this.terms = this._identifyTerms(this.constructor.cleanFormula(this.terms));
|
||||||
|
|
||||||
@@ -68,10 +64,19 @@ export class RollL5r5e extends Roll {
|
|||||||
super.evaluate({ minimize, maximize });
|
super.evaluate({ minimize, maximize });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Roll L5R dices
|
// Check inner L5R rolls
|
||||||
if (l5rDices.length > 0) {
|
this._dice.forEach((term) => {
|
||||||
this.l5r5e.dicesTypes.l5r = true;
|
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) => {
|
l5rDices.forEach((term) => {
|
||||||
// Roll
|
// Roll
|
||||||
term.evaluate({ minimize, maximize });
|
term.evaluate({ minimize, maximize });
|
||||||
@@ -80,8 +85,9 @@ export class RollL5r5e extends Roll {
|
|||||||
["success", "explosive", "opportunity", "strife"].forEach((props) => {
|
["success", "explosive", "opportunity", "strife"].forEach((props) => {
|
||||||
this.l5r5e.summary[props] += parseInt(term.l5r5e[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("+");
|
||||||
this.terms.push(term);
|
this.terms.push(term);
|
||||||
});
|
});
|
||||||
@@ -92,14 +98,12 @@ export class RollL5r5e extends Roll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Others advantage/disadvantage
|
// TODO Others advantage/disadvantage
|
||||||
|
|
||||||
// re-inject L5R dices
|
|
||||||
// this.terms = this.terms.concat(l5rTerms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store final outputs
|
// Store final outputs
|
||||||
//this._total = total;
|
|
||||||
this._rolled = true;
|
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
|
console.log("RollL5r5e.evaluate.out", this); // TODO tmp
|
||||||
|
|
||||||
@@ -111,8 +115,6 @@ export class RollL5r5e extends Roll {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
getTooltip() {
|
getTooltip() {
|
||||||
console.log("RollL5r5e.getTooltip", this); // TODO tmp
|
|
||||||
|
|
||||||
const parts = this.dice
|
const parts = this.dice
|
||||||
.filter((t) => !(t instanceof L5rBaseDie))
|
.filter((t) => !(t instanceof L5rBaseDie))
|
||||||
.map((d) => {
|
.map((d) => {
|
||||||
@@ -150,8 +152,6 @@ export class RollL5r5e extends Roll {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
async render(chatOptions = {}) {
|
async render(chatOptions = {}) {
|
||||||
console.log("RollL5r5e.render", chatOptions, this); // TODO tmp
|
|
||||||
|
|
||||||
chatOptions = mergeObject(
|
chatOptions = mergeObject(
|
||||||
{
|
{
|
||||||
user: game.user._id,
|
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
|
// Render the roll display template
|
||||||
return renderTemplate(chatOptions.template, chatData);
|
return renderTemplate(chatOptions.template, chatData);
|
||||||
}
|
}
|
||||||
@@ -249,8 +247,6 @@ export class RollL5r5e extends Roll {
|
|||||||
roll.data = data.data;
|
roll.data = data.data;
|
||||||
roll.l5r5e = data.l5r5e;
|
roll.l5r5e = data.l5r5e;
|
||||||
|
|
||||||
console.log("RollL5r5e.fromData", roll); // TODO tmp
|
|
||||||
|
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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%}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: 100%;
|
background-size: 100%;
|
||||||
height: 40px;
|
height: 44px;
|
||||||
width: 40px;
|
width: 44px;
|
||||||
//cursor: pointer;
|
//cursor: pointer;
|
||||||
//-webkit-appearance: none;
|
//-webkit-appearance: none;
|
||||||
//appearance: none;
|
//appearance: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user