-RnK dialog auto-open after a roll
-Move for some roll props -2 RnK bugfix (TN & Reroll)
This commit is contained in:
@@ -78,6 +78,7 @@ export class CombatL5r5e extends Combat {
|
||||
}
|
||||
|
||||
let roll;
|
||||
let rnkMessage;
|
||||
const flavor =
|
||||
game.i18n.localize("l5r5e.chatdices.initiative_roll") +
|
||||
" (" +
|
||||
@@ -87,8 +88,7 @@ export class CombatL5r5e extends Combat {
|
||||
if (messageOptions.rnkRoll instanceof game.l5r5e.RollL5r5e && ids.length === 1) {
|
||||
// Specific RnK
|
||||
roll = messageOptions.rnkRoll;
|
||||
// Ugly but work... i need the new messageId
|
||||
combatant.actor.rnkMessage = await roll.toMessage({ flavor });
|
||||
rnkMessage = await roll.toMessage({ flavor });
|
||||
} else {
|
||||
// Regular
|
||||
roll = new game.l5r5e.RollL5r5e(formula);
|
||||
@@ -97,23 +97,28 @@ export class CombatL5r5e extends Combat {
|
||||
roll.l5r5e.stance = data.stance;
|
||||
roll.l5r5e.skillId = skillId;
|
||||
roll.l5r5e.skillCatId = skillCat;
|
||||
roll.l5r5e.summary.difficulty =
|
||||
roll.l5r5e.difficulty =
|
||||
messageOptions.difficulty !== undefined ? messageOptions.difficulty : cfg.difficulty;
|
||||
roll.l5r5e.summary.difficultyHidden =
|
||||
roll.l5r5e.difficultyHidden =
|
||||
messageOptions.difficultyHidden !== undefined
|
||||
? messageOptions.difficultyHidden
|
||||
: cfg.difficultyHidden;
|
||||
roll.l5r5e.summary.voidPointUsed = !!messageOptions.useVoidPoint;
|
||||
roll.l5r5e.voidPointUsed = !!messageOptions.useVoidPoint;
|
||||
|
||||
roll.roll();
|
||||
roll.toMessage({ flavor });
|
||||
rnkMessage = await roll.toMessage({ flavor });
|
||||
}
|
||||
|
||||
// Ugly but work... i need the new messageId
|
||||
if (ids.length === 1) {
|
||||
combatant.actor.rnkMessage = rnkMessage;
|
||||
}
|
||||
|
||||
// if the character succeeded on their Initiative check, they add 1 to their base initiative value,
|
||||
// plus an additional amount equal to their bonus successes.
|
||||
const successes = roll.l5r5e.summary.totalSuccess;
|
||||
if (successes >= roll.l5r5e.summary.difficulty) {
|
||||
initiative = initiative + 1 + Math.max(successes - roll.l5r5e.summary.difficulty, 0);
|
||||
if (successes >= roll.l5r5e.difficulty) {
|
||||
initiative = initiative + 1 + Math.max(successes - roll.l5r5e.difficulty, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
</span>
|
||||
|
||||
<span class="chat-profil-element">
|
||||
{{#if l5r5e.summary.difficultyHidden}}
|
||||
{{#if l5r5e.difficultyHidden}}
|
||||
{{localize 'l5r5e.chatdices.difficulty_hidden'}}
|
||||
{{else}}
|
||||
{{localize 'l5r5e.chatdices.difficulty'}} {{l5r5e.summary.difficulty}}
|
||||
{{localize 'l5r5e.chatdices.difficulty'}} {{l5r5e.difficulty}}
|
||||
{{/if}}
|
||||
{{#if l5r5e.summary.voidPointUsed}}
|
||||
{{#if l5r5e.voidPointUsed}}
|
||||
<br><i class="i_void" title="{{localize 'l5r5e.chatdices.void_point_used'}}"></i>
|
||||
{{/if}}
|
||||
</span>
|
||||
@@ -78,13 +78,15 @@
|
||||
</div>
|
||||
|
||||
{{!-- Result text --}}
|
||||
{{^if ../l5r5e.difficultyHidden}}
|
||||
<div>
|
||||
{{#ifCond totalSuccess '>=' difficulty}}
|
||||
{{#ifCond totalSuccess '>=' ../l5r5e.difficulty}}
|
||||
{{localize "l5r5e.chatdices.success_text"}} ({{totalBonus}} {{localize "l5r5e.chatdices.bonus_text"}})
|
||||
{{else}}
|
||||
{{localize "l5r5e.chatdices.fail_text"}}
|
||||
{{/ifCond}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/l5r5e.summary}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
</span>
|
||||
|
||||
<span class="chat-profil-element">
|
||||
{{#if l5r5e.summary.difficultyHidden}}
|
||||
{{#if l5r5e.difficultyHidden}}
|
||||
{{localize 'l5r5e.chatdices.difficulty_hidden'}}
|
||||
{{else}}
|
||||
{{localize 'l5r5e.chatdices.difficulty'}} {{l5r5e.summary.difficulty}}
|
||||
{{localize 'l5r5e.chatdices.difficulty'}} {{l5r5e.difficulty}}
|
||||
{{/if}}
|
||||
{{#if l5r5e.summary.voidPointUsed}}
|
||||
{{#if l5r5e.voidPointUsed}}
|
||||
<br><i class="i_void" title="{{localize 'l5r5e.chatdices.void_point_used'}}"></i>
|
||||
{{/if}}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user