parse flavor for stance skill
This commit is contained in:
@@ -11,8 +11,6 @@ export class RollL5r5e extends Roll {
|
|||||||
// static TOOLTIP_TEMPLATE = `${CONFIG.L5r5e.pathTemplates}dice/tooltip.html`;
|
// static TOOLTIP_TEMPLATE = `${CONFIG.L5r5e.pathTemplates}dice/tooltip.html`;
|
||||||
|
|
||||||
constructor(...args) {
|
constructor(...args) {
|
||||||
console.log("RollL5r5e.in.args", args); // TODO tmp
|
|
||||||
|
|
||||||
super(...args);
|
super(...args);
|
||||||
|
|
||||||
this.l5r5e = {
|
this.l5r5e = {
|
||||||
@@ -32,9 +30,18 @@ export class RollL5r5e extends Roll {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO parse difficulty stance skillId from cmd line ?
|
// Parse flavor for stance and skillId
|
||||||
|
const flavors = Array.from(args[0].matchAll(/\d+d(s|r)\[([^\]]+)\]/gmu));
|
||||||
|
flavors.forEach((res) => {
|
||||||
|
if (res[1] === "r" && !!res[2] && this.l5r5e.stance === "") {
|
||||||
|
this.l5r5e.stance = res[2];
|
||||||
|
}
|
||||||
|
if (res[1] === "s" && !!res[2] && this.l5r5e.skillId === "") {
|
||||||
|
this.l5r5e.skillId = res[2];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
console.log("RollL5r5e.out.args", args, this); // TODO tmp
|
// TODO parse difficulty stance skillId from cmd line ?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,8 +56,6 @@ export class RollL5r5e extends Roll {
|
|||||||
throw new Error("This Roll object need dice to be rolled.");
|
throw new Error("This Roll object need dice to be rolled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("RollL5r5e.evaluate.in", this); // TODO tmp
|
|
||||||
|
|
||||||
// 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));
|
||||||
|
|
||||||
@@ -71,8 +76,6 @@ export class RollL5r5e extends Roll {
|
|||||||
this.l5r5e.dicesTypes.std = this.dice.some((term) => term instanceof DiceTerm && !(term instanceof L5rBaseDie)); // ignore math symbols
|
this.l5r5e.dicesTypes.std = this.dice.some((term) => term instanceof DiceTerm && !(term instanceof L5rBaseDie)); // ignore math symbols
|
||||||
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof L5rBaseDie);
|
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof L5rBaseDie);
|
||||||
|
|
||||||
console.log("RollL5r5e.evaluate.out", this); // TODO tmp
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,13 +86,15 @@ export class RollL5r5e extends Roll {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_l5rSummary(term) {
|
_l5rSummary(term) {
|
||||||
if (term instanceof L5rBaseDie) {
|
if (!(term instanceof L5rBaseDie)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
["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]);
|
||||||
});
|
});
|
||||||
// TODO Others advantage/disadvantage
|
// TODO Others advantage/disadvantage
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the total result of the Roll expression if it has been evaluated, otherwise null
|
* Return the total result of the Roll expression if it has been evaluated, otherwise null
|
||||||
@@ -201,6 +206,8 @@ export class RollL5r5e extends Roll {
|
|||||||
l5r5e: isPrivate
|
l5r5e: isPrivate
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
|
stance: this.l5r5e.stance,
|
||||||
|
skillId: this.l5r5e.skillId,
|
||||||
dicesTypes: this.l5r5e.dicesTypes,
|
dicesTypes: this.l5r5e.dicesTypes,
|
||||||
summary: this.l5r5e.summary,
|
summary: this.l5r5e.summary,
|
||||||
dices: this.dice.map((d) => {
|
dices: this.dice.map((d) => {
|
||||||
@@ -226,8 +233,6 @@ export class RollL5r5e extends Roll {
|
|||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
toMessage(messageData = {}, { rollMode = null, create = true } = {}) {
|
toMessage(messageData = {}, { rollMode = null, create = true } = {}) {
|
||||||
console.log("RollL5r5e.toMessage", this); // TODO tmp
|
|
||||||
|
|
||||||
// Perform the roll, if it has not yet been rolled
|
// Perform the roll, if it has not yet been rolled
|
||||||
if (!this._rolled) {
|
if (!this._rolled) {
|
||||||
this.evaluate();
|
this.evaluate();
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
{{#if l5r5e.stance}}
|
{{#if l5r5e.stance}}
|
||||||
<div class="l5r5e dice-stance">
|
<div class="l5r5e dice-stance">
|
||||||
{{l5r5e.skillId}} ({{l5r5e.stance}})
|
<!-- TODO localization -->
|
||||||
|
{{l5r5e.skillId}} (<i class="i_{{l5r5e.stance}}"></i>)
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user