Support recherche compétence par id

This commit is contained in:
Vincent Vandemeulebrouck
2021-11-23 02:04:00 +01:00
parent 9848e1a8af
commit b57b02b3ff
2 changed files with 66 additions and 76 deletions

View File

@ -277,52 +277,34 @@ export class RdDActorSheet extends ActorSheet {
// Roll Skill
html.find('a.competence-label').click(async event => {
let compName = event.currentTarget.name;
this.actor.rollCompetence(compName);
this.actor.rollCompetence(this._getItemId(event));
});
html.find('.tache-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let tacheId = li.data('item-id');
this.actor.rollTache(tacheId);
this.actor.rollTache(this._getItemId(event));
});
html.find('.meditation-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let meditationId = li.data('item-id');
this.actor.rollMeditation(meditationId);
this.actor.rollMeditation(this._getItemId(event));
});
html.find('.chant-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let chantId = li.data('item-id');
this.actor.rollChant(chantId);
this.actor.rollChant(this._getItemId(event));
});
html.find('.danse-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let danseId = li.data('item-id');
this.actor.rollDanse(danseId);
this.actor.rollDanse(this._getItemId(event));
});
html.find('.musique-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let musiqueId = li.data('item-id');
this.actor.rollMusique(musiqueId);
this.actor.rollMusique(this._getItemId(event));
});
html.find('.oeuvre-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let oeuvreId = li.data('item-id');
this.actor.rollOeuvre(oeuvreId);
this.actor.rollOeuvre(this._getItemId(event));
});
html.find('.jeu-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let jeuId = li.data('item-id');
this.actor.rollJeu(jeuId);
this.actor.rollJeu(this._getItemId(event));
});
html.find('.recettecuisine-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let recetteId = li.data('item-id');
this.actor.rollRecetteCuisine(recetteId);
this.actor.rollRecetteCuisine(this._getItemId(event));
});
html.find('.subacteur-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let actorId = li.data('actor-id');
let actorId = this._getEventItemData(event, 'actor-id');
let actor = game.actors.get(actorId);
if (actor) {
actor.sheet.render(true);
@ -344,16 +326,14 @@ export class RdDActorSheet extends ActorSheet {
// Roll Weapon1
html.find('.arme-label a').click(async event => {
const li = $(event.currentTarget).parents(".item");
let arme = this._getArmeCombat(li);
let arme = this._getEventArmeCombat(event);
this.actor.rollArme( duplicate(arme) );
});
// Initiative pour l'arme
html.find('.arme-initiative a').click(async event => {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
if (combatant) {
const li = $(event.currentTarget).parents(".item");
let arme = this._getArmeCombat(li);
let arme = this._getEventArmeCombat(event);
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme);
} else {
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
@ -385,8 +365,7 @@ export class RdDActorSheet extends ActorSheet {
this.actor.enleverTousLesEffets();
});
html.find('.conteneur-name a').click(async event => {
let myID = event.currentTarget.attributes['data-item-id'].value;
RdDUtility.toggleAfficheContenu(myID);
RdDUtility.toggleAfficheContenu(this._getItemId(event));
this.render(true);
});
html.find('.carac-xp-augmenter').click(async event => {
@ -394,10 +373,12 @@ export class RdDActorSheet extends ActorSheet {
this.actor.updateCaracXPAuto(caracName);
});
html.find('.competence-xp-augmenter').click(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceXPAuto(compName);
this.actor.updateCompetenceXPAuto(this._getItemId(event));
});
html.find('.competence-stress-augmenter').click(async event => {
this.actor.updateCompetenceStress(this._getItemId(event));
});
if (this.options.editCaracComp) {
// On carac change
html.find('.carac-value').change(async event => {
@ -534,8 +515,17 @@ export class RdDActorSheet extends ActorSheet {
});
}
_getItemId(event) {
return this._getEventItemData(event, "item-id");
}
_getArmeCombat(li) {
_getEventItemData(event, property) {
const li = $(event.currentTarget)?.parents(".item");
return li?.data(property);
}
_getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name");
let compName = li.data('competence-name');
const arme = this.armesList.find(a => a.name == armeName && a.data.competence == compName);