Fix update endurance/vie
Dans certains cas, les valeurs de vie/endurance n'étaient pas mises à jour
This commit is contained in:
parent
48acdaaca6
commit
ce7f5381ca
@ -408,19 +408,18 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async remiseANeuf() {
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: 'Remise à neuf de ' + this.name
|
||||
});
|
||||
await this.supprimerBlessures(it => true);
|
||||
await this.removeEffects(e => e.id != STATUSES.StatusDemiReve);
|
||||
const updates = {
|
||||
await this.update({
|
||||
'system.sante.endurance.value': this.system.sante.endurance.max,
|
||||
'system.sante.vie.value': this.system.sante.vie.max,
|
||||
'system.sante.fatigue.value': 0,
|
||||
'system.compteurs.ethylisme': { value: 1, nb_doses: 0, jet_moral: false }
|
||||
};
|
||||
await this.update(updates);
|
||||
})
|
||||
await this.removeEffects(e => e.id != STATUSES.StatusDemiReve);
|
||||
await this.supprimerBlessures(it => true);
|
||||
await ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: 'Remise à neuf de ' + this.name
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -524,7 +523,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
jet_moral: false,
|
||||
value: value
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1891,8 +1890,8 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
rollData.tache.system.tentatives = rollData.tache.system.nb_jet_succes + rollData.tache.system.nb_jet_echec;
|
||||
|
||||
this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||
this.santeIncDec("fatigue", rollData.tache.system.fatigue);
|
||||
await this.updateEmbeddedDocuments('Item', [rollData.tache]);
|
||||
await this.santeIncDec("fatigue", rollData.tache.system.fatigue);
|
||||
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-tache.html');
|
||||
if (options?.onRollAutomate) {
|
||||
@ -2590,7 +2589,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
for (const armure of armures) {
|
||||
protection += await RdDDice.rollTotal(armure.system.protection.toString());
|
||||
if (dmg > 0 && attackerRoll.dmg.encaisserSpecial != "noarmure") {
|
||||
armure.deteriorerArmure(dmg);
|
||||
await armure.deteriorerArmure(dmg)
|
||||
dmg = 0;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ export class RdDItemArmure extends RdDItem {
|
||||
return "systems/foundryvtt-reve-de-dragon/icons/armes_armures/armure_plaques.webp";
|
||||
}
|
||||
|
||||
deteriorerArmure(dmg) {
|
||||
async deteriorerArmure(dmg) {
|
||||
if (!ReglesOptionnelles.isUsing('deteriorationArmure') || this.system.protection == '0') {
|
||||
return;
|
||||
}
|
||||
@ -23,12 +23,10 @@ export class RdDItemArmure extends RdDItem {
|
||||
protection = this.calculProtectionDeterioree();
|
||||
ChatMessage.create({ content: `Votre armure ${this.name} s'est détériorée, elle protège maintenant de ${protection}` });
|
||||
}
|
||||
this.update({
|
||||
system: {
|
||||
deterioration: deterioration,
|
||||
protection: protection
|
||||
}
|
||||
});
|
||||
await this.update({
|
||||
'system.deterioration': deterioration,
|
||||
'system.protection': protection
|
||||
})
|
||||
}
|
||||
|
||||
calculProtectionDeterioree() {
|
||||
|
@ -30,7 +30,7 @@ export class RdDItemBlessure extends RdDItem {
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
this.system.label = this.getLabelGravite()
|
||||
this.system.label = RdDItemBlessure.getLabelGravite(this.system.gravite)
|
||||
}
|
||||
|
||||
static prepareTacheSoin(gravite) {
|
||||
@ -43,29 +43,32 @@ export class RdDItemBlessure extends RdDItem {
|
||||
}
|
||||
|
||||
static async applyFullBlessure(actor, gravite) {
|
||||
const definition = RdDItemBlessure.getDefinition(gravite)
|
||||
const definition = foundry.utils.duplicate(RdDItemBlessure.getDefinition(gravite))
|
||||
|
||||
let lostEndurance = 0
|
||||
let lostVie = 0
|
||||
if (definition.endurance) {
|
||||
lostEndurance = new Roll(definition.endurance)
|
||||
await lostEndurance.roll();
|
||||
actor.santeIncDec("endurance", -Number(lostEndurance.total));
|
||||
}
|
||||
if (definition.vie) {
|
||||
lostVie = definition.vie
|
||||
actor.santeIncDec("vie", definition.vie)
|
||||
await actor.santeIncDec("vie", definition.vie)
|
||||
}
|
||||
const lostEndurance = await RdDItemBlessure.rollLostEndurance(definition.endurance)
|
||||
if (lostEndurance) {
|
||||
await actor.santeIncDec("endurance", -Number(lostEndurance));
|
||||
}
|
||||
|
||||
await this.createBlessure(actor, gravite)
|
||||
|
||||
ChatMessage.create({
|
||||
content: `Blessure ${definition.label} appliquée à ${actor.name}`+
|
||||
`<br>Perte d'endurance : ${lostEndurance}`+
|
||||
`<br>Perte de Vie : ${lostVie}`,
|
||||
//TODO: hbs
|
||||
content: `Blessure ${definition.label} appliquée à ${actor.name}<br>Perte d'endurance : ${lostEndurance} (${definition.endurance})<br>Perte de Vie : ${definition.vie}`,
|
||||
whisper: ChatUtility.getOwners(actor)
|
||||
});
|
||||
actor.sheet?.render()
|
||||
}
|
||||
|
||||
static async rollLostEndurance(formula) {
|
||||
if (formula) {
|
||||
const roll = new Roll(formula)
|
||||
await roll.evaluate()
|
||||
return roll.total
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
static async createBlessure(actor, gravite, localisation = '', attackerToken) {
|
||||
@ -125,10 +128,10 @@ export class RdDItemBlessure extends RdDItem {
|
||||
}
|
||||
if (this.system.gravite > 0) {
|
||||
const update = { system: { premierssoins: { bonus: 0 }, soinscomplets: { bonus: 0 } } }
|
||||
const gravite = this.system.gravite;
|
||||
const graviteMoindre = gravite - 2;
|
||||
const gravite = this.system.gravite
|
||||
const graviteMoindre = gravite - 2
|
||||
const moindres = blessures.filter(it => it.system.gravite == graviteMoindre, 'blessures').length
|
||||
const label = this.getLabelGravite();
|
||||
const label = RdDItemBlessure.getLabelGravite(this.system.gravite)
|
||||
|
||||
let rolled = await actor.jetRecuperationConstitution(this.system.soinscomplets.bonus, message);
|
||||
|
||||
@ -158,7 +161,7 @@ export class RdDItemBlessure extends RdDItem {
|
||||
}
|
||||
|
||||
peutRetrograder(graviteMoindre, moindres) {
|
||||
return moindres < RdDItemBlessure.getDefinition(graviteMoindre).max
|
||||
return moindres < RdDItemBlessure.maxBlessures(graviteMoindre)
|
||||
}
|
||||
|
||||
async calculerFinPeriodeTemporel(debut) {
|
||||
@ -182,16 +185,16 @@ export class RdDItemBlessure extends RdDItem {
|
||||
return `systems/foundryvtt-reve-de-dragon/icons/sante/${soins ? 'blessure-soins' : img}.webp`
|
||||
}
|
||||
|
||||
getLabelGravite() {
|
||||
return RdDItemBlessure.getDefinition(this.system.gravite).label
|
||||
static getLabelGravite(gravite) {
|
||||
return definitionsBlessures.find(it => it.gravite >= gravite).label
|
||||
}
|
||||
|
||||
static getDefinition(gravite) {
|
||||
return definitionsBlessures.sort(Misc.ascending(it => it.gravite))
|
||||
.find(it => it.gravite >= gravite);
|
||||
return definitionsBlessures.find(it => it.gravite >= gravite)
|
||||
}
|
||||
|
||||
static maxBlessures(gravite) {
|
||||
return RdDItemBlessure.getDefinition(gravite).max
|
||||
return definitionsBlessures.find(it => it.gravite >= gravite).max
|
||||
}
|
||||
|
||||
isContusion() {
|
||||
@ -216,7 +219,7 @@ export class RdDItemBlessure extends RdDItem {
|
||||
`<b>Heure et Date</b>: ${new RdDTimestamp(this.system.temporel.debut).formatDateHeure()}`,
|
||||
RdDItem.propertyIfDefined('Blessé', this.parent?.name, this.parent),
|
||||
`<b>Localisation</b>: ${this.system.localisation}`,
|
||||
`<b>Gravité</b>: ${RdDItemBlessure.getDefinition(this.system.gravite).label}`,
|
||||
`<b>Gravité</b>: ${this.system.label}`,
|
||||
`<b>Difficulté des soins</b>: ${this.system.difficulte}`,
|
||||
(this.system.soinscomplets.done ?
|
||||
`<b>Bonus soins complets</b>: ${this.system.soinscomplets.bonus}` :
|
||||
|
@ -1,41 +1,47 @@
|
||||
<div class="flex-group-center header-compteurs">
|
||||
<ul>
|
||||
<li>
|
||||
<label class="compteur">
|
||||
<a class="jet-vie" data-tooltip="Faire un jet de vie">Vie</a>
|
||||
<div class="compteur">
|
||||
<label for="system.sante.vie.value">
|
||||
<a class="jet-vie" data-tooltip="Faire un jet de vie">Vie</a>
|
||||
</label>
|
||||
<a class="vie-moins"><i class="fa-solid fa-square-minus"></i></a>
|
||||
<input class="resource-content" type="text" name="system.sante.vie.value" value="{{system.sante.vie.value}}" data-dtype="Number"/>
|
||||
<span>/ {{system.sante.vie.max}}</span>
|
||||
<a class="vie-plus"><i class="fa-solid fa-square-plus"></i></a>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label class="compteur">
|
||||
<a class="jet-endurance" data-tooltip="Faire un jet d'endurance pour ne pas être sonné">Endurance</a>
|
||||
<div class="compteur">
|
||||
<label for="system.sante.endurance.value">
|
||||
<a class="jet-endurance" data-tooltip="Faire un jet d'endurance pour ne pas être sonné">Endurance</a>
|
||||
</label>
|
||||
<a class="endurance-moins"><i class="fa-solid fa-square-minus"></i></a>
|
||||
<input class="resource-content" type="text" name="system.sante.endurance.value" value="{{system.sante.endurance.value}}" data-dtype="Number"/>
|
||||
<span>/ {{system.sante.endurance.max}}</span>
|
||||
<a class="endurance-plus"><i class="fa-solid fa-square-plus"></i></a>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label class="appliquerFatigue compteur tooltip">
|
||||
<span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span>
|
||||
Fatigue ({{calc.fatigue.malus}})
|
||||
<div class="appliquerFatigue compteur tooltip">
|
||||
<label for="system.sante.fatigue.value">Fatigue ({{calc.fatigue.malus}})</label>
|
||||
<div class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</div>
|
||||
<a class="fatigue-moins"><i class="fa-solid fa-square-minus"></i></a>
|
||||
<input class="resource-content" type="text" name="system.sante.fatigue.value" value="{{system.sante.fatigue.value}}" data-dtype="Number" />
|
||||
<span>/ {{system.sante.fatigue.max}}</span>
|
||||
<a class="fatigue-plus"><i class="fa-solid fa-square-plus"></i></a>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label class="compteur">
|
||||
<span class="roll-reve-actuel" data-tooltip="Faire un jet de Rêve actuel (ou jet de résistance)"><a>Rêve</a></span>
|
||||
<div class="compteur">
|
||||
<label for="system.reve.reve.value">
|
||||
<a class="roll-reve-actuel" data-tooltip="Faire un jet de Rêve actuel (ou jet de résistance)">Rêve</a>
|
||||
</label>
|
||||
<a class="ptreve-actuel-moins"><i class="fa-solid fa-square-minus"></i></a>
|
||||
<input class="resource-content" class="pointsreve-value" type="text" name="system.reve.reve.value" value="{{system.reve.reve.value}}" data-dtype="Number" />
|
||||
<span>/ {{system.reve.seuil.value}}</span>
|
||||
<a class="ptreve-actuel-plus"><i class="fa-solid fa-square-plus"></i></a>
|
||||
</label>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user