chgt endurance ne rend plus inconscient

This commit is contained in:
Vincent Vandemeulebrouck 2022-09-19 20:15:01 +02:00
parent 5402508b26
commit 6d06c96497
2 changed files with 30 additions and 35 deletions

View File

@ -368,7 +368,7 @@ export class RdDActorSheet extends ActorSheet {
}); });
html.find('.enlever-tous-effets').click(async event => { html.find('.enlever-tous-effets').click(async event => {
if (game.user.isGM) { if (game.user.isGM) {
this.actor.enleverTousLesEffets(); await this.actor.removeEffects();
} }
}); });
html.find('.conteneur-name a').click(async event => { html.find('.conteneur-name a').click(async event => {

View File

@ -44,6 +44,7 @@ const POSSESSION_SANS_DRACONIC = {
} }
}; };
const PAS_DE_BLESSURE = { "active": false, "psdone": false, "scdone": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": "" };
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
@ -545,7 +546,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
_supprimerBlessure(blessure) { _supprimerBlessure(blessure) {
mergeObject(blessure, { "active": false, "psdone": false, "scdone": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": "" }); mergeObject(blessure, PAS_DE_BLESSURE);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -588,39 +589,30 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async remiseANeuf() { async remiseANeuf() {
let message = {
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
content: "Remise à neuf de " + this.name
};
if (this.isEntite([ENTITE_NONINCARNE])) { if (this.isEntite([ENTITE_NONINCARNE])) {
return; return;
} }
if (this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) { ChatMessage.create({
await this.santeIncDec("endurance", this.system.sante.endurance.max - this.system.sante.endurance.value); whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
} content: 'Remise à neuf de ' + this.name
else { });
const updates = {
'system.sante.endurance.value' : this.system.sante.endurance.max
};
if (!this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) {
if (this.system.blessures) { if (this.system.blessures) {
const blessures = duplicate(this.system.blessures); updates['system.blessures.legeres.liste'] = [PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE, PAS_DE_BLESSURE];
for (let listeBlessures of [blessures.legeres.liste, blessures.graves.liste, blessures.critiques.liste]) { updates['system.blessures.graves.liste'] = [PAS_DE_BLESSURE, PAS_DE_BLESSURE];
for (let blessure of listeBlessures) { updates['system.blessures.critiques.liste'] = [PAS_DE_BLESSURE];
this._supprimerBlessure(blessure);
}
}
await this.update({ "system.blessures": blessures });
} }
updates['system.sante.vie.value'] = this.system.sante.vie.max;
updates['system.sante.fatigue.value'] = 0;
if (this.isPersonnage()) { if (this.isPersonnage()) {
await this.setEthylisme(1); updates['system.compteurs.ethylisme'] = { value:1, nb_doses: 0, jet_moral: false};
}
await this.santeIncDec("vie", this.system.sante.vie.max - this.system.sante.vie.value);
await this.santeIncDec("endurance", this.system.sante.endurance.max - this.system.sante.endurance.value);
if (ReglesOptionelles.isUsing("appliquer-fatigue") && this.system.sante.fatigue) {
await this.update({ "system.sante.fatigue.value": 0 });
} }
} }
ChatMessage.create(message); await this.update(updates);
this.sheet.render(true); await this.removeEffects(e => e.flags.core.statusId !== STATUSES.StatusDemiReve);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -4101,8 +4093,8 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getEffects() { getEffects(filter = e => true) {
return this.getEmbeddedCollection("ActiveEffect"); return this.getEmbeddedCollection("ActiveEffect").filter(filter);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -4116,10 +4108,12 @@ export class RdDActor extends Actor {
return; return;
} }
console.log("setEffect", statusId, status) console.log("setEffect", statusId, status)
await this.removeEffect(statusId); const effect = this.getEffect(statusId);
const effect = StatusEffects.status(statusId); if (!status && effect){
if (effect) { await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
await this.createEmbeddedDocuments("ActiveEffect", [effect]); }
if (status && !effect ) {
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.status(statusId)]);
} }
} }
@ -4131,9 +4125,10 @@ export class RdDActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
enleverTousLesEffets() { async removeEffects(filter = e => true) {
if (game.user.isGM) { if (game.user.isGM) {
this.deleteEmbeddedDocuments('ActiveEffect', this.getEffects().map(it => it.id)); const ids = this.getEffects(filter).map(it => it.id);
await this.deleteEmbeddedDocuments('ActiveEffect', ids);
} }
} }