Changed the way the swap is handled, that now work the same as the reroll
This commit is contained in:
@@ -22,6 +22,9 @@
|
|||||||
- Added a selection for techniques with skill list.
|
- Added a selection for techniques with skill list.
|
||||||
- RnK :
|
- RnK :
|
||||||
- Added ability to directly apply the strife to the actor on final step. The chat message show the value taken in gray aside the total strife.
|
- Added ability to directly apply the strife to the actor on final step. The chat message show the value taken in gray aside the total strife.
|
||||||
|
- Changed the way the swap is handled, that now work the same as the reroll.
|
||||||
|
- You need to keep them after the step was validated.
|
||||||
|
- This way you can do step by step for disadvantages, advantages, techniques swaps...
|
||||||
- Roll chat message :
|
- Roll chat message :
|
||||||
- Added Target information.
|
- Added Target information.
|
||||||
- Properties sheet:
|
- Properties sheet:
|
||||||
|
|||||||
@@ -314,6 +314,7 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
current.newFace = diceNewFace;
|
current.newFace = diceNewFace;
|
||||||
|
this._forceChoiceForDiceWithoutOne(RollnKeepDialog.CHOICES.keep);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,19 +364,25 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
*/
|
*/
|
||||||
_checkKeepCount(step) {
|
_checkKeepCount(step) {
|
||||||
return (
|
return (
|
||||||
!this._haveChoice(step, RollnKeepDialog.CHOICES.reroll) &&
|
!this._haveChoice(step, [RollnKeepDialog.CHOICES.reroll, RollnKeepDialog.CHOICES.swap]) &&
|
||||||
(step === 0 || this._haveChoice(step - 1, RollnKeepDialog.CHOICES.reroll))
|
(step === 0 || this._haveChoice(step - 1, [RollnKeepDialog.CHOICES.reroll, RollnKeepDialog.CHOICES.swap]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if this choice exist in the current step
|
* Return true if this choice exist in the current step
|
||||||
|
* @param {number} currentStep
|
||||||
|
* @param {string|string[]} choices
|
||||||
|
* @return {boolean}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_haveChoice(currentStep, choice) {
|
_haveChoice(currentStep, choices) {
|
||||||
|
if (!Array.isArray(choices)) {
|
||||||
|
choices = [choices];
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
this.object.dicesList[currentStep] &&
|
this.object.dicesList[currentStep] &&
|
||||||
this.object.dicesList[currentStep].some((e) => !!e && e.choice === choice)
|
this.object.dicesList[currentStep].some((e) => !!e && choices.includes(e.choice))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,9 +419,11 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _applyChoices() {
|
async _applyChoices() {
|
||||||
let haveSwap = false;
|
|
||||||
let nextStep = this.object.currentStep + 1;
|
let nextStep = this.object.currentStep + 1;
|
||||||
const haveReroll = this._haveChoice(this.object.currentStep, RollnKeepDialog.CHOICES.reroll);
|
const haveReroll = this._haveChoice(this.object.currentStep, [
|
||||||
|
RollnKeepDialog.CHOICES.reroll,
|
||||||
|
RollnKeepDialog.CHOICES.swap,
|
||||||
|
]);
|
||||||
|
|
||||||
// Foreach kept dices, apply choices
|
// Foreach kept dices, apply choices
|
||||||
const newRolls = {};
|
const newRolls = {};
|
||||||
@@ -452,22 +461,12 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
|
|
||||||
case RollnKeepDialog.CHOICES.swap:
|
case RollnKeepDialog.CHOICES.swap:
|
||||||
// FaceSwap : add a new dice with selected face in next step
|
// FaceSwap : add a new dice with selected face in next step
|
||||||
haveSwap = true;
|
|
||||||
this._initializeDicesListStep(nextStep);
|
this._initializeDicesListStep(nextStep);
|
||||||
this.object.dicesList[nextStep][idx] = {
|
this.object.dicesList[nextStep][idx] = {
|
||||||
type: currentRow.type,
|
type: currentRow.type,
|
||||||
face: currentRow.newFace,
|
face: currentRow.newFace,
|
||||||
choice: RollnKeepDialog.CHOICES.keep,
|
choice: RollnKeepDialog.CHOICES.nothing,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Swapped to an exploding face : add the roll
|
|
||||||
if (game.l5r5e[currentRow.type].FACES[currentRow.newFace].explosive) {
|
|
||||||
if (!newRolls[currentRow.type]) {
|
|
||||||
newRolls[currentRow.type] = 0;
|
|
||||||
}
|
|
||||||
newRolls[currentRow.type] += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete currentRow.newFace;
|
delete currentRow.newFace;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -475,13 +474,10 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
|
|
||||||
// If new rolls, roll and add them
|
// If new rolls, roll and add them
|
||||||
if (Object.keys(newRolls).length > 0) {
|
if (Object.keys(newRolls).length > 0) {
|
||||||
if (haveSwap) {
|
|
||||||
nextStep++;
|
|
||||||
}
|
|
||||||
const newRollsResults = await this._newRoll(newRolls);
|
const newRollsResults = await this._newRoll(newRolls);
|
||||||
this._initializeDicesListStep(nextStep);
|
this._initializeDicesListStep(nextStep);
|
||||||
|
|
||||||
const applyNewRolls = (die, idx) => {
|
this.object.dicesList[this.object.currentStep].forEach((die, idx) => {
|
||||||
if (!die) {
|
if (!die) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -493,13 +489,7 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
) {
|
) {
|
||||||
this.object.dicesList[nextStep][idx] = newRollsResults[die.type].shift();
|
this.object.dicesList[nextStep][idx] = newRollsResults[die.type].shift();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
this.object.dicesList[this.object.currentStep].forEach(applyNewRolls);
|
|
||||||
if (haveSwap) {
|
|
||||||
this.object.dicesList[nextStep - 1].forEach(applyNewRolls);
|
|
||||||
this.object.currentStep++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,7 +564,9 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
async _rebuildRoll(forceKeep = false) {
|
async _rebuildRoll(forceKeep = false) {
|
||||||
// Get all kept dices + new (choice null)
|
// Get all kept dices + new (choice null)
|
||||||
const diceList = this.object.dicesList.reduce((acc, step, stepIdx) => {
|
const diceList = this.object.dicesList.reduce((acc, step, stepIdx) => {
|
||||||
const haveReroll = stepIdx > 0 && this._haveChoice(stepIdx - 1, RollnKeepDialog.CHOICES.reroll);
|
const haveReroll =
|
||||||
|
stepIdx > 0 &&
|
||||||
|
this._haveChoice(stepIdx - 1, [RollnKeepDialog.CHOICES.reroll, RollnKeepDialog.CHOICES.swap]);
|
||||||
step.forEach((die, idx) => {
|
step.forEach((die, idx) => {
|
||||||
if (
|
if (
|
||||||
!!die &&
|
!!die &&
|
||||||
|
|||||||
Reference in New Issue
Block a user