Added ability to apply the strife to the actor
This commit is contained in:
@@ -10,8 +10,10 @@
|
||||
- Compendiums :
|
||||
- Techniques : Added difficulty and skill values (not all techniques).
|
||||
- DicePicker :
|
||||
- Added TN hidden difficulty visibility for GM.
|
||||
- Added TN hidden difficulty visibility for GM (ex: ?2?).
|
||||
- Added a selection for techniques with skill list.
|
||||
- RnK :
|
||||
- Added ability to apply the strife to the actor on final step. The chat message show the value taken in gray aside the total strife.
|
||||
|
||||
Syntaxe quick explanation :
|
||||
- Difficulty can be :
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"swap_drop_here": "Swap",
|
||||
"keep_drop_here": "Keep",
|
||||
"bt_validate": "Finalize this step",
|
||||
"bt_strife": "Apply strife",
|
||||
"undo": "[GM] Undo the last step choices"
|
||||
},
|
||||
"gm_toolbox": {
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"swap_drop_here": "Cambiar cara",
|
||||
"keep_drop_here": "Guardar",
|
||||
"bt_validate": "Terminar este paso",
|
||||
"bt_strife": "Apply strife",
|
||||
"undo": "[GM] Deshacer los últimos cambios"
|
||||
},
|
||||
"gm_toolbox": {
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"swap_drop_here": "Modifier",
|
||||
"keep_drop_here": "Garder",
|
||||
"bt_validate": "Finaliser cette étape",
|
||||
"bt_strife": "Appliquer le conflit",
|
||||
"undo": "[GM] Annuler les choix de la dernière étape"
|
||||
},
|
||||
"gm_toolbox": {
|
||||
|
||||
@@ -632,7 +632,7 @@ export class DicePickerDialog extends FormApplication {
|
||||
let targetToken;
|
||||
if (isMin === null) {
|
||||
// only one target, get the first element
|
||||
targetToken = Array.from(game.user.targets).values().next()?.value.document.actor;
|
||||
targetToken = Array.from(game.user.targets).values().next()?.value.document;
|
||||
} else {
|
||||
// Group (Min/Max)
|
||||
const targetGrp = Array.from(game.user.targets).reduce(
|
||||
|
||||
@@ -32,6 +32,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
*/
|
||||
object = {
|
||||
currentStep: 0,
|
||||
strifeApplied: 0,
|
||||
submitDisabled: false,
|
||||
swapDiceFaces: {
|
||||
rings: [],
|
||||
@@ -225,7 +226,7 @@ export class RollnKeepDialog extends FormApplication {
|
||||
const kept = this._getKeepCount(this.object.currentStep);
|
||||
this.object.submitDisabled = kept < 1 || kept > this.roll.l5r5e.keepLimit;
|
||||
} else if (!this.object.dicesList[this.object.currentStep]) {
|
||||
this.options.editable = false;
|
||||
this.options.editable = this.roll.l5r5e.summary.strife > 0;
|
||||
this.options.classes.push("finalized");
|
||||
}
|
||||
|
||||
@@ -675,6 +676,28 @@ export class RollnKeepDialog extends FormApplication {
|
||||
return;
|
||||
}
|
||||
|
||||
// Last step strife choice
|
||||
if (this.roll?.l5r5e?.rnkEnded && formData.strifeApplied !== undefined) {
|
||||
// Apply strife to actor
|
||||
const strifeApplied = Math.min(this.roll.l5r5e.summary.strife, Math.max(0, formData.strifeApplied));
|
||||
const actorMod = strifeApplied - this.roll.l5r5e.strifeApplied;
|
||||
if (actorMod !== 0) {
|
||||
await this.roll.l5r5e.actor.update({
|
||||
data: {
|
||||
strife: {
|
||||
value: Math.max(0, this.roll.l5r5e.actor.data.data.strife.value + actorMod),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Update the roll & send to chat
|
||||
this.roll.l5r5e.strifeApplied = strifeApplied;
|
||||
await this._rebuildRoll(false);
|
||||
await this._toChatMessage();
|
||||
return this.close();
|
||||
}
|
||||
|
||||
// Discard all dices without a choice for the current step
|
||||
this._forceChoiceForDiceWithoutOne(RollnKeepDialog.CHOICES.discard);
|
||||
|
||||
@@ -690,8 +713,8 @@ export class RollnKeepDialog extends FormApplication {
|
||||
// Send the new roll in chat and delete the old message
|
||||
await this._toChatMessage();
|
||||
|
||||
// If a next step exist, rerender, else close
|
||||
if (this.object.dicesList[this.object.currentStep]) {
|
||||
// If a next step exist or strife, rerender, else close
|
||||
if (this.object.dicesList[this.object.currentStep] || this.roll.l5r5e.summary.strife > 0) {
|
||||
return this.render(false);
|
||||
}
|
||||
return this.close();
|
||||
|
||||
@@ -9,22 +9,23 @@ export class RollL5r5e extends Roll {
|
||||
super(formula, data, options);
|
||||
|
||||
this.l5r5e = {
|
||||
stance: "",
|
||||
skillId: "",
|
||||
skillCatId: "",
|
||||
actor: null,
|
||||
targetTokenId: null,
|
||||
difficulty: 2,
|
||||
difficultyHidden: false,
|
||||
voidPointUsed: false,
|
||||
keepLimit: null,
|
||||
isInitiativeRoll: false,
|
||||
skillAssistance: 0,
|
||||
initialFormula: null,
|
||||
dicesTypes: {
|
||||
std: false,
|
||||
l5r: false,
|
||||
},
|
||||
difficulty: 2,
|
||||
difficultyHidden: false,
|
||||
history: null,
|
||||
initialFormula: null,
|
||||
isInitiativeRoll: false,
|
||||
keepLimit: null,
|
||||
rnkEnded: false,
|
||||
skillAssistance: 0,
|
||||
skillCatId: "",
|
||||
skillId: "",
|
||||
stance: "",
|
||||
strifeApplied: 0,
|
||||
summary: {
|
||||
totalSuccess: 0,
|
||||
totalBonus: 0,
|
||||
@@ -33,12 +34,12 @@ export class RollL5r5e extends Roll {
|
||||
opportunity: 0,
|
||||
strife: 0,
|
||||
},
|
||||
history: null,
|
||||
rnkEnded: false,
|
||||
targetTokenId: null,
|
||||
voidPointUsed: false,
|
||||
};
|
||||
|
||||
// Parse flavor for stance and skillId
|
||||
const flavors = Array.from(formula.matchAll(/\d+d(s|r)\[([^\]]+)\]/gmu));
|
||||
const flavors = Array.from(formula.matchAll(/\d+d([sr])\[([^\]]+)\]/gmu));
|
||||
flavors.forEach((res) => {
|
||||
if (res[1] === "r" && !!res[2] && this.l5r5e.stance === "") {
|
||||
this.l5r5e.stance = res[2];
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -237,6 +237,24 @@
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
}
|
||||
.form-group {
|
||||
width: 100%;
|
||||
.form-fields {
|
||||
flex: 1;
|
||||
&:nth-child(2) {
|
||||
flex: 3;
|
||||
input {
|
||||
flex: 3;
|
||||
}
|
||||
i {
|
||||
flex: unset;
|
||||
}
|
||||
}
|
||||
}
|
||||
.range-value {
|
||||
width: 2rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.profil {
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
{{/if}}
|
||||
|
||||
{{#if strife}}
|
||||
<i class="i_strife" title="{{localize 'l5r5e.chatdices.strife'}}"></i>x{{strife}}
|
||||
<i class="i_strife" title="{{localize 'l5r5e.chatdices.strife'}}"></i>x{{strife}} {{#if ../l5r5e.strifeApplied}}<sup>{{../l5r5e.strifeApplied}}</sup>{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</header>
|
||||
<section class="rnk-ct">
|
||||
{{!-- Body --}}
|
||||
{{#if options.editable}}
|
||||
{{^if l5r5e.rnkEnded}}
|
||||
{{!-- Face Rings --}}
|
||||
<fieldset class="dropbox swap">
|
||||
<legend class="section-header">
|
||||
@@ -137,6 +137,20 @@
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{!-- Strife selection --}}
|
||||
{{#if l5r5e.summary.strife}}
|
||||
<div class="form-group" style="width: 100%;">
|
||||
<div class="form-fields"></div>
|
||||
<div class="form-fields">
|
||||
<input type="range" name="strifeApplied" data-dtype="Number" value="{{l5r5e.strifeApplied}}" min="0" max="{{l5r5e.summary.strife}}" step="1">
|
||||
<span class="range-value">{{l5r5e.strifeApplied}}</span> <i class="i_strife"></i>
|
||||
</div>
|
||||
<div class="form-fields"></div>
|
||||
</div>
|
||||
<button id="finalize" name="finalize" type="button" {{#if data.submitDisabled}}disabled{{/if}}>
|
||||
{{ localize 'l5r5e.roll_n_keep.bt_strife' }} <i class="fas fa-arrow-circle-right"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</section>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user