Add Reroll and Swap visualisation in chatlog
This commit is contained in:
@@ -91,6 +91,9 @@ export class L5rBaseDie extends DiceTerm {
|
|||||||
["success", "explosive", "opportunity", "strife"].forEach((props) => {
|
["success", "explosive", "opportunity", "strife"].forEach((props) => {
|
||||||
this.l5r5e[props] += parseInt(face[props]);
|
this.l5r5e[props] += parseInt(face[props]);
|
||||||
});
|
});
|
||||||
|
if (face.explosive) {
|
||||||
|
term.exploded = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -507,12 +507,23 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
*/
|
*/
|
||||||
async _rebuildRoll() {
|
async _rebuildRoll() {
|
||||||
// Get all kept dices + new (choice null)
|
// Get all kept dices + new (choice null)
|
||||||
const diceList = this.object.dicesList.reduce((acc, step) => {
|
const diceList = this.object.dicesList.reduce((acc, step, stepIdx) => {
|
||||||
step.forEach((die) => {
|
step.forEach((die, idx) => {
|
||||||
if (!!die && [RollnKeepDialog.CHOICES.keep, RollnKeepDialog.CHOICES.nothing].includes(die.choice)) {
|
if (!!die && [RollnKeepDialog.CHOICES.keep, RollnKeepDialog.CHOICES.nothing].includes(die.choice)) {
|
||||||
if (!acc[die.type]) {
|
if (!acc[die.type]) {
|
||||||
acc[die.type] = [];
|
acc[die.type] = [];
|
||||||
}
|
}
|
||||||
|
// Check previous dice, to add html classes in chat
|
||||||
|
if (stepIdx > 0 && this.object.dicesList[stepIdx - 1][idx]) {
|
||||||
|
switch (this.object.dicesList[stepIdx - 1][idx].choice) {
|
||||||
|
case RollnKeepDialog.CHOICES.reroll:
|
||||||
|
die.class = "rerolled";
|
||||||
|
break;
|
||||||
|
case RollnKeepDialog.CHOICES.swap:
|
||||||
|
die.class = "swapped";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
acc[die.type].push(die);
|
acc[die.type].push(die);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -535,6 +546,11 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
term.results.map((res) => {
|
term.results.map((res) => {
|
||||||
const die = diceList[term.constructor.name].shift();
|
const die = diceList[term.constructor.name].shift();
|
||||||
res.result = die.face;
|
res.result = die.face;
|
||||||
|
|
||||||
|
// add class to term result
|
||||||
|
if (die.class) {
|
||||||
|
res[die.class] = true;
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
term.l5rSummary();
|
term.l5rSummary();
|
||||||
|
|||||||
@@ -104,10 +104,13 @@ export class RollL5r5e extends Roll {
|
|||||||
); // ignore math symbols
|
); // ignore math symbols
|
||||||
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof game.l5r5e.L5rBaseDie);
|
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof game.l5r5e.L5rBaseDie);
|
||||||
summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty);
|
summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty);
|
||||||
this.l5r5e.keepLimit = this.dice.reduce(
|
|
||||||
(acc, term) => (term instanceof game.l5r5e.RingDie ? acc + term.number : acc),
|
if (!this.l5r5e.keepLimit) {
|
||||||
0
|
this.l5r5e.keepLimit = this.dice.reduce(
|
||||||
);
|
(acc, term) => (term instanceof game.l5r5e.RingDie ? acc + term.number : acc),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,8 +186,9 @@ export class RollL5r5e extends Roll {
|
|||||||
classes: [
|
classes: [
|
||||||
cls.name.toLowerCase(),
|
cls.name.toLowerCase(),
|
||||||
"d" + term.faces,
|
"d" + term.faces,
|
||||||
!isL5rDie && r.rerolled ? "rerolled" : null,
|
isL5rDie && r.swapped ? "swapped" : null,
|
||||||
!isL5rDie && r.exploded ? "exploded" : null,
|
r.rerolled ? "rerolled" : null,
|
||||||
|
r.exploded ? "exploded" : null,
|
||||||
!isL5rDie && r.discarded ? "discarded" : null,
|
!isL5rDie && r.discarded ? "discarded" : null,
|
||||||
!isL5rDie && r.result === 1 ? "min" : null,
|
!isL5rDie && r.result === 1 ? "min" : null,
|
||||||
!isL5rDie && r.result === term.faces ? "max" : null,
|
!isL5rDie && r.result === term.faces ? "max" : null,
|
||||||
@@ -240,12 +244,20 @@ export class RollL5r5e extends Roll {
|
|||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
...this.l5r5e,
|
...this.l5r5e,
|
||||||
dices: this.dice.map((d) => {
|
dices: this.dice.map((term) => {
|
||||||
|
const isL5rDie = term instanceof game.l5r5e.L5rBaseDie;
|
||||||
return {
|
return {
|
||||||
diceTypeL5r: d instanceof game.l5r5e.L5rBaseDie,
|
diceTypeL5r: isL5rDie,
|
||||||
rolls: d.results.map((r) => {
|
rolls: term.results.map((r) => {
|
||||||
return {
|
return {
|
||||||
result: d.constructor.getResultLabel(r.result),
|
result: term.constructor.getResultLabel(r.result),
|
||||||
|
classes: [
|
||||||
|
isL5rDie && r.swapped ? "swapped" : null,
|
||||||
|
r.rerolled ? "rerolled" : null,
|
||||||
|
r.exploded ? "exploded" : null,
|
||||||
|
]
|
||||||
|
.filter((c) => !!c)
|
||||||
|
.join(" "),
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -9,20 +9,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dice in chat
|
// Dice in chat
|
||||||
.chat-dice > img {
|
.chat-dice {
|
||||||
border: 1px solid transparent;
|
&.rerolled > img {
|
||||||
background-repeat: no-repeat;
|
border-bottom: 3px solid orangered;
|
||||||
background-position: center;
|
}
|
||||||
background-size: 100%;
|
|
||||||
height: 44px;
|
&.swapped > img {
|
||||||
width: 44px;
|
border-bottom: 3px solid fuchsia;
|
||||||
//cursor: pointer;
|
}
|
||||||
//-webkit-appearance: none;
|
|
||||||
//appearance: none;
|
img {
|
||||||
outline: none;
|
border: 1px solid transparent;
|
||||||
margin: 0;
|
background-repeat: no-repeat;
|
||||||
flex: 0 0 20px;
|
background-position: center;
|
||||||
display: inline-block;
|
background-size: 100%;
|
||||||
|
height: 44px;
|
||||||
|
width: 44px;
|
||||||
|
//cursor: pointer;
|
||||||
|
//-webkit-appearance: none;
|
||||||
|
//appearance: none;
|
||||||
|
outline: none;
|
||||||
|
margin: 0;
|
||||||
|
flex: 0 0 20px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-profil {
|
.chat-profil {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
{{#each l5r5e.dices}}
|
{{#each l5r5e.dices}}
|
||||||
{{#if this.diceTypeL5r}}
|
{{#if this.diceTypeL5r}}
|
||||||
{{#each this.rolls}}
|
{{#each this.rolls}}
|
||||||
<span class="l5r5e chat-dice">{{{this.result}}}</span>
|
<span class="l5r5e chat-dice {{this.classes}}">{{{this.result}}}</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|||||||
Reference in New Issue
Block a user