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:
Vincent Vandemeulebrouck 2025-01-24 20:12:34 +01:00
parent 24518642a7
commit 3d49a3de11
20 changed files with 223 additions and 266 deletions

View File

@ -126,77 +126,73 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
}) })
this.html.find('.show-hide-competences').click(async event => { this.html.find('.show-hide-competences').click(async event => {
this.options.showCompNiveauBase = !this.options.showCompNiveauBase; this.options.showCompNiveauBase = !this.options.showCompNiveauBase
this.render(true); this.render(true)
}); });
this.html.find('.button-tmr-visu').click(async event => this.actor.displayTMR("visu")) this.html.find('.button-tmr-visu').click(async event => await this.actor.displayTMR("visu"))
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('.sheet-possession-attack').click(async event => { this.html.find('.sheet-possession-attack').click(async event => {
const poss = RdDSheetUtility.getItem(event, this.actor) const poss = RdDSheetUtility.getItem(event, this.actor)
this.actor.conjurerPossession(poss) await this.actor.conjurerPossession(poss)
}) })
this.html.find('.subacteur-coeur-toggle a').click(async event => { this.html.find('.subacteur-coeur-toggle a').click(async event => {
const subActorIdactorId = RdDSheetUtility.getEventItemData(event, 'subactor-id') const subActorIdactorId = RdDSheetUtility.getEventItemData(event, 'subactor-id')
const coeurNombre = $(event.currentTarget).data('numero-coeur') const coeurNombre = $(event.currentTarget).data('numero-coeur')
RdDCoeur.toggleSubActeurCoeur(this.actor.id, subActorIdactorId, coeurNombre) await RdDCoeur.toggleSubActeurCoeur(this.actor.id, subActorIdactorId, coeurNombre)
}) })
this.html.find('.subacteur-tendre-moment').click(async event => { this.html.find('.subacteur-tendre-moment').click(async event => {
const subActorId = RdDSheetUtility.getEventItemData(event, 'subactor-id') const subActorId = RdDSheetUtility.getEventItemData(event, 'subactor-id')
RdDCoeur.startSubActeurTendreMoment(this.actor.id, subActorId) await RdDCoeur.startSubActeurTendreMoment(this.actor.id, subActorId)
}) })
this.html.find('.subacteur-delete').click(async event => { this.html.find('.subacteur-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event); const li = RdDSheetUtility.getEventElement(event);
const subActorId = li.data("subactor-id"); const subActorId = li.data("subactor-id");
this.deleteSubActeur(subActorId, li); this.deleteSubActeur(subActorId, li);
}) })
this.html.find("input.derivee-value[name='system.compteurs.stress.value']").change(async event => { this.html.find("input.derivee-value[name='system.compteurs.stress.value']").change(async event =>
this.actor.updateCompteurValue("stress", parseInt(event.target.value)); await this.actor.updateCompteurValue("stress", parseInt(event.target.value))
}); );
this.html.find("input.derivee-value[name='system.compteurs.experience.value']").change(async event => { this.html.find("input.derivee-value[name='system.compteurs.experience.value']").change(async event =>
this.actor.updateCompteurValue("experience", parseInt(event.target.value)); await this.actor.updateCompteurValue("experience", parseInt(event.target.value))
}); );
this.html.find('.creer-tache').click(async event => this.createEmptyTache()); this.html.find('.creer-tache').click(async event => await this.createEmptyTache());
this.html.find('.creer-une-oeuvre').click(async event => this.selectTypeOeuvreToCreate()); this.html.find('.creer-une-oeuvre').click(async event => await this.selectTypeOeuvreToCreate());
this.html.find('.creer-tache-blessure-legere').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 2)); this.html.find('.creer-tache-blessure-legere').click(async event => await RdDItemBlessure.createTacheSoinBlessure(this.actor, 2));
this.html.find('.creer-tache-blessure-grave').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 4)); this.html.find('.creer-tache-blessure-grave').click(async event => await RdDItemBlessure.createTacheSoinBlessure(this.actor, 4));
this.html.find('.creer-tache-blessure-critique').click(async event => RdDItemBlessure.createTacheSoinBlessure(this.actor, 6)); this.html.find('.creer-tache-blessure-critique').click(async event => await RdDItemBlessure.createTacheSoinBlessure(this.actor, 6));
this.html.find('.blessure-premierssoins-done').change(async event => { this.html.find('.blessure-premierssoins-done').change(async event => {
const blessure = this.getBlessure(event); await this.getBlessure(event)?.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } });
await blessure?.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } });
}); });
this.html.find('.blessure-soinscomplets-done').change(async event => { this.html.find('.blessure-soinscomplets-done').change(async event => {
const blessure = this.getBlessure(event); await this.getBlessure(event)?.setSoinsBlessure({ soinscomplets: { done: event.currentTarget.checked } })
await blessure?.setSoinsBlessure({ soinscomplets: { done: event.currentTarget.checked } })
}); });
this.html.find('.blessure-premierssoins-bonus').change(async event => { this.html.find('.blessure-premierssoins-bonus').change(async event => {
const blessure = this.getBlessure(event); await this.getBlessure(event)?.setSoinsBlessure({ premierssoins: { bonus: Number(event.currentTarget.value) } })
await blessure?.setSoinsBlessure({ premierssoins: { bonus: Number(event.currentTarget.value) } })
}); });
this.html.find('.blessure-soinscomplets-bonus').change(async event => { this.html.find('.blessure-soinscomplets-bonus').change(async event => {
const blessure = this.getBlessure(event); await this.getBlessure(event)?.setSoinsBlessure({ soinscomplets: { bonus: Number(event.currentTarget.value) } })
await blessure?.setSoinsBlessure({ soinscomplets: { bonus: Number(event.currentTarget.value) } })
}); });
this.html.find('.roll-chance-actuelle').click(async event => this.actor.rollCarac('chance-actuelle')) this.html.find('.roll-chance-actuelle').click(async event => await this.actor.rollCarac('chance-actuelle'))
this.html.find('.button-appel-chance').click(async event => this.actor.rollAppelChance()) this.html.find('.button-appel-chance').click(async event => await this.actor.rollAppelChance())
this.html.find('[name="jet-astrologie"]').click(async event => this.actor.astrologieNombresAstraux()) this.html.find('[name="jet-astrologie"]').click(async event => await this.actor.astrologieNombresAstraux())
this.html.find('.action-tache').click(async event => this.actor.rollTache(RdDSheetUtility.getItemId(event))) this.html.find('.action-tache').click(async event => await this.actor.rollTache(RdDSheetUtility.getItemId(event)))
this.html.find('.meditation-label a').click(async event => this.actor.rollMeditation(RdDSheetUtility.getItemId(event))) this.html.find('.meditation-label a').click(async event => await this.actor.rollMeditation(RdDSheetUtility.getItemId(event)))
this.html.find('.action-chant').click(async event => this.actor.rollChant(RdDSheetUtility.getItemId(event))) this.html.find('.action-chant').click(async event => await this.actor.rollChant(RdDSheetUtility.getItemId(event)))
this.html.find('.action-danse').click(async event => this.actor.rollDanse(RdDSheetUtility.getItemId(event))) this.html.find('.action-danse').click(async event => await this.actor.rollDanse(RdDSheetUtility.getItemId(event)))
this.html.find('.action-musique').click(async event => this.actor.rollMusique(RdDSheetUtility.getItemId(event))) this.html.find('.action-musique').click(async event => await this.actor.rollMusique(RdDSheetUtility.getItemId(event)))
this.html.find('.action-oeuvre').click(async event => this.actor.rollOeuvre(RdDSheetUtility.getItemId(event))) this.html.find('.action-oeuvre').click(async event => await this.actor.rollOeuvre(RdDSheetUtility.getItemId(event)))
this.html.find('.action-jeu').click(async event => this.actor.rollJeu(RdDSheetUtility.getItemId(event))) this.html.find('.action-jeu').click(async event => await this.actor.rollJeu(RdDSheetUtility.getItemId(event)))
this.html.find('.action-recettecuisine').click(async event => this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event))) this.html.find('.action-recettecuisine').click(async event => await this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event)))
this.html.find('.description-aleatoire').click(async event => new AppPersonnageAleatoire(this.actor).render(true)) this.html.find('.description-aleatoire').click(async event => new AppPersonnageAleatoire(this.actor).render(true))
if (game.user.isGM) { if (game.user.isGM) {
@ -212,16 +208,16 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
await this.actor.deleteExperienceLog(0, key + 1); await this.actor.deleteExperienceLog(0, key + 1);
}); });
// Boutons spéciaux MJs // Boutons spéciaux MJs
this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ")) this.html.find('.forcer-tmr-aleatoire').click(async event => await this.actor.reinsertionAleatoire("Action MJ"))
this.html.find('.don-de-haut-reve').click(async event => this.actor.addDonDeHautReve()) this.html.find('.don-de-haut-reve').click(async event => await this.actor.addDonDeHautReve())
this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible()) this.html.find('.afficher-tmr').click(async event => await this.actor.changeTMRVisible())
} }
// Points de reve actuel // Points de reve actuel
this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', {resistance:true})) this.html.find('.roll-reve-actuel').click(async event => await this.actor.rollCarac('reve-actuel', { resistance: true }))
this.html.find('.action-empoignade').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor))) this.html.find('.action-empoignade').click(async event => await RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor)))
this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence')) this.html.find('.roll-arme').click(async event => await this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence'))
// Initiative pour l'arme // Initiative pour l'arme
this.html.find('.roll-init-arme').click(async event => { this.html.find('.roll-init-arme').click(async event => {
@ -234,30 +230,30 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
}) })
// Display TMR // Display TMR
this.html.find('.button-tmr').click(async event => this.actor.displayTMR("normal")) this.html.find('.button-tmr').click(async event => await this.actor.displayTMR("normal"))
this.html.find('.button-tmr-rapide').click(async event => this.actor.displayTMR("rapide")) this.html.find('.button-tmr-rapide').click(async event => await this.actor.displayTMR("rapide"))
this.html.find('.button-repos').click(async event => await this.actor.repos()) this.html.find('.button-repos').click(async event => await this.actor.repos())
this.html.find('.carac-xp-augmenter').click(async event => this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", ""))) this.html.find('.carac-xp-augmenter').click(async event => await this.actor.updateCaracXPAuto(event.currentTarget.name.replace("augmenter.", "")))
this.html.find('.competence-xp-augmenter').click(async event => this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event))) this.html.find('.competence-xp-augmenter').click(async event => await this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event)))
this.html.find('.competence-stress-augmenter').click(async event => this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event))) this.html.find('.competence-stress-augmenter').click(async event => await this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event)))
if (this.options.vueDetaillee) { if (this.options.vueDetaillee) {
// On carac change // On carac change
this.html.find('input.carac-xp').change(async event => { this.html.find('input.carac-xp').change(async event => {
let caracName = event.currentTarget.name.replace(".xp", "").replace("system.carac.", ""); let caracName = event.currentTarget.name.replace(".xp", "").replace("system.carac.", "")
this.actor.updateCaracXP(caracName, parseInt(event.target.value)); await this.actor.updateCaracXP(caracName, parseInt(event.target.value))
}); })
// On competence xp change // On competence xp change
this.html.find('input.competence-xp').change(async event => { this.html.find('input.competence-xp').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value
this.actor.updateCompetenceXP(compName, parseInt(event.target.value)); await this.actor.updateCompetenceXP(compName, parseInt(event.target.value))
}); })
this.html.find('input.competence-xp-sort').change(async event => { this.html.find('input.competence-xp-sort').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value
this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value)); await this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value))
}); })
this.html.find('.toggle-archetype').click(async event => { this.html.find('.toggle-archetype').click(async event => {
this.options.vueArchetype = !this.options.vueArchetype; this.options.vueArchetype = !this.options.vueArchetype;
@ -266,27 +262,27 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
// On competence archetype change // On competence archetype change
this.html.find('.competence-archetype').change(async event => { this.html.find('.competence-archetype').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value)); await this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value));
}); });
this.html.find('.nouvelle-incarnation').click(async event => this.actor.nouvelleIncarnation()) this.html.find('.nouvelle-incarnation').click(async event => await this.actor.nouvelleIncarnation())
} }
// On pts de reve change // On pts de reve change
this.html.find('.pointsreve-value').change(async event => this.actor.update({ "system.reve.reve.value": event.currentTarget.value })) this.html.find('.pointsreve-value').change(async event => await this.actor.update({ "system.reve.reve.value": event.currentTarget.value }))
this.html.find('.seuil-reve-value').change(async event => this.actor.setPointsDeSeuil(event.currentTarget.value)) this.html.find('.seuil-reve-value').change(async event => await this.actor.setPointsDeSeuil(event.currentTarget.value))
this.html.find('.stress-test').click(async event => this.actor.transformerStress()) this.html.find('.stress-test').click(async event => await this.actor.transformerStress())
this.html.find('.moral-malheureux').click(async event => this.actor.jetDeMoral('malheureuse')) this.html.find('.moral-malheureux').click(async event => await this.actor.jetDeMoral('malheureuse'))
this.html.find('.moral-neutre').click(async event => this.actor.jetDeMoral('neutre')) this.html.find('.moral-neutre').click(async event => await this.actor.jetDeMoral('neutre'))
this.html.find('.moral-heureux').click(async event => this.actor.jetDeMoral('heureuse')) this.html.find('.moral-heureux').click(async event => await this.actor.jetDeMoral('heureuse'))
this.html.find('.button-ethylisme').click(async event => this.actor.jetEthylisme()) this.html.find('.button-ethylisme').click(async event => await this.actor.jetEthylisme())
this.html.find('.ptreve-actuel-plus').click(async event => this.actor.reveActuelIncDec(1)) this.html.find('.ptreve-actuel-plus').click(async event => await this.actor.reveActuelIncDec(1))
this.html.find('.ptreve-actuel-moins').click(async event => this.actor.reveActuelIncDec(-1)) this.html.find('.ptreve-actuel-moins').click(async event => await this.actor.reveActuelIncDec(-1))
this.html.find('.chance-actuelle-plus').click(async event => this.actor.chanceActuelleIncDec(1)) this.html.find('.chance-actuelle-plus').click(async event => await this.actor.chanceActuelleIncDec(1))
this.html.find('.chance-actuelle-moins').click(async event => this.actor.chanceActuelleIncDec(-1)) this.html.find('.chance-actuelle-moins').click(async event => await this.actor.chanceActuelleIncDec(-1))
this.html.find('.fatigue-plus').click(async event => this.actor.santeIncDec("fatigue", 1)) this.html.find('.fatigue-plus').click(async event => await this.actor.santeIncDec("fatigue", 1))
this.html.find('.fatigue-moins').click(async event => this.actor.santeIncDec("fatigue", -1)) this.html.find('.fatigue-moins').click(async event => await this.actor.santeIncDec("fatigue", -1))
} }
getBlessure(event) { getBlessure(event) {

View File

@ -757,7 +757,7 @@ export class RdDActor extends RdDBaseActorSang {
expérience requise: ${xpRequis} expérience requise: ${xpRequis}
niveau : ${fromNiveau} niveau : ${fromNiveau}
archétype : ${competence.system.niveau_archetype}`); archétype : ${competence.system.niveau_archetype}`);
return; return
} }
const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis)); const xpUtilise = Math.max(0, Math.min(fromXpStress, xpRequis));
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0; const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0;
@ -810,7 +810,7 @@ export class RdDActor extends RdDBaseActorSang {
await competence.update({ 'system.xp': toXp }); await competence.update({ 'system.xp': toXp });
await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true); await ExperienceLog.add(this, XP_TOPIC.XP, fromXp, toXp, competence.name, true);
if (toXp > fromXp) { 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 competence.update({ 'system.xp_sort': toXpSort });
await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true); await ExperienceLog.add(this, XP_TOPIC.XPSORT, fromXpSort, toXpSort, competence.name, true);
if (toXpSort > fromXpSort) { 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); new RdDRollDialogEthylisme(html, rollData, this, r => this.saouler(r.forceAlcool)).render(true);
} }
async mangerNourriture(item, onActionItem) { async mangerNourriture(item) {
return (await DialogConsommer.create(this, item, onActionItem)).render(true); return (await DialogConsommer.create(this, item)).render(true);
} }
async actionLire(item) { async actionLire(item) {
@ -1844,7 +1844,7 @@ export class RdDActor extends RdDBaseActorSang {
[tacheData.system.carac]: foundry.utils.duplicate(this.system.carac[tacheData.system.carac]) [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; oeuvre.system.niveau = oeuvre.system.niveau ?? 0;
foundry.utils.mergeObject(artData, foundry.utils.mergeObject(artData,
{ {
@ -2178,7 +2178,7 @@ export class RdDActor extends RdDBaseActorSang {
label: 'Appel à la chance', label: 'Appel à la chance',
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html',
rollData: { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' }, 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) { async consommerPotionSoin(potion) {
potionData.alias = this.name; potion.alias = this.name;
potionData.supprimer = true; potion.supprimer = true;
if (potionData.system.magique) { if (potion.system.magique) {
// Gestion de la résistance: // Gestion de la résistance:
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8); potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
if (potionData.rolled.isEchec) { if (potion.rolled.isEchec) {
await this.reveActuelIncDec(-1); await this.reveActuelIncDec(-1);
potionData.guerisonData = await this.buildPotionGuerisonList(potionData.system.puissance); potion.guerisonData = await this.buildPotionGuerisonList(potion.system.puissance);
potionData.guerisonMinutes = potionData.guerisonData.pointsConsommes * 5; potion.guerisonMinutes = potion.guerisonData.pointsConsommes * 5;
} }
} }
if (!potionData.system.magique || potionData.rolled.isSuccess) { if (!potion.system.magique || potion.rolled.isSuccess) {
await this.setBonusPotionSoin(potionData.system.herbebonus); await this.setBonusPotionSoin(potion.system.herbebonus);
} }
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this), 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) { async consommerPotionRepos(potion) {
potionData.alias = this.name; potion.alias = this.name;
potionData.supprimer = true; potion.supprimer = true;
if (potionData.system.magique) { if (potion.system.magique) {
// Gestion de la résistance: // Gestion de la résistance:
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8); potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
if (potionData.rolled.isEchec) { if (potion.rolled.isEchec) {
await this.reveActuelIncDec(-1); await this.reveActuelIncDec(-1);
let fatigueActuelle = this.getFatigueActuelle(); let fatigueActuelle = this.getFatigueActuelle();
potionData.caseFatigueReel = Math.min(fatigueActuelle, potionData.system.puissance); potion.caseFatigueReel = Math.min(fatigueActuelle, potion.system.puissance);
potionData.guerisonDureeUnite = (potionData.system.reposalchimique) ? "rounds" : "minutes"; potion.guerisonDureeUnite = (potion.system.reposalchimique) ? "rounds" : "minutes";
potionData.guerisonDureeValue = (potionData.system.reposalchimique) ? potionData.caseFatigueReel : potionData.caseFatigueReel * 5; potion.guerisonDureeValue = (potion.system.reposalchimique) ? potion.caseFatigueReel : potion.caseFatigueReel * 5;
potionData.aphasiePermanente = false; potion.aphasiePermanente = false;
if (potionData.system.reposalchimique) { if (potion.system.reposalchimique) {
let chanceAphasie = await RdDDice.rollTotal("1d100"); let chanceAphasie = await RdDDice.rollTotal("1d100");
if (chanceAphasie <= potionData.system.pr) { if (chanceAphasie <= potion.system.pr) {
potionData.aphasiePermanente = true; potion.aphasiePermanente = true;
} }
} }
await this.santeIncDec("fatigue", -potionData.caseFatigueReel); await this.santeIncDec("fatigue", -potion.caseFatigueReel);
} }
} }
if (!potionData.system.magique || potionData.rolled.isSuccess) { if (!potion.system.magique || potion.rolled.isSuccess) {
this.bonusRepos = potionData.system.herbebonus; this.bonusRepos = potion.system.herbebonus;
} }
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this), 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) { async consommerPotionGenerique(potion) {
potionData.alias = this.name; potion.alias = this.name;
if (potionData.system.magique) { if (potion.system.magique) {
// Gestion de la résistance: // Gestion de la résistance:
potionData.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8); potion.rolled = await RdDResolutionTable.roll(this.getReveActuel(), -8);
if (potionData.rolled.isEchec) { if (potion.rolled.isEchec) {
await this.reveActuelIncDec(-1); await this.reveActuelIncDec(-1);
} }
} }
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getOwners(this), 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 () => { }) { async consommerPotion(potion) {
const potionData = potion if (potion.system.categorie.includes('Soin')) {
this.consommerPotionSoin(potion);
if (potionData.system.categorie.includes('Soin')) { } else if (potion.system.categorie.includes('Repos')) {
this.consommerPotionSoin(potionData); this.consommerPotionRepos(potion);
} else if (potionData.system.categorie.includes('Repos')) {
this.consommerPotionRepos(potionData);
} else { } else {
this.consommerPotionGenerique(potionData); this.consommerPotionGenerique(potion);
} }
await this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potionData.supprimer }); await this.diminuerQuantiteObjet(potion.id, 1, { supprimerSiZero: potion.supprimer });
await onActionItem()
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -26,16 +26,17 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('.button-encaissement').click(async event => this.actor.encaisser()) this.html.find('.button-encaissement').click(async event => await this.actor.encaisser())
this.html.find('.roll-carac').click(async event => { this.html.find('.roll-carac').click(async event => {
this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))}) await this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))
this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); })
this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1)); this.html.find('.roll-competence').click(async event => await this.actor.rollCompetence(RdDSheetUtility.getItemId(event)));
this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1)); this.html.find('.endurance-plus').click(async event => await this.actor.santeIncDec("endurance", 1));
this.html.find('.endurance-moins').click(async event => await this.actor.santeIncDec("endurance", -1));
if (game.user.isGM) { if (game.user.isGM) {
this.html.find('.button-remise-a-neuf').click(async event => this.actor.remiseANeuf()) this.html.find('.button-remise-a-neuf').click(async event => await this.actor.remiseANeuf())
this.html.find('.delete-active-effect').click(async event => this.actor.removeEffect(this.html.find(event.currentTarget).parents(".active-effect").data('effect'))); this.html.find('.delete-active-effect').click(async event => await this.actor.removeEffect(this.html.find(event.currentTarget).parents(".active-effect").data('effect')));
this.html.find('.enlever-tous-effets').click(async event => await this.actor.removeEffects()); this.html.find('.enlever-tous-effets').click(async event => await this.actor.removeEffects());
} }
this.html.find('.competence-add').click(async event => this.html.find('.competence-add').click(async event =>
@ -55,14 +56,13 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
if (this.options.vueDetaillee) { if (this.options.vueDetaillee) {
// On carac change // On carac change
this.html.find('.carac-value').change(async event => { this.html.find('.carac-value').change(async event => {
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", ""); let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "")
this.actor.updateCarac(caracName, parseInt(event.target.value)); await this.actor.updateCarac(caracName, parseInt(event.target.value))
}); });
// On competence change // On competence change
this.html.find('.competence-value').change(async event => { this.html.find('.competence-value').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value
//console.log("Competence changed :", compName); await this.actor.updateCompetence(compName, parseInt(event.target.value))
this.actor.updateCompetence(compName, parseInt(event.target.value));
}); });
} }
} }

View File

@ -310,7 +310,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
competence: competence, competence: competence,
show: { title: options?.title ?? '' } show: { title: options?.title ?? '' }
}, },
callbackAction: r => this.$onRollCompetence(r, options) callbackAction: async r => await this.$onRollCompetence(r, options)
}); });
} }
/** /**
@ -362,7 +362,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
selectedCaracName: selectedCaracName, selectedCaracName: selectedCaracName,
competences: this.itemTypes['competence'] competences: this.itemTypes['competence']
}, },
callbackAction: r => this.$onRollCaracResult(r) callbackAction: async r => await this.$onRollCaracResult(r)
}) })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -384,7 +384,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
diffLibre: options.diff ?? 0, diffLibre: options.diff ?? 0,
jetResistance: options.resistance ? caracName : undefined jetResistance: options.resistance ? caracName : undefined
}, },
callbackAction: r => this.$onRollCaracResult(r) callbackAction: async r => await this.$onRollCaracResult(r)
}); });
} }
@ -422,7 +422,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
label: 'Jet ' + Grammar.apostrophe('de', competence.name), label: 'Jet ' + Grammar.apostrophe('de', competence.name),
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html', template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
rollData: rollData, rollData: rollData,
callbackAction: r => this.$onRollCompetence(r, options) callbackAction: async r => await this.$onRollCompetence(r, options)
}); });
} }

View File

@ -17,20 +17,20 @@ export class RdDBaseActorSangSheet extends RdDBaseActorReveSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('.creer-blessure-legere').click(async event => RdDItemBlessure.createBlessure(this.actor, 2)); this.html.find('.creer-blessure-legere').click(async event => await RdDItemBlessure.createBlessure(this.actor, 2));
this.html.find('.creer-blessure-grave').click(async event => RdDItemBlessure.createBlessure(this.actor, 4)); this.html.find('.creer-blessure-grave').click(async event => await RdDItemBlessure.createBlessure(this.actor, 4));
this.html.find('.creer-blessure-critique').click(async event => RdDItemBlessure.createBlessure(this.actor, 6)); this.html.find('.creer-blessure-critique').click(async event => await RdDItemBlessure.createBlessure(this.actor, 6));
this.html.find('.subir-blessure-contusion').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 0)); this.html.find('.subir-blessure-contusion').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 0));
this.html.find('.subir-blessure-legere').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 2)); this.html.find('.subir-blessure-legere').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 2));
this.html.find('.subir-blessure-grave').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 4)); this.html.find('.subir-blessure-grave').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 4));
this.html.find('.subir-blessure-critique').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 6)); this.html.find('.subir-blessure-critique').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 6));
this.html.find('.jet-vie').click(async event => this.actor.jetDeVie()) this.html.find('.jet-vie').click(async event => await this.actor.jetDeVie())
this.html.find('.jet-endurance').click(async event => await this.jetEndurance()) this.html.find('.jet-endurance').click(async event => await this.jetEndurance())
this.html.find('.vie-plus').click(async event => this.actor.santeIncDec("vie", 1)) this.html.find('.vie-plus').click(async event => await this.actor.santeIncDec("vie", 1))
this.html.find('.vie-moins').click(async event => this.actor.santeIncDec("vie", -1)) this.html.find('.vie-moins').click(async event => await this.actor.santeIncDec("vie", -1))
} }
async jetEndurance() { async jetEndurance() {

View File

@ -85,14 +85,14 @@ export class RdDBaseActorSheet extends ActorSheet {
super.activateListeners(html); super.activateListeners(html);
this.html = html; this.html = html;
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options)) this.html.find('.actionItem').click(async event => await ItemAction.onActionItem(event, this.actor, this.options))
this.html.find('.item-edit').click(async event => this.itemActionEdit(event)) this.html.find('.item-edit').click(async event => await this.itemActionEdit(event))
this.html.find('.conteneur-name a').click(async event => { this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(this.getItemId(event)) RdDUtility.toggleAfficheContenu(this.getItemId(event))
this.render(true) this.render(true)
}) })
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat()); this.html.find('.actor-montrer').click(async event => await this.actor.postActorToChat());
this.html.find('.recherche') this.html.find('.recherche')
.each((index, field) => { .each((index, field) => {
@ -106,21 +106,17 @@ export class RdDBaseActorSheet extends ActorSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('.item-equip-armure').click(async event => this.actor.equiperObjet(this.getItem(event))) this.html.find('.item-equip-armure').click(async event => await this.actor.equiperObjet(this.getItem(event)))
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this.getItem(event), this.actor)); this.html.find('.item-delete').click(async event => await RdDUtility.confirmActorItemDelete(this.getItem(event), this.actor));
this.html.find('.item-quantite-plus').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), 1)); this.html.find('.item-quantite-plus').click(async event => await this.actor.itemQuantiteIncDec(this.getItemId(event), 1));
this.html.find('.item-quantite-moins').click(async event => this.actor.itemQuantiteIncDec(this.getItemId(event), -1)); this.html.find('.item-quantite-moins').click(async event => await this.actor.itemQuantiteIncDec(this.getItemId(event), -1));
this.html.find('.creer-un-objet').click(async event => { this.html.find('.creer-un-objet').click(async event => await this.selectObjetTypeToCreate())
this.selectObjetTypeToCreate(); this.html.find('.nettoyer-conteneurs').click(async event => await this.actor.nettoyerConteneurs())
});
this.html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
});
this.html.find('.vue-detaillee').click(async event => { this.html.find('.vue-detaillee').click(async event => {
this.options.vueDetaillee = !this.options.vueDetaillee; this.options.vueDetaillee = !this.options.vueDetaillee
this.render(true); this.render(true)
}); });
} }

View File

@ -26,15 +26,15 @@ export class RdDCreatureSheet extends RdDBaseActorSangSheet {
// On competence change // On competence change
this.html.find('.creature-carac').change(async event => { this.html.find('.creature-carac').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value)); await this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
}); });
this.html.find('.creature-niveau').change(async event => { this.html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value)); await this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
}); });
this.html.find('.creature-dommages').change(async event => { this.html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); await this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
}); });
} }
} }

View File

@ -33,15 +33,15 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
// On competence change // On competence change
this.html.find('.creature-carac').change(async event => { this.html.find('.creature-carac').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value)); await this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
}); });
this.html.find('.creature-dommages').change(async event => { this.html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); await this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
}) })
this.html.find('.resonance-add').click(async event => this.html.find('.resonance-add').click(async event =>
DialogSelect.select({ await DialogSelect.select({
label: "Choisir un acteur à accorder", label: "Choisir un acteur à accorder",
list: game.actors.filter(it => it.isPersonnage() && it.prototypeToken.actorLink) list: game.actors.filter(it => it.isPersonnage() && it.prototypeToken.actorLink)
}, },

View File

@ -104,13 +104,12 @@ export class RdDActorExportSheet extends RdDActorSheet {
this.html.find('.click-blessure-add').click(async event => this.html.find('.click-blessure-add').click(async event =>
await this.actor.ajouterBlessure({ await this.actor.ajouterBlessure({
gravite: this.html.find(event.currentTarget).data('gravite') gravite: this.html.find(event.currentTarget).data('gravite')
// event.currentTarget.attributes['data-gravite'].value
}) })
) )
this.html.find('.button-export').click(async event => { this.html.find('.button-export').click(async event => await
ExportScriptarium.INSTANCE.exportActors([this.actor], ExportScriptarium.INSTANCE.exportActors([this.actor],
`${this.actor.uuid}-${this.actor.name}` `${this.actor.uuid}-${this.actor.name}`
) )
}) )
} }
} }

View File

@ -32,18 +32,10 @@ export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('.resistance-moins').click(async event => { this.html.find('.resistance-moins').click(async event => await this.actor.vehicleIncDec("resistance", -1))
this.actor.vehicleIncDec("resistance", -1); this.html.find('.resistance-plus').click(async event => await this.actor.vehicleIncDec("resistance", 1))
}); this.html.find('.structure-moins').click(async event => await this.actor.vehicleIncDec("structure", -1))
this.html.find('.resistance-plus').click(async event => { this.html.find('.structure-plus').click(async event => await this.actor.vehicleIncDec("structure", 1))
this.actor.vehicleIncDec("resistance", 1);
});
this.html.find('.structure-moins').click(async event => {
this.actor.vehicleIncDec("structure", -1);
});
this.html.find('.structure-plus').click(async event => {
this.actor.vehicleIncDec("structure", 1);
});
} }
} }

View File

@ -37,18 +37,13 @@ export class DialogChoixXpCarac extends Dialog {
} }
activateListeners(html) { activateListeners(html) {
//TODO
super.activateListeners(html) super.activateListeners(html)
this.html = html this.html = html
this.html.find("li.xpCarac-option .xpCarac-moins").click(event => this.html.find("li.xpCarac-option .xpCarac-moins").click(event => this.ajouterXp(event, -1))
this.ajouterXp(event, -1) this.html.find("li.xpCarac-option .xpCarac-plus").click(event => this.ajouterXp(event, 1))
)
this.html.find("li.xpCarac-option .xpCarac-plus").click(event =>
this.ajouterXp(event, 1)
)
} }
async ajouterXp(event, delta) { ajouterXp(event, delta) {
const liCarac = this.html.find(event.currentTarget)?.parents("li.xpCarac-option") const liCarac = this.html.find(event.currentTarget)?.parents("li.xpCarac-option")
const label = liCarac?.data("carac-label") const label = liCarac?.data("carac-label")
const carac = this.caracs.find(c => c.label == label) const carac = this.caracs.find(c => c.label == label)

View File

@ -2,13 +2,13 @@ import { Misc } from "./misc.js";
export class DialogConsommer extends Dialog { export class DialogConsommer extends Dialog {
static async create(actor, item, onActionItem = async () => { }) { static async create(actor, item) {
const consommerData = DialogConsommer.prepareData(actor, item); const consommerData = DialogConsommer.prepareData(actor, item);
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html', consommerData); const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html', consommerData);
return new DialogConsommer(actor, item, consommerData, html, onActionItem) return new DialogConsommer(actor, item, consommerData, html)
} }
constructor(actor, item, consommerData, html, onActionItem = async () => { }) { constructor(actor, item, consommerData, html) {
const options = { classes: ["dialogconsommer"], width: 350, height: 'fit-content', 'z-index': 99999 }; const options = { classes: ["dialogconsommer"], width: 350, height: 'fit-content', 'z-index': 99999 };
let conf = { let conf = {
title: consommerData.title, title: consommerData.title,
@ -16,10 +16,7 @@ export class DialogConsommer extends Dialog {
default: consommerData.buttonName, default: consommerData.buttonName,
buttons: { buttons: {
[consommerData.buttonName]: { [consommerData.buttonName]: {
label: consommerData.buttonName, callback: async it => { label: consommerData.buttonName, callback: async it => await this.onConsommer()
await this.onConsommer();
await onActionItem();
}
} }
} }
}; };

View File

@ -159,23 +159,19 @@ export class RdDItemSheet extends ItemSheet {
HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionnelles.isUsing('afficher-prix-joueurs') HtmlUtility.showControlWhen(this.html.find(".item-cout"), ReglesOptionnelles.isUsing('afficher-prix-joueurs')
|| game.user.isGM || game.user.isGM
|| !this.item.isOwned); || !this.item.isOwned)
HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique); HtmlUtility.showControlWhen(this.html.find(".item-magique"), this.item.isMagique)
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return
this.form.ondragstart = (event) => this._onDragStart(event); this.form.ondragstart = async event => await this._onDragStart(event)
this.form.ondrop = (event) => this._onDrop(event); this.form.ondrop = async event => await this._onDrop(event)
// Select competence categorie // Select competence categorie
this.html.find(".categorie").change(event => this._onSelectCategorie(event)); this.html.find(".categorie").change(async event => await this._onSelectCategorie(event))
this.html.find('.sheet-competence-xp').change((event) => { this.html.find('.sheet-competence-xp').change(event => RdDUtility.checkThanatosXP(this.item))
if (this.item.isCompetencePersonnage()) {
RdDUtility.checkThanatosXP(this.item.name);
}
});
this.html.find(".item-cout input[name='system.cout']").change(event => { this.html.find(".item-cout input[name='system.cout']").change(event => {
if (this.item.isMonnaie()) { if (this.item.isMonnaie()) {
const value = event.currentTarget.value; const value = event.currentTarget.value;
@ -184,42 +180,41 @@ export class RdDItemSheet extends ItemSheet {
} }
} }
}) })
this.html.find('.delete-bonus-case').click((event) => { this.html.find('.delete-bonus-case').click(async event => await this.supprimerBonusCase(event.currentTarget.attributes['data-deleteCoord'].value))
this.supprimerBonusCase(event.currentTarget.attributes['data-deleteCoord'].value) this.html.find('.creer-tache-livre').click(async event => await this._getEventActor(event).creerTacheDepuisLivre(this.item))
}) this.html.find('.creer-potion-base').click(async event => await this._getEventActor(event).fabriquerDecoctionHerbe(this.item))
this.html.find('input[name="system.cacher_points_de_tache"]').change(async event =>
this.html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item)); await this.item.update({ 'system.cacher_points_de_tache': event.currentTarget.checked })
this.html.find('.creer-potion-base').click((event) => this._getEventActor(event).fabriquerDecoctionHerbe(this.item)) )
this.html.find('input[name="system.cacher_points_de_tache"]').change(async event => await this.item.update({ 'system.cacher_points_de_tache': event.currentTarget.checked }));
this.html.find('.roll-text').click(async event => await RdDTextEditor.rollText(event, this.actor)) this.html.find('.roll-text').click(async event => await RdDTextEditor.rollText(event, this.actor))
this.html.find('.chat-roll-text').click(async event => await RdDTextEditor.chatRollText(event)) this.html.find('.chat-roll-text').click(async event => await RdDTextEditor.chatRollText(event))
if (this.actor) { if (this.actor) {
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options)) this.html.find('.actionItem').click(async event => await ItemAction.onActionItem(event, this.actor, this.options))
// TODO: utiliser un itemAction? // TODO: utiliser un itemAction?
this.html.find('.item-potion-consommer').click(event => this.itemActionConsommer(event)) this.html.find('.item-potion-consommer').click(async event => await this.itemActionConsommer(event))
this.html.find('.item-quantite-plus').click(async event => { this.html.find('.item-quantite-plus').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1) await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), 1)
this.render() //this.render()
}) })
this.html.find('.item-quantite-moins').click(async event => { this.html.find('.item-quantite-moins').click(async event => {
await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1) await this.actor.itemQuantiteIncDec(RdDSheetUtility.getItemId(event), -1)
this.render() //this.render()
}) })
} }
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: foundry.utils.duplicate(timestamp) }) const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: foundry.utils.duplicate(timestamp) })
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.debut', updateItemTimestamp); RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.debut', updateItemTimestamp)
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp); RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp)
} }
itemActionDelete(event) { async itemActionDelete(event) {
const item = RdDSheetUtility.getItem(event, this.actor) const item = RdDSheetUtility.getItem(event, this.actor)
return RdDUtility.confirmActorItemDelete(item, this.actor) return await RdDUtility.confirmActorItemDelete(item, this.actor)
} }
async itemActionConsommer(event) { async itemActionConsommer(event) {
@ -238,12 +233,7 @@ export class RdDItemSheet extends ItemSheet {
} }
} }
_getEventActor(event) { _getEventActor(event) { return game.actors.get(event.currentTarget.attributes['data-actor-id'].value) }
let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get(actorId);
return actor;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onSelectCategorie(event) { async _onSelectCategorie(event) {
@ -285,7 +275,7 @@ export class RdDItemSheet extends ItemSheet {
break break
} }
return this.item.update(formData); return this.item.update(formData)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -318,8 +308,9 @@ export class RdDItemSheet extends ItemSheet {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDragStart(event) { async _onDragStart(event) { }
} async _onDropItem(event, dragData) { }
async _onDropActor(event, dragData) { }
async _onDrop(event) { async _onDrop(event) {
// Try to extract the dragData // Try to extract the dragData
@ -345,13 +336,7 @@ export class RdDItemSheet extends ItemSheet {
return JSON.parse(eventData); return JSON.parse(eventData);
} }
} catch (err) { } } catch (err) { }
return undefined; return undefined
}
async _onDropItem(event, dragData) {
}
async _onDropActor(event, dragData) {
} }
} }

View File

@ -135,12 +135,12 @@ export class ItemAction {
return undefined return undefined
} }
static onActionItem(event, actor, options) { static async onActionItem(event, actor, options) {
const item = RdDSheetUtility.getItem(event, actor) const item = RdDSheetUtility.getItem(event, actor)
const code = $(event.currentTarget).data('code') const code = $(event.currentTarget).data('code')
const action = item?.itemActions().find(it => it.code == code) const action = item?.itemActions().find(it => it.code == code)
if (action && (!action.optionsFilter || action.optionsFilter(options))) { if (action && (!action.optionsFilter || action.optionsFilter(options))) {
action.action(item, actor) await action.action(item, actor)
} }
} }
} }

View File

@ -34,8 +34,8 @@ export class RdDItemInventaireSheet extends RdDItemSheet {
HtmlUtility.showControlWhen(this.html.find("div.description-milieu"), TYPE_ITEMS_NATURELS.includes(this.item.type)); HtmlUtility.showControlWhen(this.html.find("div.description-milieu"), TYPE_ITEMS_NATURELS.includes(this.item.type));
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event)); this.html.find("a.preparer-nourriture").click(async event => await this.preparerNourriture(event));
this.html.find("a.manger-nourriture").click(event => this.mangerNourriture(event)); this.html.find("a.manger-nourriture").click(async event => await this.mangerNourriture(event));
this.html.find("input.input-selection-milieu").keypress(event => { this.html.find("input.input-selection-milieu").keypress(event => {
if (event.keyCode == '13') { if (event.keyCode == '13') {
@ -43,11 +43,11 @@ export class RdDItemInventaireSheet extends RdDItemSheet {
} }
event.stopPropagation(); event.stopPropagation();
}) })
this.html.find("a.milieu-add").click(event => this.onAddMilieu(event)); this.html.find("a.milieu-add").click(async event => await this.onAddMilieu(event));
this.html.find("div.environnement-milieu a.milieu-delete").click(event => this.onDeleteMilieu(event)); this.html.find("div.environnement-milieu a.milieu-delete").click(async event => await this.onDeleteMilieu(event));
this.html.find("div.environnement-milieu select.environnement-rarete").change(event => this.onChange(event, this.html.find("div.environnement-milieu select.environnement-rarete").change(async event => await this.onChange(event,
updated => this.$changeRarete(event, updated))); updated => this.$changeRarete(event, updated)));
this.html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => this.onChange(event, this.html.find("div.environnement-milieu input[name='environnement-frequence']").change(async event => await this.onChange(event,
updated => this.$changeFrequence(event, updated))); updated => this.$changeFrequence(event, updated)));

View File

@ -15,15 +15,15 @@ export class RdDBlessureItemSheet extends RdDItemSheet {
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find('[name="premierssoins-done"]').change(async event => { this.html.find('[name="premierssoins-done"]').change(async event =>
await this.item.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } }); await this.item.setSoinsBlessure({ premierssoins: { done: event.currentTarget.checked } })
}); )
this.html.find('[name="soinscomplets-done"]').change(async event => { this.html.find('[name="soinscomplets-done"]').change(async event =>
await this.item.setSoinsBlessure({ soinscomplets: { done: event.currentTarget.checked } }) await this.item.setSoinsBlessure({ soinscomplets: { done: event.currentTarget.checked } })
}); )
this.html.find('[name="system-gravite"]').change(async event => { this.html.find('[name="system-gravite"]').change(async event => {
const gravite = Number(event.currentTarget.value) const gravite = Number(event.currentTarget.value)
await this.item.setSoinsBlessure({ gravite: gravite, difficulte: - gravite }) await this.item.setSoinsBlessure({ gravite: gravite, difficulte: - gravite })
}); })
} }
} }

View File

@ -9,7 +9,7 @@ export class RdDFauneItemSheet extends RdDItemInventaireSheet {
if (!this.options.editable) return; if (!this.options.editable) return;
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor()); html.find("a.linked-actor-delete").click(async event => await this.onDeleteLinkedActor());
} }
async _onDropActor(event, dragData) { async _onDropActor(event, dragData) {

View File

@ -44,8 +44,8 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;
this.html.find("a.effet-add").click(event => this.onAddEffet(event)); this.html.find("a.effet-add").click(async event => await this.onAddEffet(event));
this.html.find("a.effet-delete").click(event => this.onDeleteEffet(event)); this.html.find("a.effet-delete").click(async event => await this.onDeleteEffet(event));
} }
async onAddEffet(event) { async onAddEffet(event) {

View File

@ -36,9 +36,9 @@ export class RdDSigneDraconiqueItemSheet extends RdDItemSheet {
if (!this.options.editable) return; if (!this.options.editable) return;
html.find(".signe-aleatoire").click(event => this.setSigneAleatoire()); html.find(".signe-aleatoire").click(async event => await this.setSigneAleatoire());
html.find("input.select-tmr").change(event => this.onSelectTmr(event)); html.find("input.select-tmr").change(async event => await this.onSelectTmr(event));
html.find(".signe-xp-sort").change(event => this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value))); html.find(".signe-xp-sort").change(async event => await this.onValeurXpSort(event.currentTarget.attributes['data-typereussite']?.value, Number(event.currentTarget.value)));
} }
async setSigneAleatoire() { async setSigneAleatoire() {

View File

@ -964,8 +964,8 @@ export class RdDUtility {
} }
/*-------------------------------------------- */ /*-------------------------------------------- */
static checkThanatosXP(compName) { static checkThanatosXP(item) {
if (compName.includes('Thanatos')) { if (item.isCompetencePersonnage() && item.name.includes('Thanatos')) {
let message = "Vous avez mis des points d'Expérience en Thanatos !<br>Vous devez réduire manuellement d'un même montant d'XP une autre compétence Draconique."; let message = "Vous avez mis des points d'Expérience en Thanatos !<br>Vous devez réduire manuellement d'un même montant d'XP une autre compétence Draconique.";
ChatMessage.create({ ChatMessage.create({
whisper: ChatUtility.getUserAndGMs(), whisper: ChatUtility.getUserAndGMs(),