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:
@ -26,16 +26,17 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
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.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('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1));
|
||||
await this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))
|
||||
})
|
||||
this.html.find('.roll-competence').click(async event => await this.actor.rollCompetence(RdDSheetUtility.getItemId(event)));
|
||||
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) {
|
||||
this.html.find('.button-remise-a-neuf').click(async event => 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('.button-remise-a-neuf').click(async event => await this.actor.remiseANeuf())
|
||||
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('.competence-add').click(async event =>
|
||||
@ -55,14 +56,13 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet {
|
||||
if (this.options.vueDetaillee) {
|
||||
// On carac change
|
||||
this.html.find('.carac-value').change(async event => {
|
||||
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
|
||||
this.actor.updateCarac(caracName, parseInt(event.target.value));
|
||||
let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "")
|
||||
await this.actor.updateCarac(caracName, parseInt(event.target.value))
|
||||
});
|
||||
// On competence change
|
||||
this.html.find('.competence-value').change(async event => {
|
||||
let compName = event.currentTarget.attributes.compname.value;
|
||||
//console.log("Competence changed :", compName);
|
||||
this.actor.updateCompetence(compName, parseInt(event.target.value));
|
||||
let compName = event.currentTarget.attributes.compname.value
|
||||
await this.actor.updateCompetence(compName, parseInt(event.target.value))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
competence: competence,
|
||||
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,
|
||||
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,
|
||||
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),
|
||||
template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
|
||||
rollData: rollData,
|
||||
callbackAction: r => this.$onRollCompetence(r, options)
|
||||
callbackAction: async r => await this.$onRollCompetence(r, options)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -17,20 +17,20 @@ export class RdDBaseActorSangSheet extends RdDBaseActorReveSheet {
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
this.html.find('.creer-blessure-legere').click(async event => RdDItemBlessure.createBlessure(this.actor, 2));
|
||||
this.html.find('.creer-blessure-grave').click(async event => RdDItemBlessure.createBlessure(this.actor, 4));
|
||||
this.html.find('.creer-blessure-critique').click(async event => RdDItemBlessure.createBlessure(this.actor, 6));
|
||||
this.html.find('.creer-blessure-legere').click(async event => await RdDItemBlessure.createBlessure(this.actor, 2));
|
||||
this.html.find('.creer-blessure-grave').click(async event => await RdDItemBlessure.createBlessure(this.actor, 4));
|
||||
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-legere').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 2));
|
||||
this.html.find('.subir-blessure-grave').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 4));
|
||||
this.html.find('.subir-blessure-critique').click(async event => RdDItemBlessure.applyFullBlessure(this.actor, 6));
|
||||
this.html.find('.subir-blessure-contusion').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 0));
|
||||
this.html.find('.subir-blessure-legere').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 2));
|
||||
this.html.find('.subir-blessure-grave').click(async event => await RdDItemBlessure.applyFullBlessure(this.actor, 4));
|
||||
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('.vie-plus').click(async event => this.actor.santeIncDec("vie", 1))
|
||||
this.html.find('.vie-moins').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 => await this.actor.santeIncDec("vie", -1))
|
||||
}
|
||||
|
||||
async jetEndurance() {
|
||||
|
@ -85,14 +85,14 @@ export class RdDBaseActorSheet extends ActorSheet {
|
||||
super.activateListeners(html);
|
||||
this.html = html;
|
||||
|
||||
this.html.find('.actionItem').click(event => ItemAction.onActionItem(event, this.actor, this.options))
|
||||
this.html.find('.item-edit').click(async event => this.itemActionEdit(event))
|
||||
this.html.find('.actionItem').click(async event => await ItemAction.onActionItem(event, this.actor, this.options))
|
||||
this.html.find('.item-edit').click(async event => await this.itemActionEdit(event))
|
||||
this.html.find('.conteneur-name a').click(async event => {
|
||||
RdDUtility.toggleAfficheContenu(this.getItemId(event))
|
||||
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')
|
||||
.each((index, field) => {
|
||||
@ -106,21 +106,17 @@ export class RdDBaseActorSheet extends ActorSheet {
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
this.html.find('.item-equip-armure').click(async event => 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-quantite-plus').click(async event => 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-equip-armure').click(async event => await this.actor.equiperObjet(this.getItem(event)))
|
||||
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 => await 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.selectObjetTypeToCreate();
|
||||
});
|
||||
this.html.find('.nettoyer-conteneurs').click(async event => {
|
||||
this.actor.nettoyerConteneurs();
|
||||
});
|
||||
this.html.find('.creer-un-objet').click(async event => await this.selectObjetTypeToCreate())
|
||||
this.html.find('.nettoyer-conteneurs').click(async event => await this.actor.nettoyerConteneurs())
|
||||
|
||||
this.html.find('.vue-detaillee').click(async event => {
|
||||
this.options.vueDetaillee = !this.options.vueDetaillee;
|
||||
this.render(true);
|
||||
this.options.vueDetaillee = !this.options.vueDetaillee
|
||||
this.render(true)
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -26,15 +26,15 @@ export class RdDCreatureSheet extends RdDBaseActorSangSheet {
|
||||
// On competence change
|
||||
this.html.find('.creature-carac').change(async event => {
|
||||
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 => {
|
||||
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 => {
|
||||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -33,15 +33,15 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet {
|
||||
// On competence change
|
||||
this.html.find('.creature-carac').change(async event => {
|
||||
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 => {
|
||||
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 =>
|
||||
DialogSelect.select({
|
||||
await DialogSelect.select({
|
||||
label: "Choisir un acteur à accorder",
|
||||
list: game.actors.filter(it => it.isPersonnage() && it.prototypeToken.actorLink)
|
||||
},
|
||||
|
@ -104,13 +104,12 @@ export class RdDActorExportSheet extends RdDActorSheet {
|
||||
this.html.find('.click-blessure-add').click(async event =>
|
||||
await this.actor.ajouterBlessure({
|
||||
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],
|
||||
`${this.actor.uuid}-${this.actor.name}`
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -32,18 +32,10 @@ export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
|
||||
super.activateListeners(html);
|
||||
if (!this.options.editable) return;
|
||||
|
||||
this.html.find('.resistance-moins').click(async event => {
|
||||
this.actor.vehicleIncDec("resistance", -1);
|
||||
});
|
||||
this.html.find('.resistance-plus').click(async event => {
|
||||
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);
|
||||
});
|
||||
this.html.find('.resistance-moins').click(async event => await 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('.structure-plus').click(async event => await this.actor.vehicleIncDec("structure", 1))
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user