Support recherche compétence par id
This commit is contained in:
parent
9848e1a8af
commit
b57b02b3ff
@ -277,52 +277,34 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
// Roll Skill
|
// Roll Skill
|
||||||
html.find('a.competence-label').click(async event => {
|
html.find('a.competence-label').click(async event => {
|
||||||
let compName = event.currentTarget.name;
|
this.actor.rollCompetence(this._getItemId(event));
|
||||||
this.actor.rollCompetence(compName);
|
|
||||||
});
|
});
|
||||||
html.find('.tache-label a').click(async event => {
|
html.find('.tache-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollTache(this._getItemId(event));
|
||||||
let tacheId = li.data('item-id');
|
|
||||||
this.actor.rollTache(tacheId);
|
|
||||||
});
|
});
|
||||||
html.find('.meditation-label a').click(async event => {
|
html.find('.meditation-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollMeditation(this._getItemId(event));
|
||||||
let meditationId = li.data('item-id');
|
|
||||||
this.actor.rollMeditation(meditationId);
|
|
||||||
});
|
});
|
||||||
html.find('.chant-label a').click(async event => {
|
html.find('.chant-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollChant(this._getItemId(event));
|
||||||
let chantId = li.data('item-id');
|
|
||||||
this.actor.rollChant(chantId);
|
|
||||||
});
|
});
|
||||||
html.find('.danse-label a').click(async event => {
|
html.find('.danse-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollDanse(this._getItemId(event));
|
||||||
let danseId = li.data('item-id');
|
|
||||||
this.actor.rollDanse(danseId);
|
|
||||||
});
|
});
|
||||||
html.find('.musique-label a').click(async event => {
|
html.find('.musique-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollMusique(this._getItemId(event));
|
||||||
let musiqueId = li.data('item-id');
|
|
||||||
this.actor.rollMusique(musiqueId);
|
|
||||||
});
|
});
|
||||||
html.find('.oeuvre-label a').click(async event => {
|
html.find('.oeuvre-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollOeuvre(this._getItemId(event));
|
||||||
let oeuvreId = li.data('item-id');
|
|
||||||
this.actor.rollOeuvre(oeuvreId);
|
|
||||||
});
|
});
|
||||||
html.find('.jeu-label a').click(async event => {
|
html.find('.jeu-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollJeu(this._getItemId(event));
|
||||||
let jeuId = li.data('item-id');
|
|
||||||
this.actor.rollJeu(jeuId);
|
|
||||||
});
|
});
|
||||||
html.find('.recettecuisine-label a').click(async event => {
|
html.find('.recettecuisine-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
this.actor.rollRecetteCuisine(this._getItemId(event));
|
||||||
let recetteId = li.data('item-id');
|
|
||||||
this.actor.rollRecetteCuisine(recetteId);
|
|
||||||
});
|
});
|
||||||
html.find('.subacteur-label a').click(async event => {
|
html.find('.subacteur-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
let actorId = this._getEventItemData(event, 'actor-id');
|
||||||
let actorId = li.data('actor-id');
|
|
||||||
let actor = game.actors.get(actorId);
|
let actor = game.actors.get(actorId);
|
||||||
if (actor) {
|
if (actor) {
|
||||||
actor.sheet.render(true);
|
actor.sheet.render(true);
|
||||||
@ -344,16 +326,14 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
// Roll Weapon1
|
// Roll Weapon1
|
||||||
html.find('.arme-label a').click(async event => {
|
html.find('.arme-label a').click(async event => {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
let arme = this._getEventArmeCombat(event);
|
||||||
let arme = this._getArmeCombat(li);
|
|
||||||
this.actor.rollArme( duplicate(arme) );
|
this.actor.rollArme( duplicate(arme) );
|
||||||
});
|
});
|
||||||
// Initiative pour l'arme
|
// Initiative pour l'arme
|
||||||
html.find('.arme-initiative a').click(async event => {
|
html.find('.arme-initiative a').click(async event => {
|
||||||
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
|
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
|
||||||
if (combatant) {
|
if (combatant) {
|
||||||
const li = $(event.currentTarget).parents(".item");
|
let arme = this._getEventArmeCombat(event);
|
||||||
let arme = this._getArmeCombat(li);
|
|
||||||
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme);
|
RdDCombatManager.rollInitiativeCompetence(combatant._id, arme);
|
||||||
} else {
|
} else {
|
||||||
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
|
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();
|
this.actor.enleverTousLesEffets();
|
||||||
});
|
});
|
||||||
html.find('.conteneur-name a').click(async event => {
|
html.find('.conteneur-name a').click(async event => {
|
||||||
let myID = event.currentTarget.attributes['data-item-id'].value;
|
RdDUtility.toggleAfficheContenu(this._getItemId(event));
|
||||||
RdDUtility.toggleAfficheContenu(myID);
|
|
||||||
this.render(true);
|
this.render(true);
|
||||||
});
|
});
|
||||||
html.find('.carac-xp-augmenter').click(async event => {
|
html.find('.carac-xp-augmenter').click(async event => {
|
||||||
@ -394,10 +373,12 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
this.actor.updateCaracXPAuto(caracName);
|
this.actor.updateCaracXPAuto(caracName);
|
||||||
});
|
});
|
||||||
html.find('.competence-xp-augmenter').click(async event => {
|
html.find('.competence-xp-augmenter').click(async event => {
|
||||||
let compName = event.currentTarget.attributes.compname.value;
|
this.actor.updateCompetenceXPAuto(this._getItemId(event));
|
||||||
this.actor.updateCompetenceXPAuto(compName);
|
|
||||||
});
|
});
|
||||||
|
html.find('.competence-stress-augmenter').click(async event => {
|
||||||
|
this.actor.updateCompetenceStress(this._getItemId(event));
|
||||||
|
});
|
||||||
|
|
||||||
if (this.options.editCaracComp) {
|
if (this.options.editCaracComp) {
|
||||||
// On carac change
|
// On carac change
|
||||||
html.find('.carac-value').change(async event => {
|
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 armeName = li.data("arme-name");
|
||||||
let compName = li.data('competence-name');
|
let compName = li.data('competence-name');
|
||||||
const arme = this.armesList.find(a => a.name == armeName && a.data.competence == compName);
|
const arme = this.armesList.find(a => a.name == armeName && a.data.competence == compName);
|
||||||
|
@ -904,8 +904,8 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompetenceXPAuto(compName) {
|
async updateCompetenceXPAuto(idOrName) {
|
||||||
let competence = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (competence) {
|
if (competence) {
|
||||||
let compData = Misc.data(competence);
|
let compData = Misc.data(competence);
|
||||||
let xp = Number(compData.data.xp);
|
let xp = Number(compData.data.xp);
|
||||||
@ -914,35 +914,35 @@ export class RdDActor extends Actor {
|
|||||||
xp -= RdDItemCompetence.getCompetenceNextXp(niveau);
|
xp -= RdDItemCompetence.getCompetenceNextXp(niveau);
|
||||||
niveau++;
|
niveau++;
|
||||||
}
|
}
|
||||||
competence.update({
|
await competence.update({
|
||||||
"data.xp": xp,
|
"data.xp": xp,
|
||||||
"data.niveau": niveau,
|
"data.niveau": niveau,
|
||||||
});
|
});
|
||||||
this.updateExperienceLog("Compétence +", xp, compName + " passée à " + niveau);
|
this.updateExperienceLog("Compétence +", xp, competence.name + " passée à " + niveau);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCreatureCompetence(compName, fieldName, compValue) {
|
async updateCreatureCompetence(idOrName, fieldName, compValue) {
|
||||||
let comp = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (comp) {
|
if (competence) {
|
||||||
const update = { _id: comp.id }
|
const update = { _id: competence.id }
|
||||||
if (fieldName == "niveau")
|
if (fieldName == "niveau")
|
||||||
update['data.niveau'] = compValue;
|
update['data.niveau'] = compValue;
|
||||||
else if (fieldName == "dommages")
|
else if (fieldName == "dommages")
|
||||||
update['data.dommages'] = compValue;
|
update['data.dommages'] = compValue;
|
||||||
else
|
else
|
||||||
update['data.carac_value'] = compValue;
|
update['data.carac_value'] = compValue;
|
||||||
const updated = await this.updateEmbeddedDocuments('Item', [update]); // pdates one EmbeddedEntity
|
await this.updateEmbeddedDocuments('Item', [update]); // updates one EmbeddedEntity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompetence(compName, compValue) {
|
async updateCompetence(idOrName, compValue) {
|
||||||
let comp = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (comp) {
|
if (competence) {
|
||||||
let troncList = RdDItemCompetence.isTronc(compName);
|
let troncList = RdDItemCompetence.isTronc(competence.name);
|
||||||
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(Misc.data(comp).data.categorie);
|
let nouveauNiveau = compValue ?? RdDItemCompetence.getNiveauBase(Misc.data(competence).data.categorie);
|
||||||
if (troncList) {
|
if (troncList) {
|
||||||
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
|
let message = "Vous avez modifié une compétence 'tronc'. Vérifiez que les compétences suivantes évoluent ensemble jusqu'au niveau 0 : ";
|
||||||
for (let troncName of troncList) {
|
for (let troncName of troncList) {
|
||||||
@ -953,50 +953,50 @@ export class RdDActor extends Actor {
|
|||||||
content: message
|
content: message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const update = { _id: comp.id, 'data.niveau': nouveauNiveau };
|
const update = { _id: competence.id, 'data.niveau': nouveauNiveau };
|
||||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||||
} else {
|
} else {
|
||||||
console.log("Competence not found", compName);
|
console.log("Competence not found", idOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompetenceXP(compName, newXp) {
|
async updateCompetenceXP(idOrName, newXp) {
|
||||||
let comp = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (comp) {
|
if (competence) {
|
||||||
if (isNaN(newXp) || typeof (newXp) != 'number') newXp = 0;
|
if (isNaN(newXp) || typeof (newXp) != 'number') newXp = 0;
|
||||||
this.checkCompetenceXP(compName, newXp);
|
this.checkCompetenceXP(idOrName, newXp);
|
||||||
const update = { _id: comp.id, 'data.xp': newXp };
|
const update = { _id: competence.id, 'data.xp': newXp };
|
||||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||||
this.updateExperienceLog("XP", newXp, "XP modifié en " + compName);
|
this.updateExperienceLog("XP", newXp, "XP modifié en " + competence.name);
|
||||||
} else {
|
} else {
|
||||||
console.log("Competence not found", compName);
|
console.log("Competence not found", idOrName);
|
||||||
}
|
}
|
||||||
RdDUtility.checkThanatosXP(compName);
|
RdDUtility.checkThanatosXP(idOrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompetenceXPSort(compName, compValue) {
|
async updateCompetenceXPSort(idOrName, compValue) {
|
||||||
let comp = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (comp) {
|
if (competence) {
|
||||||
if (isNaN(compValue) || typeof (compValue) != 'number') compValue = 0;
|
if (isNaN(compValue) || typeof (compValue) != 'number') compValue = 0;
|
||||||
const update = { _id: comp.id, 'data.xp_sort': compValue };
|
const update = { _id: competence.id, 'data.xp_sort': compValue };
|
||||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||||
this.updateExperienceLog("XP Sort", compValue, "XP modifié en sort de " + compName);
|
this.updateExperienceLog("XP Sort", compValue, "XP modifié en sort de " + competence.name);
|
||||||
} else {
|
} else {
|
||||||
console.log("Competence not found", compName);
|
console.log("Competence not found", idOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async updateCompetenceArchetype(compName, compValue) {
|
async updateCompetenceArchetype(idOrName, compValue) {
|
||||||
let comp = this.getCompetence(compName);
|
let competence = this.getCompetence(idOrName);
|
||||||
if (comp) {
|
if (competence) {
|
||||||
compValue = compValue ?? 0;
|
compValue = compValue ?? 0;
|
||||||
const update = { _id: comp.id, 'data.niveau_archetype': compValue };
|
const update = { _id: competence.id, 'data.niveau_archetype': compValue };
|
||||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||||
} else {
|
} else {
|
||||||
console.log("Competence not found", compName);
|
console.log("Competence not found", idOrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2489,8 +2489,8 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence(name) {
|
async rollCompetence(idOrName) {
|
||||||
let rollData = { competence: Misc.data(this.getCompetence(name)) }
|
let rollData = { competence: Misc.data(this.getCompetence(idOrName)) }
|
||||||
|
|
||||||
//console.log("COMP CREATURE", name, rollData, name);
|
//console.log("COMP CREATURE", name, rollData, name);
|
||||||
if (rollData.competence.type == 'competencecreature') {
|
if (rollData.competence.type == 'competencecreature') {
|
||||||
@ -2510,7 +2510,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html' }, {
|
const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html' }, {
|
||||||
name: 'jet-competence',
|
name: 'jet-competence',
|
||||||
label: 'Jet ' + Grammar.apostrophe('de', name),
|
label: 'Jet ' + Grammar.apostrophe('de', rollData.competence.name),
|
||||||
callbacks: [
|
callbacks: [
|
||||||
this.createCallbackExperience(),
|
this.createCallbackExperience(),
|
||||||
this.createCallbackAppelAuMoral(),
|
this.createCallbackAppelAuMoral(),
|
||||||
|
Loading…
Reference in New Issue
Block a user