forked from public/foundryvtt-reve-de-dragon
Utilisation d'async/await dans les listeners
Sans async await dans les feuilles, la feuille n'est pas toujours mise à jour, laissant visible des informations obsoletes
This commit is contained in:
101
module/actor.js
101
module/actor.js
@ -757,7 +757,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
expérience requise: ${xpRequis}
|
||||
niveau : ${fromNiveau}
|
||||
archétype : ${competence.system.niveau_archetype}`);
|
||||
return;
|
||||
return
|
||||
}
|
||||
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis));
|
||||
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0;
|
||||
@ -810,7 +810,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
await competence.update({ 'system.xp': toXp });
|
||||
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true);
|
||||
if (toXp > fromXp) {
|
||||
RdDUtility.checkThanatosXP(idOrName);
|
||||
RdDUtility.checkThanatosXP(competence)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -824,7 +824,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
await competence.update({ 'system.xp_sort': toXpSort });
|
||||
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true);
|
||||
if (toXpSort > fromXpSort) {
|
||||
RdDUtility.checkThanatosXP(idOrName);
|
||||
RdDUtility.checkThanatosXP(competence)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1201,8 +1201,8 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
new RdDRollDialogEthylisme(html, rollData, this, r => this.saouler(r.forceAlcool)).render(true);
|
||||
}
|
||||
|
||||
async mangerNourriture(item, onActionItem) {
|
||||
return (await DialogConsommer.create(this, item, onActionItem)).render(true);
|
||||
async mangerNourriture(item) {
|
||||
return (await DialogConsommer.create(this, item)).render(true);
|
||||
}
|
||||
|
||||
async actionLire(item) {
|
||||
@ -1844,7 +1844,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
[tacheData.system.carac]: foundry.utils.duplicate(this.system.carac[tacheData.system.carac])
|
||||
}
|
||||
},
|
||||
callbackAction: r => this._tacheResult(r, options)
|
||||
callbackAction: async r => await this._tacheResult(r, options)
|
||||
});
|
||||
}
|
||||
|
||||
@ -1874,7 +1874,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _rollArt(artData, selected, oeuvre, callbackAction = r => this._resultArt(r)) {
|
||||
async _rollArt(artData, selected, oeuvre, callbackAction = async r => await this._resultArt(r)) {
|
||||
oeuvre.system.niveau = oeuvre.system.niveau ?? 0;
|
||||
foundry.utils.mergeObject(artData,
|
||||
{
|
||||
@ -2178,7 +2178,7 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
label: 'Appel à la chance',
|
||||
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
|
||||
rollData: { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' },
|
||||
callbackAction: r => this._appelChanceResult(r, onSuccess, onEchec)
|
||||
callbackAction: async r => await this._appelChanceResult(r, onSuccess, onEchec)
|
||||
});
|
||||
}
|
||||
|
||||
@ -2807,25 +2807,25 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotionSoin(potionData) {
|
||||
potionData.alias = this.name;
|
||||
potionData.supprimer = true;
|
||||
async consommerPotionSoin(potion) {
|
||||
potion.alias = this.name;
|
||||
potion.supprimer = true;
|
||||
|
||||
if (potionData.system.magique) {
|
||||
if (potion.system.magique) {
|
||||
// Gestion de la résistance:
|
||||
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potionData.rolled.isEchec) {
|
||||
potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potion.rolled.isEchec) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
potionData.guerisonData = await this.buildPotionGuerisonList(potionData.system.puissance);
|
||||
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5;
|
||||
potion.guerisonData = await this.buildPotionGuerisonList(potion.system.puissance);
|
||||
potion.guerisonMinutes = potion.guerisonData.pointsConsommes * 5;
|
||||
}
|
||||
}
|
||||
if (!potionData.system.magique || potionData.rolled.isSuccess) {
|
||||
await this.setBonusPotionSoin(potionData.system.herbebonus);
|
||||
if (!potion.system.magique || potion.rolled.isSuccess) {
|
||||
await this.setBonusPotionSoin(potion.system.herbebonus);
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-soin.html`, potionData)
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-soin.html`, potion)
|
||||
});
|
||||
}
|
||||
|
||||
@ -2834,35 +2834,35 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotionRepos(potionData) {
|
||||
potionData.alias = this.name;
|
||||
potionData.supprimer = true;
|
||||
async consommerPotionRepos(potion) {
|
||||
potion.alias = this.name;
|
||||
potion.supprimer = true;
|
||||
|
||||
if (potionData.system.magique) {
|
||||
if (potion.system.magique) {
|
||||
// Gestion de la résistance:
|
||||
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potionData.rolled.isEchec) {
|
||||
potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potion.rolled.isEchec) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
let fatigueActuelle = this.getFatigueActuelle();
|
||||
potionData.caseFatigueReel = Math.min(fatigueActuelle, potionData.system.puissance);
|
||||
potionData.guerisonDureeUnite = (potionData.system.reposalchimique) ? "rounds" : "minutes";
|
||||
potionData.guerisonDureeValue = (potionData.system.reposalchimique) ? potionData.caseFatigueReel : potionData.caseFatigueReel * 5;
|
||||
potionData.aphasiePermanente = false;
|
||||
if (potionData.system.reposalchimique) {
|
||||
potion.caseFatigueReel = Math.min(fatigueActuelle, potion.system.puissance);
|
||||
potion.guerisonDureeUnite = (potion.system.reposalchimique) ? "rounds" : "minutes";
|
||||
potion.guerisonDureeValue = (potion.system.reposalchimique) ? potion.caseFatigueReel : potion.caseFatigueReel * 5;
|
||||
potion.aphasiePermanente = false;
|
||||
if (potion.system.reposalchimique) {
|
||||
let chanceAphasie = await RdDDice.rollTotal("1d100");
|
||||
if (chanceAphasie <= potionData.system.pr) {
|
||||
potionData.aphasiePermanente = true;
|
||||
if (chanceAphasie <= potion.system.pr) {
|
||||
potion.aphasiePermanente = true;
|
||||
}
|
||||
}
|
||||
await this.santeIncDec("fatigue", -potionData.caseFatigueReel);
|
||||
await this.santeIncDec("fatigue", -potion.caseFatigueReel);
|
||||
}
|
||||
}
|
||||
if (!potionData.system.magique || potionData.rolled.isSuccess) {
|
||||
this.bonusRepos = potionData.system.herbebonus;
|
||||
if (!potion.system.magique || potion.rolled.isSuccess) {
|
||||
this.bonusRepos = potion.system.herbebonus;
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potionData)
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-repos.html`, potion)
|
||||
});
|
||||
}
|
||||
|
||||
@ -2902,35 +2902,32 @@ export class RdDActor extends RdDBaseActorSang {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotionGenerique(potionData) {
|
||||
potionData.alias = this.name;
|
||||
async consommerPotionGenerique(potion) {
|
||||
potion.alias = this.name;
|
||||
|
||||
if (potionData.system.magique) {
|
||||
if (potion.system.magique) {
|
||||
// Gestion de la résistance:
|
||||
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potionData.rolled.isEchec) {
|
||||
potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
|
||||
if (potion.rolled.isEchec) {
|
||||
await this.reveActuelIncDec(-1);
|
||||
}
|
||||
}
|
||||
ChatMessage.create({
|
||||
whisper: ChatUtility.getOwners(this),
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potionData)
|
||||
content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-consommer-potion-generique.html`, potion)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async consommerPotion(potion, onActionItem = async () => { }) {
|
||||
const potionData = potion
|
||||
|
||||
if (potionData.system.categorie.includes('Soin')) {
|
||||
this.consommerPotionSoin(potionData);
|
||||
} else if (potionData.system.categorie.includes('Repos')) {
|
||||
this.consommerPotionRepos(potionData);
|
||||
async consommerPotion(potion) {
|
||||
if (potion.system.categorie.includes('Soin')) {
|
||||
this.consommerPotionSoin(potion);
|
||||
} else if (potion.system.categorie.includes('Repos')) {
|
||||
this.consommerPotionRepos(potion);
|
||||
} else {
|
||||
this.consommerPotionGenerique(potionData);
|
||||
this.consommerPotionGenerique(potion);
|
||||
}
|
||||
await this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potionData.supprimer });
|
||||
await onActionItem()
|
||||
await this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potion.supprimer });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
Reference in New Issue
Block a user