Fix: validation encaissement MJ
This commit is contained in:
parent
6c4a8eb70f
commit
4273f5f48f
@ -3204,25 +3204,31 @@ export class RdDActor extends RdDBaseActor {
|
|||||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const attackerId = attacker?.id;
|
||||||
if (ReglesOptionelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
|
if (ReglesOptionelles.isUsing('validation-encaissement-gr') && !game.user.isGM) {
|
||||||
RdDBaseActor.remoteActorCall({
|
RdDBaseActor.remoteActorCall({
|
||||||
actorId: this.id,
|
actorId: this.id,
|
||||||
method: 'validerEncaissement',
|
method: 'appliquerEncaissement',
|
||||||
args: [rollData, show]
|
args: [rollData, show, attackerId]
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await this.appliquerEncaissement(rollData, show, attackerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
async appliquerEncaissement(rollData, show, attackerId) {
|
||||||
const armure = await this.computeArmure(rollData);
|
const armure = await this.computeArmure(rollData);
|
||||||
if (ReglesOptionelles.isUsing('validation-encaissement-gr')) {
|
if (ReglesOptionelles.isUsing('validation-encaissement-gr')) {
|
||||||
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, (encaissement, show) => this._appliquerEncaissement(encaissement, show, attacker));
|
DialogValidationEncaissement.validerEncaissement(this, rollData, armure, show, attackerId, (encaissement, show, attackerId) => this._appliquerEncaissement(encaissement, show, attackerId));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
|
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
|
||||||
await this._appliquerEncaissement(encaissement, show, attacker)
|
await this._appliquerEncaissement(encaissement, show, attackerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _appliquerEncaissement(encaissement, show, attacker) {
|
async _appliquerEncaissement(encaissement, show, attackedId) {
|
||||||
|
const attacker = attackedId ? game.actors.get(attackedId) : undefined
|
||||||
let santeOrig = duplicate(this.system.sante);
|
let santeOrig = duplicate(this.system.sante);
|
||||||
|
|
||||||
const blessure = await this.ajouterBlessure(encaissement, attacker); // Will update the result table
|
const blessure = await this.ajouterBlessure(encaissement, attacker); // Will update the result table
|
||||||
|
@ -3,6 +3,7 @@ import { SYSTEM_SOCKET_ID } from "../constants.js";
|
|||||||
import { Monnaie } from "../item-monnaie.js";
|
import { Monnaie } from "../item-monnaie.js";
|
||||||
import { Misc } from "../misc.js";
|
import { Misc } from "../misc.js";
|
||||||
import { RdDAudio } from "../rdd-audio.js";
|
import { RdDAudio } from "../rdd-audio.js";
|
||||||
|
import { RdDConfirm } from "../rdd-confirm.js";
|
||||||
import { RdDUtility } from "../rdd-utility.js";
|
import { RdDUtility } from "../rdd-utility.js";
|
||||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||||
import { APP_ASTROLOGIE_REFRESH } from "../sommeil/app-astrologie.js";
|
import { APP_ASTROLOGIE_REFRESH } from "../sommeil/app-astrologie.js";
|
||||||
|
@ -7,7 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
|
|||||||
*/
|
*/
|
||||||
export class DialogValidationEncaissement extends Dialog {
|
export class DialogValidationEncaissement extends Dialog {
|
||||||
|
|
||||||
static async validerEncaissement(actor, rollData, armure, show, onEncaisser) {
|
static async validerEncaissement(actor, rollData, armure, show, attackerId, onEncaisser) {
|
||||||
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: HIDE_DICE });
|
let encaissement = await RdDUtility.jetEncaissement(rollData, armure, { showDice: HIDE_DICE });
|
||||||
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-validation-encaissement.html', {
|
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-validation-encaissement.html', {
|
||||||
actor: actor,
|
actor: actor,
|
||||||
@ -15,12 +15,12 @@ export class DialogValidationEncaissement extends Dialog {
|
|||||||
encaissement: encaissement,
|
encaissement: encaissement,
|
||||||
show: show
|
show: show
|
||||||
});
|
});
|
||||||
const dialog = new DialogValidationEncaissement(html, actor, rollData, armure, encaissement, show, onEncaisser);
|
const dialog = new DialogValidationEncaissement(html, actor, rollData, armure, encaissement, show, attackerId, onEncaisser);
|
||||||
dialog.render(true);
|
dialog.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
constructor(html, actor, rollData, armure, encaissement, show, onEncaisser) {
|
constructor(html, actor, rollData, armure, encaissement, show, attackerId, onEncaisser) {
|
||||||
// Common conf
|
// Common conf
|
||||||
let buttons = {
|
let buttons = {
|
||||||
"valider": { label: "Valider", callback: html => this.onValider() },
|
"valider": { label: "Valider", callback: html => this.onValider() },
|
||||||
@ -48,6 +48,7 @@ export class DialogValidationEncaissement extends Dialog {
|
|||||||
this.armure = armure;
|
this.armure = armure;
|
||||||
this.encaissement = encaissement;
|
this.encaissement = encaissement;
|
||||||
this.show = show;
|
this.show = show;
|
||||||
|
this.attackerId = attackerId;
|
||||||
this.onEncaisser = onEncaisser;
|
this.onEncaisser = onEncaisser;
|
||||||
this.forceDiceResult = {total: encaissement.roll.result };
|
this.forceDiceResult = {total: encaissement.roll.result };
|
||||||
}
|
}
|
||||||
@ -66,6 +67,6 @@ export class DialogValidationEncaissement extends Dialog {
|
|||||||
|
|
||||||
async onValider() {
|
async onValider() {
|
||||||
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: SHOW_DICE, forceDiceResult: this.forceDiceResult});
|
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: SHOW_DICE, forceDiceResult: this.forceDiceResult});
|
||||||
this.onEncaisser(this.encaissement, this.show)
|
this.onEncaisser(this.encaissement, this.show, this.attackerId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,15 +58,6 @@ export class RdDCarac {
|
|||||||
selectedCarac?.label.match(/(Apparence|Force|Agilité|Dextérité|Vue|Ouïe|Odorat-Goût|Empathie|Dérobée|Mêlée|Tir|Lancer)/);
|
selectedCarac?.label.match(/(Apparence|Force|Agilité|Dextérité|Vue|Ouïe|Odorat-Goût|Empathie|Dérobée|Mêlée|Tir|Lancer)/);
|
||||||
}
|
}
|
||||||
|
|
||||||
static isIgnoreEtatGeneral(rollData) {
|
|
||||||
const selectedCarac = rollData.selectedCarac;
|
|
||||||
return !selectedCarac ||
|
|
||||||
rollData.ethylisme ||
|
|
||||||
RdDCarac.isChance(selectedCarac) ||
|
|
||||||
(RdDCarac.isReve(selectedCarac) && !rollData.competence);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static computeTotal(carac, beaute = undefined) {
|
static computeTotal(carac, beaute = undefined) {
|
||||||
const total = Object.values(carac ?? {}).filter(c => !c.derivee)
|
const total = Object.values(carac ?? {}).filter(c => !c.derivee)
|
||||||
.map(it => parseInt(it.value))
|
.map(it => parseInt(it.value))
|
||||||
|
@ -314,8 +314,8 @@ export class RdDRoll extends Dialog {
|
|||||||
HtmlUtility.showControlWhen(this.html.find(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac));
|
HtmlUtility.showControlWhen(this.html.find(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerobee(rollData.selectedCarac));
|
||||||
HtmlUtility.showControlWhen(this.html.find(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac));
|
HtmlUtility.showControlWhen(this.html.find(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac));
|
||||||
HtmlUtility.showControlWhen(this.html.find(".utilisation-moral"), rollData.use.appelAuMoral);
|
HtmlUtility.showControlWhen(this.html.find(".utilisation-moral"), rollData.use.appelAuMoral);
|
||||||
HtmlUtility.showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used);
|
|
||||||
HtmlUtility.showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral);
|
HtmlUtility.showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral);
|
||||||
|
HtmlUtility.showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used);
|
||||||
|
|
||||||
// Mise à jour valeurs
|
// Mise à jour valeurs
|
||||||
this.html.find(".dialog-roll-title").text(this._getTitle(rollData));
|
this.html.find(".dialog-roll-title").text(this._getTitle(rollData));
|
||||||
|
@ -51,7 +51,7 @@ export const referenceAjustements = {
|
|||||||
getValue: (rollData, actor) => RdDBonus.find(rollData.surpriseDefenseur).attaque,
|
getValue: (rollData, actor) => RdDBonus.find(rollData.surpriseDefenseur).attaque,
|
||||||
},
|
},
|
||||||
etat: {
|
etat: {
|
||||||
isUsed: (rollData, actor) => !RdDCarac.isIgnoreEtatGeneral(rollData),
|
isUsed: (rollData, actor) => !RollDataAjustements.isIgnoreEtatGeneral(rollData),
|
||||||
getLabel: (rollData, actor) => 'Etat général',
|
getLabel: (rollData, actor) => 'Etat général',
|
||||||
getValue: (rollData, actor) => actor.getEtatGeneral({ ethylisme: rollData.forceAlcool != undefined })
|
getValue: (rollData, actor) => actor.getEtatGeneral({ ethylisme: rollData.forceAlcool != undefined })
|
||||||
},
|
},
|
||||||
@ -177,4 +177,11 @@ export class RollDataAjustements {
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isIgnoreEtatGeneral(rollData) {
|
||||||
|
const selectedCarac = rollData.selectedCarac;
|
||||||
|
return !selectedCarac ||
|
||||||
|
rollData.ethylisme ||
|
||||||
|
RdDCarac.isChance(selectedCarac) ||
|
||||||
|
(RdDCarac.isReve(selectedCarac) && !rollData.competence);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user