Nombreux fixes
* Utilisation de EmbeddedDocuments * utiliser data seulement dans le chemin d'update * utiliser class au lieu de id dans le html * si possible, update de la valuer au lieu d'un duplicate du noeud
This commit is contained in:
@@ -37,7 +37,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
let sheetData = await super.getData();
|
||||
|
||||
sheetData.options = this.options;
|
||||
sheetData.itemsByType = Misc.classify(sheetData.items, item => item.type);
|
||||
sheetData.itemsByType = Misc.classify(sheetData.items);
|
||||
sheetData.options.isGM = game.user.isGM;
|
||||
|
||||
const carac = sheetData.data.data.carac;
|
||||
@@ -56,7 +56,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
sheetData.calc = {
|
||||
comptageArchetype: RdDItemCompetence.computeResumeArchetype(competences),
|
||||
competenceXPTotal: RdDItemCompetence.computeTotalXP(competences),
|
||||
caracTotal: RdDCarac.computeTotal(carac),
|
||||
caracTotal: RdDCarac.computeTotal(carac, sheetData.data.data.beaute),
|
||||
// Mise à jour de l'encombrement total et du prix de l'équipement
|
||||
encTotal: await sheetData.actor.computeEncombrementTotalEtMalusArmure(),
|
||||
prixTotalEquipement: await sheetData.actor.computePrixTotalEquipement(),
|
||||
@@ -73,7 +73,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
RdDItemCompetence.setLevelUp(competences);
|
||||
RdDCarac.setLevelUp(carac);
|
||||
|
||||
sheetData.armes = sheetData.itemsByType.arme;
|
||||
sheetData.armes = duplicate(sheetData.itemsByType.arme);
|
||||
RdDItemArme.computeNiveauArmes(sheetData.armes, competences);
|
||||
RdDItemArme.ajoutCorpsACorps(sheetData.armes, competences, carac);
|
||||
sheetData.esquive = RdDItemCompetence.getEsquive(competences);
|
||||
@@ -124,21 +124,21 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async createEmptyTache() {
|
||||
await this.actor.createOwnedItem({ name: 'Nouvelle tache', type: 'tache' }, { renderSheet: true });
|
||||
await this.actor.createEmbeddedDocuments('Item', [{ name: 'Nouvelle tache', type: 'tache' }], { renderSheet: true });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async creerObjet() {
|
||||
let itemType = $("#creer-equipement").val();
|
||||
await this.actor.createOwnedItem({ name: 'Nouveau ' + itemType, type: itemType }, { renderSheet: true });
|
||||
await this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async selectObjetType() {
|
||||
let itemType = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "monnaie"];
|
||||
let options = '<span class="competence-label">Selectionnez le type d\'équipement</span><select id="creer-equipement">';
|
||||
let options = `<span class="competence-label">Selectionnez le type d'équipement</span><select id="creer-equipement">`;
|
||||
for (let typeName of itemType) {
|
||||
options += '<option value="' + typeName + '">' + typeName + '</option>'
|
||||
options += `<option value="${typeName}"> ${typeName}</option>`
|
||||
}
|
||||
options += '</select>';
|
||||
let d = new Dialog({
|
||||
@@ -158,11 +158,12 @@ export class RdDActorSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
|
||||
super.activateListeners(html);
|
||||
|
||||
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
|
||||
|
||||
html.find('#show-hide-competences').click((event) => {
|
||||
html.find('.show-hide-competences').click((event) => {
|
||||
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
|
||||
this.render(true);
|
||||
});
|
||||
@@ -192,7 +193,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
RdDUtility.confirmerSuppressionSubacteur(this, li);
|
||||
});
|
||||
|
||||
html.find('#encaisser-direct').click(ev => {
|
||||
html.find('.encaisser-direct').click(ev => {
|
||||
this.actor.encaisser();
|
||||
});
|
||||
|
||||
@@ -248,15 +249,15 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.actor.rollCarac(caracName.toLowerCase());
|
||||
});
|
||||
|
||||
html.find('#chance-actuelle').click((event) => {
|
||||
html.find('.chance-actuelle').click((event) => {
|
||||
this.actor.rollCarac('chance-actuelle');
|
||||
});
|
||||
|
||||
html.find('#chance-appel').click((event) => {
|
||||
html.find('.chance-appel').click((event) => {
|
||||
this.actor.rollAppelChance();
|
||||
});
|
||||
|
||||
html.find('#jet-astrologie').click((event) => {
|
||||
html.find('.jet-astrologie').click((event) => {
|
||||
this.actor.astrologieNombresAstraux();
|
||||
});
|
||||
|
||||
@@ -337,45 +338,45 @@ export class RdDActorSheet extends ActorSheet {
|
||||
}
|
||||
});
|
||||
// Display TMR, visuualisation
|
||||
html.find('#visu-tmr').click((event) => {
|
||||
html.find('.visu-tmr').click((event) => {
|
||||
this.actor.displayTMR("visu");
|
||||
});
|
||||
|
||||
// Display TMR, normal
|
||||
html.find('#monte-tmr').click((event) => {
|
||||
html.find('.monte-tmr').click((event) => {
|
||||
this.actor.displayTMR("normal");
|
||||
});
|
||||
|
||||
// Display TMR, fast
|
||||
html.find('#monte-tmr-rapide').click((event) => {
|
||||
html.find('.monte-tmr-rapide').click((event) => {
|
||||
this.actor.displayTMR("rapide");
|
||||
});
|
||||
|
||||
html.find('#dormir-une-heure').click((event) => {
|
||||
html.find('.dormir-une-heure').click((event) => {
|
||||
this.actor.dormir(1);
|
||||
});
|
||||
html.find('#dormir-chateau-dormant').click((event) => {
|
||||
html.find('.dormir-chateau-dormant').click((event) => {
|
||||
this.actor.dormirChateauDormant();
|
||||
});
|
||||
html.find('#enlever-tous-effets').click((event) => {
|
||||
html.find('.enlever-tous-effets').click((event) => {
|
||||
this.actor.enleverTousLesEffets();
|
||||
});
|
||||
// Display info about queue
|
||||
html.find('.queuesouffle-label a').click((event) => {
|
||||
let myID = event.currentTarget.attributes['data-item-id'].value;
|
||||
const item = this.actor.getOwnedItem(myID);
|
||||
const item = this.actor.items.get(myID);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
// Info sort
|
||||
html.find('.sort-label a').click((event) => {
|
||||
let myID = event.currentTarget.attributes['data-id'].value;
|
||||
const item = this.actor.getOwnedItem(myID);
|
||||
const item = this.actor.items.get(myID);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
// Info sort
|
||||
html.find('.case-label a').click((event) => {
|
||||
let myID = event.currentTarget.attributes['data-id'].value;
|
||||
const item = this.actor.getOwnedItem(myID);
|
||||
const item = this.actor.items.get(myID);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
@@ -390,12 +391,10 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// On carac change
|
||||
html.find('.carac-value').change((event) => {
|
||||
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
|
||||
//console.log("Value changed :", event, caracName);
|
||||
this.actor.updateCarac(caracName, parseInt(event.target.value));
|
||||
});
|
||||
html.find('.carac-xp').change((event) => {
|
||||
let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", "");
|
||||
//console.log("Value changed :", event, caracName);
|
||||
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
|
||||
});
|
||||
// On competence change
|
||||
@@ -426,64 +425,61 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.options.editCaracComp = !this.options.editCaracComp;
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#show-hide-archetype').click((event) => {
|
||||
html.find('.show-hide-archetype').click((event) => {
|
||||
this.options.montrerArchetype = !this.options.montrerArchetype;
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
// On pts de reve change
|
||||
html.find('.pointsreve-value').change((event) => {
|
||||
let reveValue = event.currentTarget.value;
|
||||
let reve = duplicate(this.actor.data.data.reve.reve);
|
||||
reve.value = reveValue;
|
||||
this.actor.update({ "data.reve.reve": reve });
|
||||
this.actor.update({ "data.reve.reve.value": parseInt(event.currentTarget.value) });
|
||||
});
|
||||
|
||||
// On seuil de reve change
|
||||
html.find('.seuil-reve-value').change((event) => {
|
||||
console.log("seuil-reve-value", event.currentTarget)
|
||||
this.actor.setPointsDeSeuil(event.currentTarget.value);
|
||||
this.actor.setPointsDeSeuil(parseInt(event.currentTarget.value));
|
||||
});
|
||||
|
||||
html.find('#attribut-protection-edit').change((event) => {
|
||||
this.actor.updateProtectionValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
|
||||
html.find('.attribut-protection-edit').change((event) => {
|
||||
this.actor.updateAttribut(event.currentTarget.attributes.name.value, parseInt(event.target.value));
|
||||
});
|
||||
|
||||
// On stress change
|
||||
html.find('.compteur-edit').change((event) => {
|
||||
let fieldName = event.currentTarget.attributes.name.value;
|
||||
this.actor.updateCompteurValue(fieldName, parseInt(event.target.value));
|
||||
this.actor.updateCompteur(fieldName, parseInt(event.target.value));
|
||||
});
|
||||
|
||||
html.find('#ethylisme').change((event) => {
|
||||
html.find('.ethylisme').change((event) => {
|
||||
this.actor.setEthylisme(parseInt(event.target.value));
|
||||
});
|
||||
html.find('#stress-test').click((event) => {
|
||||
html.find('.stress-test').click((event) => {
|
||||
this.actor.transformerStress();
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#moral-malheureux').click((event) => {
|
||||
html.find('.moral-malheureux').click((event) => {
|
||||
this.actor.jetDeMoral('malheureuse');
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#moral-neutre').click((event) => {
|
||||
html.find('.moral-neutre').click((event) => {
|
||||
this.actor.jetDeMoral('neutre');
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#moral-heureux').click((event) => {
|
||||
html.find('.moral-heureux').click((event) => {
|
||||
this.actor.jetDeMoral('heureuse');
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ethylisme-test').click((event) => {
|
||||
html.find('.ethylisme-test').click((event) => {
|
||||
this.actor.ethylismeTest();
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
html.find('#jet-vie').click((event) => {
|
||||
html.find('.jet-vie').click((event) => {
|
||||
this.actor.jetVie();
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#jet-endurance').click((event) => {
|
||||
html.find('.jet-endurance').click((event) => {
|
||||
this.actor.jetEndurance();
|
||||
this.render(true);
|
||||
});
|
||||
@@ -499,19 +495,19 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
html.find('#vie-plus').click((event) => {
|
||||
html.find('.vie-plus').click((event) => {
|
||||
this.actor.santeIncDec("vie", 1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#vie-moins').click((event) => {
|
||||
html.find('.vie-moins').click((event) => {
|
||||
this.actor.santeIncDec("vie", -1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#endurance-plus').click((event) => {
|
||||
html.find('.endurance-plus').click((event) => {
|
||||
this.actor.santeIncDec("endurance", 1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#endurance-moins').click((event) => {
|
||||
html.find('.endurance-moins').click((event) => {
|
||||
this.actor.santeIncDec("endurance", -1);
|
||||
this.render(true);
|
||||
});
|
||||
@@ -519,25 +515,24 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.actor.setSonne(event.currentTarget.checked);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ptreve-actuel-plus').click((event) => {
|
||||
html.find('.ptreve-actuel-plus').click((event) => {
|
||||
this.actor.reveActuelIncDec(1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ptreve-actuel-moins').click((event) => {
|
||||
html.find('.ptreve-actuel-moins').click((event) => {
|
||||
this.actor.reveActuelIncDec(-1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#fatigue-plus').click((event) => {
|
||||
html.find('.fatigue-plus').click((event) => {
|
||||
this.actor.santeIncDec("fatigue", 1);
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#fatigue-moins').click((event) => {
|
||||
html.find('.fatigue-moins').click((event) => {
|
||||
this.actor.santeIncDec("fatigue", -1);
|
||||
this.render(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
|
||||
Reference in New Issue
Block a user