forked from public/foundryvtt-reve-de-dragon
Localisation des blessures en regle optionnelle
This commit is contained in:
@ -415,41 +415,40 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
/* -------------------------------------------- */
|
||||
async encaisser() { await RdDEncaisser.encaisser(this) }
|
||||
|
||||
async encaisserDommages(rollData, attacker = undefined, show = undefined) {
|
||||
async encaisserDommages(rollData, attacker = undefined, attackerToken = undefined, show = undefined) {
|
||||
if (attacker && !await attacker.accorder(this, 'avant-encaissement')) {
|
||||
return;
|
||||
}
|
||||
const armure = await this.computeArmure(rollData);
|
||||
if (ReglesOptionnelles.isUsing('validation-encaissement-gr')) {
|
||||
await this.encaisserDommagesValidationGR(rollData, armure, attacker?.id, show);
|
||||
await this.encaisserDommagesValidationGR(rollData, armure, attackerToken, show);
|
||||
}
|
||||
else {
|
||||
const jet = await RdDUtility.jetEncaissement(rollData, armure, { showDice: SHOW_DICE });
|
||||
await this.$onEncaissement(jet, show, attacker);
|
||||
const jet = await RdDUtility.jetEncaissement(this, rollData, armure, { showDice: SHOW_DICE });
|
||||
await this.$onEncaissement(jet, show, attackerToken)
|
||||
}
|
||||
}
|
||||
|
||||
async encaisserDommagesValidationGR(rollData, armure, attackerId, show) {
|
||||
async encaisserDommagesValidationGR(rollData, armure, attackerToken, show) {
|
||||
if (!game.user.isGM) {
|
||||
RdDBaseActor.remoteActorCall({
|
||||
tokenId: this.token?.id,
|
||||
actorId: this.id,
|
||||
method: 'encaisserDommagesValidationGR',
|
||||
args: [rollData, armure, attackerId, show]
|
||||
});
|
||||
args: [rollData, armure, attackerToken, show]
|
||||
})
|
||||
} else {
|
||||
const attacker = game.actors.get(attackerId);
|
||||
DialogValidationEncaissement.validerEncaissement(this, rollData, armure,
|
||||
jet => this.$onEncaissement(jet, show, attacker));
|
||||
jet => this.$onEncaissement(jet, show, attackerToken));
|
||||
}
|
||||
}
|
||||
|
||||
async $onEncaissement(jet, show, attacker) {
|
||||
await this.onAppliquerJetEncaissement(jet, attacker);
|
||||
async $onEncaissement(jet, show, attackerToken) {
|
||||
await this.onAppliquerJetEncaissement(jet, attackerToken);
|
||||
await this.$afficherEncaissement(jet, show);
|
||||
}
|
||||
|
||||
async onAppliquerJetEncaissement(encaissement, attacker) { }
|
||||
async onAppliquerJetEncaissement(encaissement, attackerToken) { }
|
||||
|
||||
async $afficherEncaissement(encaissement, show) {
|
||||
foundry.utils.mergeObject(encaissement, {
|
||||
|
@ -89,9 +89,9 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
async onAppliquerJetEncaissement(encaissement, attacker) {
|
||||
async onAppliquerJetEncaissement(encaissement, attackerToken) {
|
||||
const santeOrig = foundry.utils.duplicate(this.system.sante);
|
||||
const blessure = await this.ajouterBlessure(encaissement, attacker); // Will update the result table
|
||||
const blessure = await this.ajouterBlessure(encaissement, attackerToken); // Will update the result table
|
||||
const perteVie = await this.santeIncDec("vie", -encaissement.vie);
|
||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, blessure?.isCritique());
|
||||
|
||||
@ -169,7 +169,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ajouterBlessure(encaissement, attacker = undefined) {
|
||||
async ajouterBlessure(encaissement, attackerToken = undefined) {
|
||||
if (encaissement.gravite < 0) return;
|
||||
if (encaissement.gravite > 0) {
|
||||
while (this.countBlessures(it => it.system.gravite == encaissement.gravite) >= RdDItemBlessure.maxBlessures(encaissement.gravite) && encaissement.gravite <= 6) {
|
||||
@ -181,7 +181,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
}
|
||||
}
|
||||
const endActuelle = this.getEnduranceActuelle();
|
||||
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ?? '', attacker);
|
||||
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ?? '', attackerToken);
|
||||
if (blessure.isCritique()) {
|
||||
encaissement.endurance = endActuelle;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ export class RdDEntite extends RdDBaseActorReve {
|
||||
return [STATUSES.StatusComma].includes(effectId);
|
||||
}
|
||||
|
||||
async onAppliquerJetEncaissement(encaissement, attacker) {
|
||||
async onAppliquerJetEncaissement(encaissement, attackerToken) {
|
||||
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance);
|
||||
foundry.utils.mergeObject(encaissement, {
|
||||
resteEndurance: perteEndurance.newValue,
|
||||
|
Reference in New Issue
Block a user