-RnK dialog auto-open after a roll

-Move for some roll props
-2 RnK bugfix (TN & Reroll)
This commit is contained in:
Vlyan
2021-02-02 09:28:46 +01:00
parent 4350506e09
commit 931a28fbfe
6 changed files with 48 additions and 33 deletions

View File

@@ -415,9 +415,10 @@ export class DicePickerDialog extends FormApplication {
formula.push(`${this.object.skill.value}ds`);
}
let message;
if (this.object.isInitiativeRoll) {
// Initiative roll
this._actor.rollInitiative({
await this._actor.rollInitiative({
initiativeOptions: {
formula: formula.join("+"),
// updateTurn: true,
@@ -429,6 +430,9 @@ export class DicePickerDialog extends FormApplication {
},
},
});
// Adhesive tape to get the messageId :/
message = this._actor.rnkMessage;
delete this._actor.rnkMessage;
} else {
// Regular roll, so let's roll !
const roll = await new game.l5r5e.RollL5r5e(formula.join("+"));
@@ -437,12 +441,16 @@ export class DicePickerDialog extends FormApplication {
roll.l5r5e.stance = this.object.ring.id;
roll.l5r5e.skillId = this.object.skill.id;
roll.l5r5e.skillCatId = this.object.skill.cat;
roll.l5r5e.summary.difficulty = this.object.difficulty.value;
roll.l5r5e.summary.difficultyHidden = this.object.difficulty.hidden;
roll.l5r5e.summary.voidPointUsed = this.object.useVoidPoint;
roll.l5r5e.difficulty = this.object.difficulty.value;
roll.l5r5e.difficultyHidden = this.object.difficulty.hidden;
roll.l5r5e.voidPointUsed = this.object.useVoidPoint;
await roll.roll();
await roll.toMessage();
message = await roll.toMessage();
}
if (message) {
new game.l5r5e.RollnKeepDialog(message._id).render(true);
}
return this.close();

View File

@@ -117,7 +117,7 @@ export class RollnKeepDialog extends FormApplication {
}
// Get the roll
this.roll = game.l5r5e.RollL5r5e.fromData(this.message.roll);
this.roll = game.l5r5e.RollL5r5e.fromData(this.message._roll);
// Already history
if (Array.isArray(this.roll.l5r5e.history)) {
@@ -207,7 +207,7 @@ export class RollnKeepDialog extends FormApplication {
// Check only on 1st step
if (this.object.currentStep === 0) {
const kept = this._getKeepCount();
this.object.submitDisabled = kept < 1 || kept > this.roll.l5r5e.summary.ringsUsed;
this.object.submitDisabled = kept < 1 || kept > this.roll.l5r5e.ringsUsed;
} else if (!this.object.dicesList[this.object.currentStep]) {
this.options.editable = false;
}
@@ -282,7 +282,7 @@ export class RollnKeepDialog extends FormApplication {
current.choice = type;
// Little time saving : on 1st step, if we reach the max kept dices, discard all dices without a choice
if (this.object.currentStep === 0 && this._getKeepCount() === this.roll.l5r5e.summary.ringsUsed) {
if (this.object.currentStep === 0 && this._getKeepCount() === this.roll.l5r5e.ringsUsed) {
this._discardDiceWithoutChoice();
}
@@ -445,7 +445,7 @@ export class RollnKeepDialog extends FormApplication {
const roll = await new game.l5r5e.RollL5r5e(this._arrayToFormula(newRolls));
roll.l5r5e = {
...this.message.roll.l5r5e,
...this.message._roll.l5r5e,
summary: roll.l5r5e.summary,
};
@@ -480,7 +480,7 @@ export class RollnKeepDialog extends FormApplication {
// Get all kept dices + new (choice null)
const diceList = this.object.dicesList.reduce((acc, step) => {
step.forEach((die) => {
if (!!die && die.choice !== RollnKeepDialog.CHOICES.discard) {
if (!!die && [RollnKeepDialog.CHOICES.keep, RollnKeepDialog.CHOICES.nothing].includes(die.choice)) {
if (!acc[die.type]) {
acc[die.type] = [];
}
@@ -493,7 +493,7 @@ export class RollnKeepDialog extends FormApplication {
// Re create a new roll
const roll = await new game.l5r5e.RollL5r5e(this._arrayToFormula(diceList));
roll.l5r5e = {
...this.message.roll.l5r5e,
...this.message._roll.l5r5e,
summary: roll.l5r5e.summary,
};

View File

@@ -13,15 +13,16 @@ export class RollL5r5e extends Roll {
skillId: "",
skillCatId: "",
actor: null,
difficulty: 2,
difficultyHidden: false,
voidPointUsed: false,
ringsUsed: null,
isInitiativeRoll: false,
dicesTypes: {
std: false,
l5r: false,
},
summary: {
difficulty: 2,
difficultyHidden: false,
voidPointUsed: false,
ringsUsed: null,
totalSuccess: 0,
totalBonus: 0,
success: 0,
@@ -30,7 +31,6 @@ export class RollL5r5e extends Roll {
strife: 0,
},
history: null,
isInitiativeRoll: false,
};
// Parse flavor for stance and skillId
@@ -103,8 +103,8 @@ export class RollL5r5e extends Roll {
(term) => term instanceof DiceTerm && !(term instanceof game.l5r5e.L5rBaseDie)
); // ignore math symbols
this.l5r5e.dicesTypes.l5r = this.dice.some((term) => term instanceof game.l5r5e.L5rBaseDie);
summary.totalBonus = Math.max(0, summary.totalSuccess - summary.difficulty);
summary.ringsUsed = this.dice.reduce(
summary.totalBonus = Math.max(0, summary.totalSuccess - this.l5r5e.difficulty);
this.l5r5e.ringsUsed = this.dice.reduce(
(acc, term) => (term instanceof game.l5r5e.RingDie ? acc + term.number : acc),
0
);