diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js
index acfd115f..d8187818 100644
--- a/module/actor-creature-sheet.js
+++ b/module/actor-creature-sheet.js
@@ -27,15 +27,15 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
if (!this.options.editable) return;
// On competence change
- html.find('.creature-carac').change(async event => {
+ 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));
});
- html.find('.creature-niveau').change(async event => {
+ this.html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
});
- html.find('.creature-dommages').change(async event => {
+ this.html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
});
diff --git a/module/actor-entite-sheet.js b/module/actor-entite-sheet.js
index 42577475..0b0e54c2 100644
--- a/module/actor-entite-sheet.js
+++ b/module/actor-entite-sheet.js
@@ -23,15 +23,15 @@ export class RdDActorEntiteSheet extends RdDActorSheet {
if (!this.options.editable) return;
// On competence change
- html.find('.creature-carac').change(async event => {
+ 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) );
} );
- html.find('.creature-niveau').change(async event => {
+ this.html.find('.creature-niveau').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) );
} );
- html.find('.creature-dommages').change(async event => {
+ this.html.find('.creature-dommages').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
} );
diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index 7965a19d..6be3f32a 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -118,58 +118,26 @@ export class RdDActorSheet extends ActorSheet {
return formData;
}
- isCompetenceAffichable(competence) {
- return !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(competence);
- }
-
- /* -------------------------------------------- */
- async _onDropActor(event, dragData) {
- const dropActor = fromUuidSync(dragData.uuid);
- this.actor.addSubActeur(dropActor);
- super._onDropActor(event, dragData);
- }
-
- /* -------------------------------------------- */
- async _onDropItem(event, dragData) {
- const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
- const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
- if (dropParams) {
- const callSuper = await this.actor.processDropItem(dropParams)
- if (callSuper) {
- await super._onDropItem(event, dragData)
- }
- }
- }
-
- /* -------------------------------------------- */
- async createItem(name, type) {
- await this.actor.createEmbeddedDocuments('Item', [{ name: name, type: type }], { renderSheet: true });
- }
-
- /* -------------------------------------------- */
- async createEmptyTache() {
- await this.createItem('Nouvelle tache', 'tache');
- }
-
/* -------------------------------------------- */ /** @override */
activateListeners(html) {
super.activateListeners(html);
+ this.html = html;
- HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
+ HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
- html.find('.item-split').click(async event => {
+ this.html.find('.item-split').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
RdDSheetUtility.splitItem(item, this.actor);
});
- html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
- html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
- html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
- html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
- html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor));
- html.find('.subacteur-delete').click(async event => {
+ this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
+ this.html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
+ this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
+ this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
+ this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor));
+ this.html.find('.subacteur-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event);
const actorId = li.data("actor-id");
if (actorId) {
@@ -177,54 +145,54 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.confirmerSuppressionSubacteur(this, subActor, li);
}
});
- html.find('.experiencelog-delete').click(async event => {
- const li = $(event.currentTarget)?.parents(".experiencelog");
+ this.html.find('.experiencelog-delete').click(async event => {
+ const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
const key = Number(li.data("key") ?? -1);
await this.actor.deleteExperienceLog(key, 1);
});
- html.find('.experiencelog-delete-previous').click(async event => {
- const li = $(event.currentTarget)?.parents(".experiencelog");
+ this.html.find('.experiencelog-delete-previous').click(async event => {
+ const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
const key = Number(li.data("key") ?? -1);
await this.actor.deleteExperienceLog(0, key + 1);
});
- html.find('.encaisser-direct').click(async event => {
+ this.html.find('.encaisser-direct').click(async event => {
this.actor.encaisser();
})
- html.find('.sheet-possession-attack').click(async event => {
+ this.html.find('.sheet-possession-attack').click(async event => {
const poss = RdDSheetUtility.getItem(event, this.actor)
this.actor.conjurerPossession(poss)
})
- html.find('.remise-a-neuf').click(async event => {
+ this.html.find('.remise-a-neuf').click(async event => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
});
- html.find('.creer-tache').click(async event => {
+ this.html.find('.creer-tache').click(async event => {
this.createEmptyTache();
});
- html.find('.creer-un-objet').click(async event => {
+ this.html.find('.creer-un-objet').click(async event => {
RdDUtility.selectObjetType(this);
});
- html.find('.creer-une-oeuvre').click(async event => {
+ this.html.find('.creer-une-oeuvre').click(async event => {
RdDUtility.selectTypeOeuvre(this);
});
- html.find('.nettoyer-conteneurs').click(async event => {
+ this.html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs();
});
// Blessure control
- html.find('.blessure-control').click(async event => {
- const tr = $(event.currentTarget).parents(".item");
+ this.html.find('.blessure-control').click(async event => {
+ const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data("blessure-type");
let index = tr.data('blessure-index');
- let active = $(event.currentTarget).data('blessure-active');
+ let active = this.html.find(event.currentTarget).data('blessure-active');
//console.log(btype, index, active);
await this.actor.manageBlessureFromSheet(btype, index, active);
});
// Blessure data
- html.find('.blessure-soins').change(async event => {
- const tr = $(event.currentTarget).parents(".item");
+ this.html.find('.blessure-soins').change(async event => {
+ const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data('blessure-type');
let index = tr.data('blessure-index');
let psoins = tr.find('.blessure-premiers_soins').val();
@@ -238,57 +206,57 @@ export class RdDActorSheet extends ActorSheet {
});
// Equip Inventory Item
- html.find('.item-equip').click(async event => {
+ this.html.find('.item-equip').click(async event => {
this.actor.equiperObjet(RdDSheetUtility.getItemId(event));
});
// Roll Carac
- html.find('.carac-label a').click(async event => {
+ this.html.find('.carac-label a').click(async event => {
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac(caracName.toLowerCase());
});
- html.find('.chance-actuelle').click(async event => {
+ this.html.find('.chance-actuelle').click(async event => {
this.actor.rollCarac('chance-actuelle');
});
- html.find('.chance-appel').click(async event => {
+ this.html.find('.chance-appel').click(async event => {
this.actor.rollAppelChance();
});
- html.find('#jet-astrologie').click(async event => {
+ this.html.find('[name="jet-astrologie"]').click(async event => {
this.actor.astrologieNombresAstraux();
});
// Roll Skill
- html.find('a.competence-label').click(async event => {
+ this.html.find('a.competence-label').click(async event => {
this.actor.rollCompetence(RdDSheetUtility.getItemId(event));
});
- html.find('.tache-label a').click(async event => {
+ this.html.find('.tache-label a').click(async event => {
this.actor.rollTache(RdDSheetUtility.getItemId(event));
});
- html.find('.meditation-label a').click(async event => {
+ this.html.find('.meditation-label a').click(async event => {
this.actor.rollMeditation(RdDSheetUtility.getItemId(event));
});
- html.find('.chant-label a').click(async event => {
+ this.html.find('.chant-label a').click(async event => {
this.actor.rollChant(RdDSheetUtility.getItemId(event));
});
- html.find('.danse-label a').click(async event => {
+ this.html.find('.danse-label a').click(async event => {
this.actor.rollDanse(RdDSheetUtility.getItemId(event));
});
- html.find('.musique-label a').click(async event => {
+ this.html.find('.musique-label a').click(async event => {
this.actor.rollMusique(RdDSheetUtility.getItemId(event));
});
- html.find('.oeuvre-label a').click(async event => {
+ this.html.find('.oeuvre-label a').click(async event => {
this.actor.rollOeuvre(RdDSheetUtility.getItemId(event));
});
- html.find('.jeu-label a').click(async event => {
+ this.html.find('.jeu-label a').click(async event => {
this.actor.rollJeu(RdDSheetUtility.getItemId(event));
});
- html.find('.recettecuisine-label a').click(async event => {
+ this.html.find('.recettecuisine-label a').click(async event => {
this.actor.rollRecetteCuisine(RdDSheetUtility.getItemId(event));
});
- html.find('.subacteur-label a').click(async event => {
+ this.html.find('.subacteur-label a').click(async event => {
let actorId = RdDSheetUtility.getEventItemData(event, 'actor-id');
let actor = game.actors.get(actorId);
if (actor) {
@@ -297,25 +265,25 @@ export class RdDActorSheet extends ActorSheet {
});
// Boutons spéciaux MJs
- html.find('.forcer-tmr-aleatoire').click(async event => {
+ this.html.find('.forcer-tmr-aleatoire').click(async event => {
this.actor.reinsertionAleatoire("Action MJ");
});
- html.find('.afficher-tmr').click(async event => {
+ this.html.find('.afficher-tmr').click(async event => {
this.actor.changeTMRVisible();
});
// Points de reve actuel
- html.find('.ptreve-actuel a').click(async event => {
+ this.html.find('.ptreve-actuel a').click(async event => {
this.actor.rollCarac('reve-actuel');
});
// Roll Weapon1
- html.find('.arme-label a').click(async event => {
+ this.html.find('.arme-label a').click(async event => {
let arme = this._getEventArmeCombat(event);
this.actor.rollArme(duplicate(arme));
});
// Initiative pour l'arme
- html.find('.arme-initiative a').click(async event => {
+ this.html.find('.arme-initiative a').click(async event => {
let combatant = game.combat.combatants.find(c => c.actor.id == this.actor.id);
if (combatant) {
let action = this._getEventArmeCombat(event);
@@ -325,88 +293,88 @@ export class RdDActorSheet extends ActorSheet {
}
});
// Display TMR, visualisation
- html.find('.visu-tmr').click(async event => {
+ this.html.find('.visu-tmr').click(async event => {
this.actor.displayTMR("visu");
});
// Display TMR, normal
- html.find('.monte-tmr').click(async event => {
+ this.html.find('.monte-tmr').click(async event => {
this.actor.displayTMR("normal");
});
// Display TMR, fast
- html.find('.monte-tmr-rapide').click(async event => {
+ this.html.find('.monte-tmr-rapide').click(async event => {
this.actor.displayTMR("rapide");
});
- html.find('.repos').click(async event => {
+ this.html.find('.repos').click(async event => {
await DialogRepos.create(this.actor);
});
- html.find('.delete-active-effect').click(async event => {
+ this.html.find('.delete-active-effect').click(async event => {
if (game.user.isGM) {
- let effect = $(event.currentTarget).parents(".active-effect").data('effect');
+ let effect = this.html.find(event.currentTarget).parents(".active-effect").data('effect');
this.actor.removeEffect(effect);
}
});
- html.find('.enlever-tous-effets').click(async event => {
+ this.html.find('.enlever-tous-effets').click(async event => {
if (game.user.isGM) {
await this.actor.removeEffects();
}
});
- html.find('.conteneur-name a').click(async event => {
+ this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true);
});
- html.find('.carac-xp-augmenter').click(async event => {
+ this.html.find('.carac-xp-augmenter').click(async event => {
let caracName = event.currentTarget.name.replace("augmenter.", "");
this.actor.updateCaracXPAuto(caracName);
});
- html.find('.competence-xp-augmenter').click(async event => {
+ this.html.find('.competence-xp-augmenter').click(async event => {
this.actor.updateCompetenceXPAuto(RdDSheetUtility.getItemId(event));
});
- html.find('.competence-stress-augmenter').click(async event => {
+ this.html.find('.competence-stress-augmenter').click(async event => {
this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event));
});
if (this.options.vueDetaillee) {
// On carac change
- 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.", "");
this.actor.updateCarac(caracName, parseInt(event.target.value));
});
- 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.", "");
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
});
// On competence change
- html.find('.competence-value').change(async event => {
+ 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));
});
// On competence xp change
- html.find('input.competence-xp').change(async event => {
+ this.html.find('input.competence-xp').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceXP(compName, parseInt(event.target.value));
});
// On competence xp change
- 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;
this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value));
});
// On competence archetype change
- html.find('.competence-archetype').change(async event => {
+ this.html.find('.competence-archetype').change(async event => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.value));
});
}
- html.find('.show-hide-competences').click(async event => {
+ this.html.find('.show-hide-competences').click(async event => {
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true);
});
- html.find('.recherche')
+ this.html.find('.recherche')
.each((index, field) => {
if (this.options.recherche) {
field.focus();
@@ -429,92 +397,125 @@ export class RdDActorSheet extends ActorSheet {
.change(async event =>
this.options.recherche = this._optionRecherche(event.currentTarget)
);
- html.find('.vue-detaillee').click(async event => {
+ this.html.find('.vue-detaillee').click(async event => {
this.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true);
});
// On pts de reve change
- html.find('.pointsreve-value').change(async event => {
+ this.html.find('.pointsreve-value').change(async event => {
let reveValue = event.currentTarget.value;
this.actor.update({ "system.reve.reve.value": reveValue });
});
// On seuil de reve change
- html.find('.seuil-reve-value').change(async event => {
+ this.html.find('.seuil-reve-value').change(async event => {
console.log("seuil-reve-value", event.currentTarget)
this.actor.setPointsDeSeuil(event.currentTarget.value);
});
- html.find('#attribut-protection-edit').change(async event => {
+ this.html.find('#attribut-protection-edit').change(async event => {
this.actor.updateAttributeValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
});
// On stress change
- html.find('.compteur-edit').change(async event => {
+ this.html.find('.compteur-edit').change(async event => {
let fieldName = event.currentTarget.attributes.name.value;
this.actor.updateCompteurValue(fieldName, parseInt(event.target.value));
});
- html.find('#ethylisme').change(async event => {
+ this.html.find('#ethylisme').change(async event => {
this.actor.setEthylisme(parseInt(event.target.value));
});
- html.find('.stress-test').click(async event => {
+ this.html.find('.stress-test').click(async event => {
this.actor.transformerStress();
});
- html.find('.moral-malheureux').click(async event => {
+ this.html.find('.moral-malheureux').click(async event => {
this.actor.jetDeMoral('malheureuse');
});
- html.find('.moral-neutre').click(async event => {
+ this.html.find('.moral-neutre').click(async event => {
this.actor.jetDeMoral('neutre');
});
- html.find('.moral-heureux').click(async event => {
+ this.html.find('.moral-heureux').click(async event => {
this.actor.jetDeMoral('heureuse');
});
- html.find('.ethylisme-test').click(async event => {
+ this.html.find('.ethylisme-test').click(async event => {
this.actor.jetEthylisme();
});
- html.find('.jet-vie').click(async event => {
+ this.html.find('.jet-vie').click(async event => {
this.actor.jetVie();
});
- html.find('.jet-endurance').click(async event => {
+ this.html.find('.jet-endurance').click(async event => {
this.actor.jetEndurance();
});
- html.find('.monnaie-plus').click(async event => {
+ this.html.find('.monnaie-plus').click(async event => {
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), 1);
});
- html.find('.monnaie-moins').click(async event => {
+ this.html.find('.monnaie-moins').click(async event => {
this.actor.monnaieIncDec(RdDSheetUtility.getItemId(event), -1);
});
- html.find('.vie-plus').click(async event => {
+ this.html.find('.vie-plus').click(async event => {
this.actor.santeIncDec("vie", 1);
});
- html.find('.vie-moins').click(async event => {
+ this.html.find('.vie-moins').click(async event => {
this.actor.santeIncDec("vie", -1);
});
- html.find('.endurance-plus').click(async event => {
+ this.html.find('.endurance-plus').click(async event => {
this.actor.santeIncDec("endurance", 1);
});
- html.find('.endurance-moins').click(async event => {
+ this.html.find('.endurance-moins').click(async event => {
this.actor.santeIncDec("endurance", -1);
});
- html.find('.ptreve-actuel-plus').click(async event => {
+ this.html.find('.ptreve-actuel-plus').click(async event => {
this.actor.reveActuelIncDec(1);
});
- html.find('.ptreve-actuel-moins').click(async event => {
+ this.html.find('.ptreve-actuel-moins').click(async event => {
this.actor.reveActuelIncDec(-1);
});
- html.find('.fatigue-plus').click(async event => {
+ this.html.find('.fatigue-plus').click(async event => {
this.actor.santeIncDec("fatigue", 1);
});
- html.find('.fatigue-moins').click(async event => {
+ this.html.find('.fatigue-moins').click(async event => {
this.actor.santeIncDec("fatigue", -1);
});
}
+ isCompetenceAffichable(competence) {
+ return !this.options.showCompNiveauBase || !RdDItemCompetence.isNiveauBase(competence);
+ }
+
+ /* -------------------------------------------- */
+ async _onDropActor(event, dragData) {
+ const dropActor = fromUuidSync(dragData.uuid);
+ this.actor.addSubActeur(dropActor);
+ super._onDropActor(event, dragData);
+ }
+
+ /* -------------------------------------------- */
+ async _onDropItem(event, dragData) {
+ const destItemId = this.html.find(event.target)?.closest('.item').attr('data-item-id')
+ const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
+ if (dropParams) {
+ const callSuper = await this.actor.processDropItem(dropParams)
+ if (callSuper) {
+ await super._onDropItem(event, dragData)
+ }
+ }
+ }
+
+ /* -------------------------------------------- */
+ async createItem(name, type) {
+ await this.actor.createEmbeddedDocuments('Item', [{ name: name, type: type }], { renderSheet: true });
+ }
+
+ /* -------------------------------------------- */
+ async createEmptyTache() {
+ await this.createItem('Nouvelle tache', 'tache');
+ }
+
_optionRecherche(target) {
if (!target.value?.length){
return undefined;
@@ -527,7 +528,7 @@ export class RdDActorSheet extends ActorSheet {
}
_getEventArmeCombat(event) {
- const li = $(event.currentTarget)?.parents(".item");
+ const li = this.html.find(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.system.competence == compName);
diff --git a/module/actor-vehicule-sheet.js b/module/actor-vehicule-sheet.js
index 5803f3f7..0124de0c 100644
--- a/module/actor-vehicule-sheet.js
+++ b/module/actor-vehicule-sheet.js
@@ -22,16 +22,16 @@ export class RdDActorVehiculeSheet extends RdDActorSheet {
super.activateListeners(html);
if (!this.options.editable) return;
- html.find('.resistance-moins').click(async event => {
+ this.html.find('.resistance-moins').click(async event => {
this.actor.vehicleIncDec("resistance", -1);
});
- html.find('.resistance-plus').click(async event => {
+ this.html.find('.resistance-plus').click(async event => {
this.actor.vehicleIncDec("resistance", 1);
});
- html.find('.structure-moins').click(async event => {
+ this.html.find('.structure-moins').click(async event => {
this.actor.vehicleIncDec("structure", -1);
});
- html.find('.structure-plus').click(async event => {
+ this.html.find('.structure-plus').click(async event => {
this.actor.vehicleIncDec("structure", 1);
});
}
diff --git a/module/actor.js b/module/actor.js
index f8c6ea1c..d4106077 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -150,17 +150,6 @@ export class RdDActor extends Actor {
this.computeEtatGeneral();
}
- /* -------------------------------------------- */
- setRollWindowsOpened(flag) {
- // TODO: résoudre le souci lié aux ids dans les fenêtres roll
- this.rollWindowsOpened = flag;
- }
-
- /* -------------------------------------------- */
- isRollWindowsOpened() {
- return this.rollWindowsOpened;
- }
-
/* -------------------------------------------- */
_prepareCreatureData(actorData) {
this.computeEncombrementTotalEtMalusArmure();
@@ -601,11 +590,14 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async _jetRecuperationConstitution(bonusSoins, message = undefined) {
- const tData = this.system;
- let difficulte = Misc.toInt(bonusSoins) + Math.min(0, tData.sante.vie.value - tData.sante.vie.max);
- let rolled = await RdDResolutionTable.roll(tData.carac.constitution.value, difficulte);
+ let difficulte = Misc.toInt(bonusSoins) + Math.min(0, this.system.sante.vie.value - this.system.sante.vie.max);
+ let rolled = await RdDResolutionTable.roll(this.system.carac.constitution.value, difficulte);
if (message) {
- message.content += RdDResolutionTable.explain(rolled).replace(/Jet :/, "Constitution :");
+ message.content = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/roll/explain.hbs", {
+ actor: this,
+ carac: this.system.carac.constitution,
+ rolled
+ })
}
return rolled;
}
@@ -3422,9 +3414,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async encaisser() {
- let dialogData = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
- let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', dialogData);
- new RdDEncaisser(html, this).render(true);
+ await RdDEncaisser.encaisser(this);
}
/* -------------------------------------------- */
@@ -3600,17 +3590,17 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async accorder(entite, when = 'avant-encaissement') {
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
+ || entite == undefined
|| !entite.isEntite([ENTITE_INCARNE])
|| entite.isEntiteAccordee(this)) {
return true;
}
- const tplData = this.system;
- let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value));
+ const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value));
const rollData = {
alias: this.name,
rolled: rolled,
entite: entite.name,
- selectedCarac: tplData.carac.reve
+ selectedCarac: this.system.carac.reve
};
if (rolled.isSuccess) {
diff --git a/module/dialog-chronologie.js b/module/dialog-chronologie.js
index 98762087..c86dd519 100644
--- a/module/dialog-chronologie.js
+++ b/module/dialog-chronologie.js
@@ -62,6 +62,7 @@ export class DialogChronologie extends Dialog {
activateListeners(html) {
super.activateListeners(html);
+ this.html = html;
}
async ajouter() {
@@ -74,11 +75,11 @@ export class DialogChronologie extends Dialog {
}
async forceValidation() {
- await $("form.rdddialogchrono :input").change();
+ await this.html.find("form.rdddialogchrono :input").change();
}
findJournal() {
- const journalId = $("form.rdddialogchrono :input[name='journalId']").val();
+ const journalId = this.html.find("form.rdddialogchrono :input[name='journalId']").val();
const journalEntry = game.journal.get(journalId);
return { journalId, journalEntry };
}
@@ -89,15 +90,15 @@ export class DialogChronologie extends Dialog {
extractJournalParameters() {
return {
- auteur: $("form.rdddialogchrono :input[name='auteur']").val(),
- information: $("form.rdddialogchrono :input[name='information']").val(),
+ auteur: this.html.find("form.rdddialogchrono :input[name='auteur']").val(),
+ information: this.html.find("form.rdddialogchrono :input[name='information']").val(),
dateRdD: {
- jour: $("form.rdddialogchrono :input[name='jourRdD']").val(),
- moisRdD: $("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(),
- annee: $("form.rdddialogchrono :input[name='dateRdD.annee']").val()
+ jour: this.html.find("form.rdddialogchrono :input[name='jourRdD']").val(),
+ moisRdD: this.html.find("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(),
+ annee: this.html.find("form.rdddialogchrono :input[name='dateRdD.annee']").val()
},
- heureRdD: $("form.rdddialogchrono :input[name='heureRdD']").val(),
- dateReel: $("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ')
+ heureRdD: this.html.find("form.rdddialogchrono :input[name='heureRdD']").val(),
+ dateReel: this.html.find("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ')
}
}
diff --git a/module/dialog-create-signedraconique.js b/module/dialog-create-signedraconique.js
index 2b4aa444..86b98d45 100644
--- a/module/dialog-create-signedraconique.js
+++ b/module/dialog-create-signedraconique.js
@@ -35,16 +35,16 @@ export class DialogCreateSigneDraconique extends Dialog {
super(conf, options);
this.dialogData = dialogData;
}
-
+
async _onCreerSigneActeurs() {
- await $("[name='signe.system.ephemere']").change();
- await $(".signe-xp-sort").change();
+ await this.html.find("[name='signe.system.ephemere']").change();
+ await this.html.find(".signe-xp-sort").change();
this.validerSigne();
this.dialogData.actors.filter(it => it.selected)
- .map(it => game.actors.get(it.id))
- .forEach(actor => this._createSigneForActor(actor, this.dialogData.signe));
+ .map(it => game.actors.get(it.id))
+ .forEach(actor => this._createSigneForActor(actor, this.dialogData.signe));
}
-
+
async _createSigneForActor(actor, signe) {
actor.createEmbeddedDocuments("Item", [signe]);
ChatMessage.create({
@@ -57,19 +57,20 @@ export class DialogCreateSigneDraconique extends Dialog {
}
validerSigne() {
- this.dialogData.signe.name = $("[name='signe.name']").val();
- this.dialogData.signe.system.valeur.norm = $("[name='signe.system.valeur.norm']").val();
- this.dialogData.signe.system.valeur.sign = $("[name='signe.system.valeur.sign']").val();
- this.dialogData.signe.system.valeur.part = $("[name='signe.system.valeur.part']").val();
- this.dialogData.signe.system.difficulte = $("[name='signe.system.difficulte']").val();
- this.dialogData.signe.system.ephemere = $("[name='signe.system.ephemere']").prop("checked");
- this.dialogData.signe.system.duree = $("[name='signe.system.duree']").val();
+ this.dialogData.signe.name = this.html.find("[name='signe.name']").val();
+ this.dialogData.signe.system.valeur.norm = this.html.find("[name='signe.system.valeur.norm']").val();
+ this.dialogData.signe.system.valeur.sign = this.html.find("[name='signe.system.valeur.sign']").val();
+ this.dialogData.signe.system.valeur.part = this.html.find("[name='signe.system.valeur.part']").val();
+ this.dialogData.signe.system.difficulte = this.html.find("[name='signe.system.difficulte']").val();
+ this.dialogData.signe.system.ephemere = this.html.find("[name='signe.system.ephemere']").prop("checked");
+ this.dialogData.signe.system.duree = this.html.find("[name='signe.system.duree']").val();
this.dialogData.signe.system.typesTMR = TMRUtility.buildListTypesTMRSelection(this.dialogData.tmrs);
}
-
+
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
+ this.html = html;
this.setEphemere(this.dialogData.signe.system.ephemere);
html.find(".signe-aleatoire").click(event => this.setSigneAleatoire());
html.find("[name='signe.system.ephemere']").change((event) => this.setEphemere(event.currentTarget.checked));
@@ -81,27 +82,27 @@ export class DialogCreateSigneDraconique extends Dialog {
async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true});
- $("[name='signe.name']").val(newSigne.name);
- $("[name='signe.system.valeur.norm']").val(newSigne.system.valeur.norm);
- $("[name='signe.system.valeur.sign']").val(newSigne.system.valeur.sign);
- $("[name='signe.system.valeur.part']").val(newSigne.system.valeur.part);
- $("[name='signe.system.difficulte']").val(newSigne.system.difficulte);
- $("[name='signe.system.duree']").val(newSigne.system.duree);
- $("[name='signe.system.ephemere']").prop("checked", newSigne.system.ephemere);
+ this.html.find("[name='signe.name']").val(newSigne.name);
+ this.html.find("[name='signe.system.valeur.norm']").val(newSigne.system.valeur.norm);
+ this.html.find("[name='signe.system.valeur.sign']").val(newSigne.system.valeur.sign);
+ this.html.find("[name='signe.system.valeur.part']").val(newSigne.system.valeur.part);
+ this.html.find("[name='signe.system.difficulte']").val(newSigne.system.difficulte);
+ this.html.find("[name='signe.system.duree']").val(newSigne.system.duree);
+ this.html.find("[name='signe.system.ephemere']").prop("checked", newSigne.system.ephemere);
this.dialogData.tmrs = TMRUtility.buildSelectionTypesTMR(newSigne.system.typesTMR);
this.dialogData.tmrs.forEach(t => {
- $(`[data-tmr-name='${t.name}']`).prop( "checked", t.selected);
+ this.html.find(`[data-tmr-name='${t.name}']`).prop( "checked", t.selected);
})
this.setEphemere(newSigne.system.ephemere);
}
async setEphemere(ephemere) {
this.dialogData.signe.system.ephemere = ephemere;
- HtmlUtility._showControlWhen($(".signe-system-duree"), ephemere);
+ HtmlUtility._showControlWhen(this.html.find(".signe-system-duree"), ephemere);
}
async onSelectActor(event) {
- const actorId = $(event.currentTarget)?.data("actor-id");
+ const actorId = this.html.find(event.currentTarget)?.data("actor-id");
const actor = this.dialogData.actors.find(it => it.id == actorId);
if (actor) {
actor.selected = event.currentTarget.checked;
@@ -109,7 +110,7 @@ export class DialogCreateSigneDraconique extends Dialog {
}
onSelectTmr(event) {
- const tmrName = $(event.currentTarget)?.data("tmr-name");
+ const tmrName = this.html.find(event.currentTarget)?.data("tmr-name");
const onTmr = this.tmrs.find(it => it.name == tmrName);
if (onTmr){
onTmr.selected = event.currentTarget.checked;
diff --git a/module/dialog-fabriquer-potion.js b/module/dialog-fabriquer-potion.js
index a8571c5a..3d3dd236 100644
--- a/module/dialog-fabriquer-potion.js
+++ b/module/dialog-fabriquer-potion.js
@@ -13,18 +13,12 @@ export class DialogFabriquerPotion extends Dialog {
}
let potionData = DialogFabriquerPotion.prepareData(actor, item);
- let conf = {
- title: `Fabriquer une potion de ${potionData.system.categorie}`,
- content: await renderTemplate(dialogConfig.html, potionData),
- default: potionData.buttonName,
- };
+ const html = await renderTemplate(dialogConfig.html, potionData);
let options = { classes: ["dialogfabriquerpotion"], width: 600, height: 160, 'z-index': 99999 };
mergeObject(options, dialogConfig.options ?? {}, { overwrite: true })
- const dialog = new DialogFabriquerPotion(actor, potionData, conf, options);
- dialog.render(true);
- return dialog;
+ new DialogFabriquerPotion(actor, potionData, html, options).render(true);
}
/* -------------------------------------------- */
@@ -40,10 +34,15 @@ export class DialogFabriquerPotion extends Dialog {
}
/* -------------------------------------------- */
- constructor(actor, potionData, conf, options) {
- conf.buttons = {
- [potionData.buttonName]: {
- label: potionData.buttonName, callback: it => this.onFabriquer(it)
+ constructor(actor, potionData, html, options) {
+ const conf = {
+ title: `Fabriquer une potion de ${potionData.system.categorie}`,
+ content: html,
+ default: 'fabriquer',
+ buttons: {
+ 'fabriquer': {
+ label: potionData.buttonName, callback: it => this.onFabriquer(html)
+ }
}
};
@@ -53,6 +52,24 @@ export class DialogFabriquerPotion extends Dialog {
this.potionData = potionData;
}
+ /* -------------------------------------------- */
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ this.html.find("[name='nbBrins']").change(event => {
+ this.potionData.nbBrins = Misc.toInt(event.currentTarget.value);
+ const brinsManquants = Math.max(0, DialogFabriquerPotion.nombreBrinsOptimal(this.potionData) - this.potionData.nbBrins);
+ this.potionData.herbebonus = Math.max(0, this.potionData.system.niveau - brinsManquants)
+ });
+ }
+
+ /* -------------------------------------------- */
+ async onFabriquer(html) {
+ await this.html.find("[name='nbBrins']").change();
+ this.actor.fabriquerPotion(this.potionData);
+ this.close();
+ }
+
static nombreBrinsMinimum(herbeData) {
switch (herbeData.system.categorie ?? '') {
case "Soin": return 1 + Math.max(0, 12 - 2 * herbeData.system.niveau);
@@ -68,22 +85,4 @@ export class DialogFabriquerPotion extends Dialog {
}
return 1;
}
-
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
-
- html.find("#nbBrins").change(event => {
- this.potionData.nbBrins = Misc.toInt(event.currentTarget.value);
- const brinsManquants = Math.max(0, DialogFabriquerPotion.nombreBrinsOptimal(this.potionData) - this.potionData.nbBrins);
- this.potionData.herbebonus = Math.max(0, this.potionData.system.niveau - brinsManquants)
- });
- }
-
- /* -------------------------------------------- */
- async onFabriquer(it) {
- await $("#nbBrins").change();
- this.actor.fabriquerPotion(this.potionData);
- this.close();
- }
}
\ No newline at end of file
diff --git a/module/dialog-item-achat.js b/module/dialog-item-achat.js
index 649b1545..01162e97 100644
--- a/module/dialog-item-achat.js
+++ b/module/dialog-item-achat.js
@@ -42,8 +42,7 @@ export class DialogItemAchat extends Dialog {
static async onAcheter(venteData) {
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData);
- const dialog = new DialogItemAchat(html, venteData);
- dialog.render(true);
+ new DialogItemAchat(html, venteData).render(true);
}
constructor(html, venteData) {
@@ -65,12 +64,11 @@ export class DialogItemAchat extends Dialog {
};
super(conf, options);
-
this.venteData = venteData;
}
async onAchat() {
- await $(".nombreLots").change();
+ await this.html.find(".nombreLots").change();
(this.venteData.vendeur ?? this.venteData.acheteur).achatVente({
userId: game.user.id,
vendeurId: this.venteData.vendeur?.id,
@@ -90,9 +88,9 @@ export class DialogItemAchat extends Dialog {
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
-
- html.find(".nombreLots").change(event => this.setNombreLots(Number(event.currentTarget.value)));
- html.find(".se-forcer").change(event => this.setSeForcer(event));
+ this.html = html;
+ this.html.find(".nombreLots").change(event => this.setNombreLots(Number(event.currentTarget.value)));
+ this.html.find(".se-forcer").change(event => this.setSeForcer(event));
}
setSeForcer(event) {
@@ -105,8 +103,8 @@ export class DialogItemAchat extends Dialog {
}
this.venteData.choix.nombreLots = Math.min(nombreLots, this.venteData.quantiteNbLots);
this.venteData.prixTotal = (nombreLots * this.venteData.prixLot).toFixed(2);
- $(".nombreLots").val(this.venteData.choix.nombreLots);
- $(".prixTotal").text(this.venteData.prixTotal);
+ this.html.find(".nombreLots").val(this.venteData.choix.nombreLots);
+ this.html.find(".prixTotal").text(this.venteData.prixTotal);
}
}
\ No newline at end of file
diff --git a/module/dialog-item-consommer.js b/module/dialog-item-consommer.js
index 69642e7d..d669b5e9 100644
--- a/module/dialog-item-consommer.js
+++ b/module/dialog-item-consommer.js
@@ -17,7 +17,7 @@ export class DialogConsommer extends Dialog {
buttons: {
[consommerData.buttonName]: {
label: consommerData.buttonName, callback: async it => {
- await this.onConsommer(it);
+ await this.onConsommer();
await onActionItem();
}
}
@@ -31,9 +31,16 @@ export class DialogConsommer extends Dialog {
this.consommerData = consommerData;
}
- async onConsommer(event) {
- await $(".se-forcer").change();
- await $(".consommer-doses").change();
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ this.html.find(".se-forcer").change(event => this.setSeForcer(event));
+ this.html.find(".consommer-doses").change(event => this.selectDoses(event));
+ }
+
+ async onConsommer() {
+ await this.html.find(".se-forcer").change();
+ await this.html.find(".consommer-doses").change();
await this.actor.consommer(this.item, this.consommerData.choix);
}
@@ -92,14 +99,6 @@ export class DialogConsommer extends Dialog {
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
- html.find(".se-forcer").change(event => this.setSeForcer(event));
- html.find(".consommer-doses").change(event => this.selectDoses(event));
- }
-
-
setSeForcer(event) {
this.consommerData.choix.seForcer = event.currentTarget.checked;
}
@@ -107,7 +106,7 @@ export class DialogConsommer extends Dialog {
selectDoses(event) {
this.consommerData.choix.doses = Number(event.currentTarget.value);
DialogConsommer.calculDoses(this.consommerData, this.item);
- $(".total-sust").text(this.consommerData.totalSust);
- $(".total-desaltere").text(this.consommerData.totalDesaltere);
+ this.html.find(".total-sust").text(this.consommerData.totalSust);
+ this.html.find(".total-desaltere").text(this.consommerData.totalDesaltere);
}
}
\ No newline at end of file
diff --git a/module/dialog-item-vente.js b/module/dialog-item-vente.js
index 32639eef..2b09b60b 100644
--- a/module/dialog-item-vente.js
+++ b/module/dialog-item-vente.js
@@ -37,26 +37,26 @@ export class DialogItemVente extends Dialog {
this.venteData = venteData;
}
- async onProposer(it) {
- await $(".tailleLot").change();
- await $(".quantiteNbLots").change();
- await $(".quantiteIllimite").change();
- await $(".prixLot").change();
- this.callback(this.venteData);
- }
-
- /* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
+ this.html = html;
+ HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
- HtmlUtility._showControlWhen($(".quantiteNbLots"), !this.venteData.quantiteIllimite)
-
- html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value)));
- html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
- html.find(".quantiteIllimite").change(event => this.setQuantiteIllimite(event.currentTarget.checked));
- html.find(".prixLot").change(event => this.setPrixLot(Number(event.currentTarget.value)));
+ this.html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value)));
+ this.html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
+ this.html.find(".quantiteIllimite").change(event => this.setQuantiteIllimite(event.currentTarget.checked));
+ this.html.find(".prixLot").change(event => this.setPrixLot(Number(event.currentTarget.value)));
}
+ async onProposer(it) {
+ await this.html.find(".tailleLot").change();
+ await this.html.find(".quantiteNbLots").change();
+ await this.html.find(".quantiteIllimite").change();
+ await this.html.find(".prixLot").change();
+ this.callback(this.venteData);
+ }
+
+ /* -------------------------------------------- */
setPrixLot(prixLot) {
this.venteData.prixLot = prixLot;
}
@@ -65,15 +65,15 @@ export class DialogItemVente extends Dialog {
// recalculer le prix du lot
if (tailleLot != this.venteData.tailleLot) {
this.venteData.prixLot = (tailleLot * this.venteData.prixOrigine).toFixed(2);
- $(".prixLot").val(this.venteData.prixLot);
+ this.html.find(".prixLot").val(this.venteData.prixLot);
}
this.venteData.tailleLot = tailleLot;
if (this.venteData.isOwned) {
// recalculer le nombre de lots max
this.venteData.quantiteMaxLots = Math.floor(this.venteData.quantiteMax / tailleLot);
this.venteData.quantiteNbLots = Math.min(this.venteData.quantiteMaxLots, this.venteData.quantiteNbLots);
- $(".quantiteNbLots").val(this.venteData.quantiteNbLots);
- $(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots)
+ this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
+ this.html.find(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots)
}
}
@@ -82,12 +82,12 @@ export class DialogItemVente extends Dialog {
nbLots = Math.max(0, Math.min(nbLots, this.venteData.quantiteMaxLots));
}
this.venteData.quantiteNbLots = nbLots;
- $(".quantiteNbLots").val(this.venteData.quantiteNbLots);
+ this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
}
setQuantiteIllimite(checked) {
this.venteData.quantiteIllimite = checked;
- $(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles");
- HtmlUtility._showControlWhen($(".quantiteNbLots"), !this.venteData.quantiteIllimite)
+ this.html.find(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles");
+ HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
}
}
\ No newline at end of file
diff --git a/module/dialog-repos.js b/module/dialog-repos.js
index 324b6d91..e5e10576 100644
--- a/module/dialog-repos.js
+++ b/module/dialog-repos.js
@@ -21,13 +21,18 @@ export class DialogRepos extends Dialog {
super(conf, options);
this.actor = actor;
}
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ }
+ /* -------------------------------------------- */
async repos() {
- await $("[name='nb-heures']").change();
- await $("[name='nb-jours']").change();
- const selection = await $("[name='repos']:checked").val();
- const nbHeures = Number.parseInt(await $("[name='nb-heures']").val());
- const nbJours = Number.parseInt(await $("[name='nb-jours']").val());
+ await this.html.find("[name='nb-heures']").change();
+ await this.html.find("[name='nb-jours']").change();
+ const selection = await this.html.find("[name='repos']:checked").val();
+ const nbHeures = Number.parseInt(await this.html.find("[name='nb-heures']").val());
+ const nbJours = Number.parseInt(await this.html.find("[name='nb-jours']").val());
switch (selection) {
case "sieste": {
await this.actor.dormir(nbHeures);
@@ -35,7 +40,7 @@ export class DialogRepos extends Dialog {
}
case "nuit": {
let heuresDormies = await this.actor.dormir(nbHeures);
- if (heuresDormies == nbHeures){
+ if (heuresDormies == nbHeures) {
await this.actor.dormirChateauDormant();
}
return;
@@ -49,8 +54,4 @@ export class DialogRepos extends Dialog {
}
}
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
- }
}
\ No newline at end of file
diff --git a/module/dialog-select-target.js b/module/dialog-select-target.js
index 87f504f3..dd6140ff 100644
--- a/module/dialog-select-target.js
+++ b/module/dialog-select-target.js
@@ -20,8 +20,9 @@ export class DialogSelectTarget extends Dialog {
activateListeners(html) {
super.activateListeners(html);
- html.find("li.select-target").click((event) => {
- this.targetSelected($(event.currentTarget)?.data("token-id"));
+ this.html = html;
+ this.html.find("li.select-target").click((event) => {
+ this.targetSelected(this.html.find(event.currentTarget)?.data("token-id"));
});
}
diff --git a/module/dialog-split-item.js b/module/dialog-split-item.js
index d5ba3298..4b21c6ef 100644
--- a/module/dialog-split-item.js
+++ b/module/dialog-split-item.js
@@ -13,39 +13,33 @@ export class DialogSplitItem extends Dialog {
constructor(item, splitData, html, callback) {
let options = { classes: ["dialogsplit"], width: 300, height: 160, 'z-index': 99999 };
-
let conf = {
title: "Séparer en deux",
content: html,
default: "separer",
buttons: {
- "separer": {
- label: "Séparer", callback: it => {
- this.onSplit();
- }
- }
+ "separer": { label: "Séparer", callback: it => this.onSplit() }
}
};
-
super(conf, options);
-
+
this.callback = callback;
this.item = item;
this.splitData = splitData;
}
- async onSplit(){
- await $(".choix-quantite").change();
- this.callback(this.item, this.splitData.choix.quantite);
- }
-
- /* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
-
- html.find(".choix-quantite").change(event => {
+ this.html = html;
+ this.html.find(".choix-quantite").change(event => {
this.splitData.choix.quantite = Number(event.currentTarget.value);
});
}
+ /* -------------------------------------------- */
+ async onSplit() {
+ await this.html.find(".choix-quantite").change();
+ this.callback(this.item, this.splitData.choix.quantite);
+ }
+
}
\ No newline at end of file
diff --git a/module/dialog-stress.js b/module/dialog-stress.js
index 6ec1efb5..f0b9b8e6 100644
--- a/module/dialog-stress.js
+++ b/module/dialog-stress.js
@@ -37,24 +37,24 @@ export class DialogStress extends Dialog {
this.dialogData = dialogData;
}
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ this.html.find("input.select-actor").change((event) => this.onSelectActor(event));
+ }
+
async onStress() {
- const motif = $("form.rdddialogstress input[name='motif']").val();
- const stress = Number($("form.rdddialogstress input[name='stress']").val());
- const compteur = ($("form.rdddialogstress input[name='immediat']").prop("checked")) ? 'experience' : 'stress';
+ const motif = this.html.find("form.rdddialogstress input[name='motif']").val();
+ const stress = Number(this.html.find("form.rdddialogstress input[name='stress']").val());
+ const compteur = (this.html.find("form.rdddialogstress input[name='immediat']").prop("checked")) ? 'experience' : 'stress';
this.dialogData.actors.filter(it => it.selected)
.map(it => game.actors.get(it.id))
.forEach(actor => actor.distribuerStress(compteur, stress, motif));
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
- html.find("input.select-actor").change((event) => this.onSelectActor(event));
- }
-
async onSelectActor(event) {
- const actorId = $(event.currentTarget)?.data("actor-id");
+ const actorId = this.html.find(event.currentTarget)?.data("actor-id");
const actor = this.dialogData.actors.find(it => it.id == actorId);
if (actor) {
actor.selected = event.currentTarget.checked;
diff --git a/module/dialog-validation-encaissement.js b/module/dialog-validation-encaissement.js
index addcf45c..a5d092ea 100644
--- a/module/dialog-validation-encaissement.js
+++ b/module/dialog-validation-encaissement.js
@@ -35,7 +35,7 @@ export class DialogValidationEncaissement extends Dialog {
}
let dialogOptions = {
- classes: ["rdddialog"],
+ classes: ["rdd-roll-dialog"],
width: 350,
height: 290
}
@@ -55,11 +55,12 @@ export class DialogValidationEncaissement extends Dialog {
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
- html.find('input.encaissement-roll-result').keyup(async event => {
+ this.html = html;
+ this.html.find('input.encaissement-roll-result').keyup(async event => {
this.forceDiceResult.total = event.currentTarget.value;
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: HIDE_DICE, forceDiceResult: this.forceDiceResult});
- $('label.encaissement-total').text(this.encaissement.total);
- $('label.encaissement-blessure').text(this.encaissement.blessures)
+ this.html.find('label.encaissement-total').text(this.encaissement.total);
+ this.html.find('label.encaissement-blessure').text(this.encaissement.blessures)
});
}
diff --git a/module/environnement.js b/module/environnement.js
index eebc6834..0f278278 100644
--- a/module/environnement.js
+++ b/module/environnement.js
@@ -147,29 +147,29 @@ export class EnvironmentSheetHelper {
});
}
- static activateListeners(sheet, html) {
+ static activateListeners(sheet) {
if (!sheet.options.editable) return;
- html.find("input.input-selection-milieu").keypress(event => {
+ sheet.html.find("input.input-selection-milieu").keypress(event => {
if (event.keyCode == '13') {
- EnvironmentSheetHelper.onAddMilieu(html, sheet, event);
+ EnvironmentSheetHelper.onAddMilieu(sheet, event);
}
event.stopPropagation();
})
- html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(html, sheet, event));
- html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event));
- html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event,
- updated => EnvironmentSheetHelper.$changeRarete(event, updated)));
- html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event,
- updated => EnvironmentSheetHelper.$changeFrequence(updated, event)));
+ sheet.html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(sheet, event));
+ sheet.html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event));
+ sheet.html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event,
+ updated => EnvironmentSheetHelper.$changeRarete(sheet, event, updated)));
+ sheet.html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event,
+ updated => EnvironmentSheetHelper.$changeFrequence(sheet, event, updated)));
}
- static $changeFrequence(updated, event) {
- updated.frequence = Number($(event.currentTarget).val());
+ static $changeFrequence(sheet, event, updated) {
+ updated.frequence = Number(sheet.html.find(event.currentTarget).val());
}
- static $changeRarete(event, updated) {
- const name = $(event.currentTarget).val();
+ static $changeRarete(sheet, event, updated) {
+ const name = sheet.html.find(event.currentTarget).val();
const rarete = Environnement.getRarete(name);
updated.rarete = rarete.name;
updated.frequence = rarete.frequence;
@@ -178,8 +178,8 @@ export class EnvironmentSheetHelper {
// rarete.max);
}
- static async onAddMilieu(html, sheet, event) {
- const milieu = html.find('input.input-selection-milieu').val();
+ static async onAddMilieu(sheet, event) {
+ const milieu = sheet.html.find('input.input-selection-milieu').val();
if (!milieu) {
ui.notifications.warn(`Choisissez le milieu dans lequel se trouve le/la ${sheet.item.name}`);
return
@@ -206,7 +206,7 @@ export class EnvironmentSheetHelper {
static async onChange(sheet, event, doMutation) {
const list = sheet.item.system.environnement;
- const milieu = EnvironmentSheetHelper.$getEventMilieu(event);
+ const milieu = EnvironmentSheetHelper.$getEventMilieu(sheet, event);
const updated = list.find(it => it.milieu == milieu);
if (updated) {
doMutation(updated);
@@ -216,8 +216,8 @@ export class EnvironmentSheetHelper {
}
}
- static $getEventMilieu(event) {
- return $(event.currentTarget)?.parents("div.environnement-milieu").data("milieu");
+ static $getEventMilieu(sheet, event) {
+ return sheet.html.find(event.currentTarget)?.parents("div.environnement-milieu").data("milieu");
}
}
\ No newline at end of file
diff --git a/module/html-utility.js b/module/html-utility.js
index 1566039c..c4754cc5 100644
--- a/module/html-utility.js
+++ b/module/html-utility.js
@@ -1,10 +1,10 @@
export class HtmlUtility{
- static _showControlWhen(control, condition) {
+ static _showControlWhen(jQuerySelector, condition) {
if (condition) {
- control.show();
+ jQuerySelector.show();
}
else {
- control.hide();
+ jQuerySelector.hide();
}
}
}
\ No newline at end of file
diff --git a/module/item-conteneur-sheet.js b/module/item-conteneur-sheet.js
index 4cb398fb..0df3121a 100644
--- a/module/item-conteneur-sheet.js
+++ b/module/item-conteneur-sheet.js
@@ -16,9 +16,10 @@ export class RdDConteneurItemSheet extends RdDItemSheet {
activateListeners(html) {
super.activateListeners(html);
+
if (!this.options.editable) return;
- html.find('.conteneur-name a').click(async event => {
+ this.html.find('.conteneur-name a').click(async event => {
RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true);
});
diff --git a/module/item-faune-sheet.js b/module/item-faune-sheet.js
index 3b97d7ca..f49d2317 100644
--- a/module/item-faune-sheet.js
+++ b/module/item-faune-sheet.js
@@ -23,7 +23,7 @@ export class RdDFauneItemSheet extends RdDItemSheet {
super.activateListeners(html);
if (!this.options.editable) return;
- EnvironmentSheetHelper.activateListeners(this, html);
+ EnvironmentSheetHelper.activateListeners(this);
html.find("a.linked-actor-delete").click(event => this.onDeleteLinkedActor());
html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event));
diff --git a/module/item-herbe-sheet.js b/module/item-herbe-sheet.js
index 940eec58..0cc0c36b 100644
--- a/module/item-herbe-sheet.js
+++ b/module/item-herbe-sheet.js
@@ -20,6 +20,6 @@ export class RdDHerbeItemSheet extends RdDItemSheet {
activateListeners(html) {
super.activateListeners(html);
- EnvironmentSheetHelper.activateListeners(this, html);
+ EnvironmentSheetHelper.activateListeners(this);
}
}
diff --git a/module/item-ingredient-sheet.js b/module/item-ingredient-sheet.js
index fe78bc68..fdfc66ae 100644
--- a/module/item-ingredient-sheet.js
+++ b/module/item-ingredient-sheet.js
@@ -20,6 +20,6 @@ export class RdDIngredientItemSheet extends RdDItemSheet {
activateListeners(html) {
super.activateListeners(html);
- EnvironmentSheetHelper.activateListeners(this, html);
+ EnvironmentSheetHelper.activateListeners(this);
}
}
diff --git a/module/item-rencontre-sheet.js b/module/item-rencontre-sheet.js
index d4b74a98..e806222c 100644
--- a/module/item-rencontre-sheet.js
+++ b/module/item-rencontre-sheet.js
@@ -51,15 +51,15 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
activateListeners(html) {
super.activateListeners(html);
if (!this.options.editable) return;
- html.find("a.effet-add").click(event => this.onAddEffet(event));
- html.find("a.effet-delete").click(event => this.onDeleteEffet(event));
+ this.html.find("a.effet-add").click(event => this.onAddEffet(event));
+ this.html.find("a.effet-delete").click(event => this.onDeleteEffet(event));
}
async onAddEffet(event) {
- const resultat = $(event.currentTarget)?.data("effet-resultat");
+ const resultat = this.html.find(event.currentTarget)?.data("effet-resultat");
const keyEffets = `system.${resultat}.effets`;
- const code = $(event.currentTarget)?.data("effet-code");
+ const code = this.html.find(event.currentTarget)?.data("effet-code");
const liste = RdDRencontre.getListeEffets(this.item, resultat);
liste.push(code);
@@ -67,10 +67,10 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
}
async onDeleteEffet(event) {
- const resultat = $(event.currentTarget)?.data("effet-resultat");
+ const resultat = this.html.find(event.currentTarget)?.data("effet-resultat");
const keyEffets = `system.${resultat}.effets`;
- const pos = $(event.currentTarget)?.data("effet-pos");
+ const pos = this.html.find(event.currentTarget)?.data("effet-pos");
const liste = RdDRencontre.getListeEffets(this.item, resultat);
liste.splice(pos, 1);
diff --git a/module/item-sheet.js b/module/item-sheet.js
index baeb40e5..b928d36d 100644
--- a/module/item-sheet.js
+++ b/module/item-sheet.js
@@ -157,36 +157,39 @@ export class RdDItemSheet extends ItemSheet {
/** @override */
activateListeners(html) {
super.activateListeners(html);
+ this.html = html;
+
let itemSheetDialog = this;
- HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned);
- HtmlUtility._showControlWhen($(".item-magique"), this.item.isMagique());
+ HtmlUtility._showControlWhen(this.html.find(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned);
+ HtmlUtility._showControlWhen(this.html.find(".item-magique"), this.item.isMagique());
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
+
this.form.ondragstart = (event) => this._onDragStart(event);
this.form.ondrop = (event) => this._onDrop(event);
// Select competence categorie
- html.find(".categorie").change(event => this._onSelectCategorie(event));
+ this.html.find(".categorie").change(event => this._onSelectCategorie(event));
- html.find('.sheet-competence-xp').change((event) => {
+ this.html.find('.sheet-competence-xp').change((event) => {
if (this.item.isCompetencePersonnage()) {
RdDUtility.checkThanatosXP(this.item.name);
}
});
- html.find('.enchanteDate').change((event) => {
- let jour = Number($('#jourMois').val());
- let mois = $('#nomMois').val();
+ this.html.find('.enchanteDate').change((event) => {
+ let jour = Number(this.html.find('[name="splitDate.day"]').val());
+ let mois = this.html.find('[name="splitDate.month"]').val();
this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois);
});
- html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item));
- html.find('.consommer-potion').click((event) => this._getEventActor(event).consommerPotion(this.item));
- html.find('.creer-potion-base').click((event) => this._getEventActor(event).dialogFabriquerPotion(this.item));
+ this.html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item));
+ this.html.find('.consommer-potion').click((event) => this._getEventActor(event).consommerPotion(this.item));
+ this.html.find('.creer-potion-base').click((event) => this._getEventActor(event).dialogFabriquerPotion(this.item));
- html.find('.alchimie-tache a').click((event) => {
+ this.html.find('.alchimie-tache a').click((event) => {
let actor = this._getEventActor(event);
if (actor) {
let recetteId = event.currentTarget.attributes['data-recette-id'].value;
@@ -198,12 +201,12 @@ export class RdDItemSheet extends ItemSheet {
}
});
- html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => itemSheetDialog.render(true)));
- html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
- html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
- html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
- html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
- html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => itemSheetDialog.render(true)));
+ this.html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => itemSheetDialog.render(true)));
+ this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
+ this.html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
+ this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
+ this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
+ this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => itemSheetDialog.render(true)));
}
_getEventActor(event) {
@@ -219,7 +222,7 @@ export class RdDItemSheet extends ItemSheet {
if (this.item.isCompetence()) {
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value);
this.item.system.base = level;
- $("#base").val(level);
+ this.html.find('[name="system.base"]').val(level);
}
}
diff --git a/module/rdd-astrologie-editeur.js b/module/rdd-astrologie-editeur.js
index 75913483..b2dd6260 100644
--- a/module/rdd-astrologie-editeur.js
+++ b/module/rdd-astrologie-editeur.js
@@ -15,13 +15,19 @@
// Common conf
let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" };
- let dialogOptions = { classes: ["rdddialog"], width: 600, height: 300, 'z-index': 99999 }
+ let dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 300, 'z-index': 99999 }
super(dialogConf, dialogOptions)
this.calendrier = calendrier;
this.updateData( calendrierData );
}
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ }
+
+
/* -------------------------------------------- */
async resetNombreAstraux() {
game.system.rdd.calendrier.resetNombreAstral();
@@ -39,15 +45,4 @@
this.calendrierData = duplicate(calendrierData);
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
-
- let astrologieData = this.astrologieData;
-
- $(function () {
- });
-
- }
-
}
diff --git a/module/rdd-astrologie-joueur.js b/module/rdd-astrologie-joueur.js
index 5c520d6a..5ec5660d 100644
--- a/module/rdd-astrologie-joueur.js
+++ b/module/rdd-astrologie-joueur.js
@@ -20,7 +20,7 @@ export class RdDAstrologieJoueur extends Dialog {
astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie')
}
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', dialogData);
- let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };
+ let options = { classes: ["rdd-roll-dialog"], width: 600, height: 500, 'z-index': 99999 };
if (dialogConfig.options) {
mergeObject(options, dialogConfig.options, { overwrite: true });
}
@@ -29,21 +29,35 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */
constructor(html, actor, dialogData) {
-
- let myButtons = {
- saveButton: { label: "Fermer", callback: html => this.quitDialog() }
+ const dialogConf = {
+ title: "Nombres Astraux",
+ content: html,
+ default: "saveButton",
+ buttons: {
+ saveButton: { label: "Fermer", callback: html => this.quitDialog() }
+ },
};
-
- // Get all n
- // Common conf
- let dialogConf = { content: html, title: "Nombres Astraux", buttons: myButtons, default: "saveButton" };
- let dialogOptions = { classes: ["rdddialog"], width: 600, height: 300, 'z-index': 99999 };
+ const dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 300, 'z-index': 99999 };
super(dialogConf, dialogOptions);
this.actor = actor;
this.dataNombreAstral = duplicate(dialogData);
}
+ /* -------------------------------------------- */
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+
+ this.html.find(function () {
+ this.html.find("[name='diffConditions']").val(0);
+ });
+
+ this.html.find('[name="jet-astrologie"]').click((event) => {
+ this.requestJetAstrologie();
+ });
+ }
+
/* -------------------------------------------- */
static organizeNombres(actor) {
let itemNombres = actor.listItemsData('nombreastral');
@@ -68,8 +82,8 @@ export class RdDAstrologieJoueur extends Dialog {
carac_vue: this.actor.system.carac['vue'].value,
etat: this.dataNombreAstral.etat,
astrologie: this.dataNombreAstral.astrologie,
- conditions: $("#diffConditions").val(),
- date: $("#joursAstrologie").val(),
+ conditions: this.html.find('[name="diffConditions"]').val(),
+ date: this.html.find('[name="joursAstrologie"]').val(),
userId: game.user.id
}
if (Misc.isUniqueConnectedGM()) {
@@ -87,17 +101,4 @@ export class RdDAstrologieJoueur extends Dialog {
quitDialog() {
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
-
- $(function () {
- $("#diffConditions").val(0);
- });
-
- html.find('#jet-astrologie').click((event) => {
- this.requestJetAstrologie();
- });
- }
-
}
diff --git a/module/rdd-calendrier-editeur.js b/module/rdd-calendrier-editeur.js
index 6a740d5c..936dee45 100644
--- a/module/rdd-calendrier-editeur.js
+++ b/module/rdd-calendrier-editeur.js
@@ -23,15 +23,24 @@ export class RdDCalendrierEditeur extends Dialog {
this.calendrierData = calendrierData;
}
+ activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+ this.html.find("input[name='nomMois']").val(this.calendrierData.moisKey);
+ this.html.find("select[name='nomHeure']").val(this.calendrierData.heureKey);
+ this.html.find("select[name='jourMois']").val(this.calendrierData.jourMois);
+ this.html.find("select[name='minutesRelative']").val(calendrierData.minutesRelative);
+ this.html.find("select[name='annee']").val(this.calendrierData.annee);
+ }
+
/* -------------------------------------------- */
fillData() {
- this.calendrierData.annee = $("input[name='annee']").val();
- this.calendrierData.moisKey = $("select[name='nomMois']").val();
- this.calendrierData.heureKey = $("select[name='nomHeure']").val();
- this.calendrierData.jourMois = $("select[name='jourMois']").val();
- this.calendrierData.minutesRelative = $("select[name='minutesRelative']").val();
+ this.calendrierData.annee = this.html.find("input[name='annee']").val();
+ this.calendrierData.moisKey = this.html.find("select[name='nomMois']").val();
+ this.calendrierData.heureKey = this.html.find("select[name='nomHeure']").val();
+ this.calendrierData.jourMois = this.html.find("select[name='jourMois']").val();
+ this.calendrierData.minutesRelative = this.html.find("select[name='minutesRelative']").val();
- console.log("UPDATE ", this.calendrierData);
this.calendrier.saveEditeur(this.calendrierData)
}
@@ -40,21 +49,4 @@ export class RdDCalendrierEditeur extends Dialog {
this.calendrierData = duplicate(calendrierData);
}
- /* -------------------------------------------- */
- activateListeners(html) {
- super.activateListeners(html);
-
- let calendrierData = this.calendrierData;
-
- $(function () {
- console.log(calendrierData);
- $("input[name='nomMois']").val(calendrierData.moisKey);
- $("select[name='nomHeure']").val(calendrierData.heureKey);
- $("select[name='jourMois']").val(calendrierData.jourMois);
- $("select[name='minutesRelative']").val(calendrierData.minutesRelative);
- $("select[name='annee']").val(calendrierData.annee);
- });
-
- }
-
}
diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js
index f47ca3fd..554a11e2 100644
--- a/module/rdd-calendrier.js
+++ b/module/rdd-calendrier.js
@@ -43,6 +43,14 @@ const MAX_NOMBRE_ASTRAL = 12;
/* -------------------------------------------- */
export class RdDCalendrier extends Application {
+ static get defaultOptions() {
+ return mergeObject(super.defaultOptions, {
+ template: "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html",
+ popOut: false,
+ resizable: false
+ });
+ }
+
static createCalendrierPos() {
return { top: 200, left: 200 };
}
@@ -121,20 +129,103 @@ export class RdDCalendrier extends Application {
console.log('RdDCalendrier.constructor()', this.calendrier, this.calendrierPos, this.listeNombreAstral);
}
+ /* -------------------------------------------- */
+ /** @override */
+ async activateListeners(html) {
+ super.activateListeners(html);
+ this.html = html;
+
+ this.updateDisplay();
+
+ this.html.find('.ajout-chronologie').click(ev => DialogChronologie.create());
+
+ this.html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
+
+ this.html.find('.calendar-btn-edit').click(ev => {
+ ev.preventDefault();
+ this.showCalendarEditor();
+ });
+
+ this.html.find('.astrologie-btn-edit').click(ev => {
+ ev.preventDefault();
+ this.showAstrologieEditor();
+ });
+
+ this.html.find('#calendar-move-handle').mousedown(ev => {
+ ev.preventDefault();
+ ev = ev || window.event;
+ let isRightMB = false;
+ if ("which" in ev) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
+ isRightMB = ev.which == 3;
+ } else if ("button" in ev) { // IE, Opera
+ isRightMB = ev.button == 2;
+ }
+
+ if (!isRightMB) {
+ dragElement(document.getElementById("calendar-time-container"));
+ let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
+
+ function dragElement(elmnt) {
+ elmnt.onmousedown = dragMouseDown;
+ function dragMouseDown(e) {
+ e = e || window.event;
+ e.preventDefault();
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+
+ document.onmouseup = closeDragElement;
+ document.onmousemove = elementDrag;
+ }
+
+ function elementDrag(e) {
+ e = e || window.event;
+ e.preventDefault();
+ // calculate the new cursor position:
+ pos1 = pos3 - e.clientX;
+ pos2 = pos4 - e.clientY;
+ pos3 = e.clientX;
+ pos4 = e.clientY;
+ // set the element's new position:
+ elmnt.style.bottom = undefined
+ elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
+ elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
+ }
+
+ function closeDragElement() {
+ // stop moving when mouse button is released:
+ elmnt.onmousedown = undefined;
+ document.onmouseup = undefined;
+ document.onmousemove = undefined;
+ let xPos = (elmnt.offsetLeft - pos1) > window.innerWidth ? window.innerWidth - 200 : (elmnt.offsetLeft - pos1);
+ let yPos = (elmnt.offsetTop - pos2) > window.innerHeight - 20 ? window.innerHeight - 100 : (elmnt.offsetTop - pos2)
+ xPos = xPos < 0 ? 0 : xPos;
+ yPos = yPos < 0 ? 0 : yPos;
+ if (xPos != (elmnt.offsetLeft - pos1) || yPos != (elmnt.offsetTop - pos2)) {
+ elmnt.style.top = (yPos) + "px";
+ elmnt.style.left = (xPos) + "px";
+ }
+ game.system.rdd.calendrier.calendrierPos.top = yPos;
+ game.system.rdd.calendrier.calendrierPos.left = xPos;
+ if (game.user.isGM) {
+ game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
+ }
+ }
+ }
+ } else if (isRightMB) {
+ game.system.rdd.calendrier.calendrierPos.top = 200;
+ game.system.rdd.calendrier.calendrierPos.left = 200;
+ if (game.user.isGM) {
+ game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
+ }
+ this.setPos(game.system.rdd.calendrier.calendrierPos);
+ }
+ });
+ }
/* -------------------------------------------- */
getListeNombreAstral() {
return game.settings.get(SYSTEM_RDD, "liste-nombre-astral") ?? [];
}
- /* -------------------------------------------- */
- static get defaultOptions() {
- return mergeObject(super.defaultOptions, {
- template: "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html",
- popOut: false,
- resizable: false
- });
- }
-
/* -------------------------------------------- */
getDateFromIndex(index) {
const dateRdD = this.getCalendrier(index);
@@ -555,97 +646,4 @@ export class RdDCalendrier extends Application {
astrologieEditeur.updateData(calendrierData);
astrologieEditeur.render(true);
}
-
- /* -------------------------------------------- */
- /** @override */
- async activateListeners(html) {
- super.activateListeners(html);
-
- this.updateDisplay();
-
- html.find('.ajout-chronologie').click(ev => DialogChronologie.create());
-
- html.find('.calendar-btn').click(ev => this.onCalendarButton(ev));
-
- html.find('.calendar-btn-edit').click(ev => {
- ev.preventDefault();
- this.showCalendarEditor();
- });
-
- html.find('.astrologie-btn-edit').click(ev => {
- ev.preventDefault();
- this.showAstrologieEditor();
- });
-
- html.find('#calendar-move-handle').mousedown(ev => {
- ev.preventDefault();
- ev = ev || window.event;
- let isRightMB = false;
- if ("which" in ev) { // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
- isRightMB = ev.which == 3;
- } else if ("button" in ev) { // IE, Opera
- isRightMB = ev.button == 2;
- }
-
- if (!isRightMB) {
- dragElement(document.getElementById("calendar-time-container"));
- let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
-
- function dragElement(elmnt) {
- elmnt.onmousedown = dragMouseDown;
- function dragMouseDown(e) {
- e = e || window.event;
- e.preventDefault();
- pos3 = e.clientX;
- pos4 = e.clientY;
-
- document.onmouseup = closeDragElement;
- document.onmousemove = elementDrag;
- }
-
- function elementDrag(e) {
- e = e || window.event;
- e.preventDefault();
- // calculate the new cursor position:
- pos1 = pos3 - e.clientX;
- pos2 = pos4 - e.clientY;
- pos3 = e.clientX;
- pos4 = e.clientY;
- // set the element's new position:
- elmnt.style.bottom = undefined
- elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
- elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
- }
-
- function closeDragElement() {
- // stop moving when mouse button is released:
- elmnt.onmousedown = undefined;
- document.onmouseup = undefined;
- document.onmousemove = undefined;
- let xPos = (elmnt.offsetLeft - pos1) > window.innerWidth ? window.innerWidth - 200 : (elmnt.offsetLeft - pos1);
- let yPos = (elmnt.offsetTop - pos2) > window.innerHeight - 20 ? window.innerHeight - 100 : (elmnt.offsetTop - pos2)
- xPos = xPos < 0 ? 0 : xPos;
- yPos = yPos < 0 ? 0 : yPos;
- if (xPos != (elmnt.offsetLeft - pos1) || yPos != (elmnt.offsetTop - pos2)) {
- elmnt.style.top = (yPos) + "px";
- elmnt.style.left = (xPos) + "px";
- }
- game.system.rdd.calendrier.calendrierPos.top = yPos;
- game.system.rdd.calendrier.calendrierPos.left = xPos;
- if (game.user.isGM) {
- game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
- }
- }
- }
- } else if (isRightMB) {
- game.system.rdd.calendrier.calendrierPos.top = 200;
- game.system.rdd.calendrier.calendrierPos.left = 200;
- if (game.user.isGM) {
- game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
- }
- this.setPos(game.system.rdd.calendrier.calendrierPos);
- }
- });
- }
-
}
\ No newline at end of file
diff --git a/module/rdd-combat.js b/module/rdd-combat.js
index c5579338..9dd406f2 100644
--- a/module/rdd-combat.js
+++ b/module/rdd-combat.js
@@ -767,7 +767,7 @@ export class RdDCombat {
// whisper: ChatMessage.getWhisperRecipients("GM")})
// }
- if (!await this.accorderEntite('avant-attaque')) {
+ if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
return;
}
if (arme.system.cac == 'empoignade' && this.attacker.isCombatTouche()) {
@@ -886,7 +886,7 @@ export class RdDCombat {
}
await RdDResolutionTable.displayRollData(attackerRoll, this.attacker, 'chat-resultat-attaque.html');
- if (!await this.accorderEntite('avant-defense')) {
+ if (!await this.attacker.accorder(this.defender, 'avant-defense')) {
return;
}
@@ -1319,35 +1319,6 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
}
- /* -------------------------------------------- */
- /* retourne true si on peut continuer, false si on ne peut pas continuer */
- async accorderEntite(when = 'avant-encaissement') {
- if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
- || this.defender == undefined
- || !this.defender.isEntite([ENTITE_INCARNE])
- || this.defender.isEntiteAccordee(this.attacker)) {
- return true;
- }
-
- let rolled = await RdDResolutionTable.roll(this.attacker.getReveActuel(), - Number(this.defender.system.carac.niveau.value));
-
- let message = {
- content: "Jet de points actuels de rêve à " + rolled.finalLevel + RdDResolutionTable.explain(rolled) + "
",
- whisper: ChatMessage.getWhisperRecipients(this.attacker.name)
- };
-
- if (rolled.isSuccess) {
- await this.defender.setEntiteReveAccordee(this.attacker);
- message.content += this.attacker.name + " s'est accordé avec " + this.defender.name;
- }
- else {
- message.content += this.attacker.name + " n'est pas accordé avec " + this.defender.name;
- }
-
- ChatMessage.create(message);
- return rolled.isSuccess;
- }
-
/* -------------------------------------------- */
static async displayActorCombatStatus(combat, actor) {
let formData = {
diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js
index c6d67bf3..fd2e482a 100644
--- a/module/rdd-resolution-table.js
+++ b/module/rdd-resolution-table.js
@@ -14,7 +14,7 @@ const levelDown = [
{ level: -15, score: 1, norm: 1, sign: 0, part: 0, epart: 2, etotal: 10 },
{ level: -16, score: 1, norm: 1, sign: 0, part: 0, epart: 0, etotal: 2 }
];
-const levelImpossible = { score: 0, norm:0, sign: 0, part: 0, epart: 0, etotal: 1 };
+const levelImpossible = { score: 0, norm: 0, sign: 0, part: 0, epart: 0, etotal: 1 };
const reussites = [
{ code: "etotal", isPart: false, isSign: false, isSuccess: false, isEchec: true, isEPart: true, isETotal: true, ptTache: -4, ptQualite: -6, quality: "Echec total", condition: (target, roll) => roll >= target.etotal && roll <= 100 },
@@ -42,6 +42,44 @@ export class RdDResolutionTable {
return table;
}
+ /* -------------------------------------------- */
+ static computeChances(carac, level) {
+ if (level < -16) {
+ return levelImpossible;
+ }
+ if (level < -10) {
+ return levelDown.find(it => it.level == level);
+ }
+ const percentage = RdDResolutionTable.computePercentage(carac, level);
+ return this._computeCell(level, percentage);
+ }
+
+
+ /* -------------------------------------------- */
+ static _computeRow(caracValue) {
+ let dataRow = [
+ this._computeCell(-10, Math.max(Math.floor(caracValue / 4), 1)),
+ this._computeCell(-9, Math.max(Math.floor(caracValue / 2), 1))
+ ]
+ for (var diff = -8; diff <= 22; diff++) {
+ dataRow[diff + 10] = this._computeCell(diff, RdDResolutionTable.computePercentage(caracValue, diff));
+ }
+ return dataRow;
+ }
+
+ /* -------------------------------------------- */
+ static _computeCell(niveau, percentage) {
+ return {
+ niveau: niveau,
+ score: percentage,
+ norm: Math.min(99, percentage),
+ sign: this._reussiteSignificative(percentage),
+ part: this._reussitePart(percentage),
+ epart: this._echecParticulier(percentage),
+ etotal: this._echecTotal(percentage)
+ };
+ }
+
/* -------------------------------------------- */
static getResultat(code) {
let resultat = reussites.find(r => code == r.code);
@@ -51,17 +89,6 @@ export class RdDResolutionTable {
return resultat;
}
- /* -------------------------------------------- */
- static explain(rolled) {
- let message = "
Jet : " + rolled.roll + " sur " + rolled.score + "% ";
- if (rolled.caracValue != undefined && rolled.finalLevel != undefined) {
- message += (rolled.diviseurSignificative > 1 ? `(1/${rolled.diviseurSignificative} de ` : "(")
- + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ") ";
- }
- message += '' + rolled.quality + ''
- return message;
- }
-
/* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
return await ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
@@ -82,8 +109,8 @@ export class RdDResolutionTable {
}
/* -------------------------------------------- */
- static async roll(caracValue, finalLevel, rollData = {}){
- let chances = this.computeChances(caracValue, finalLevel);
+ static async roll(caracValue, finalLevel, rollData = {}) {
+ let chances = duplicate(this.computeChances(caracValue, finalLevel));
this._updateChancesWithBonus(chances, rollData.bonus, finalLevel);
this._updateChancesFactor(chances, rollData.diviseurSignificative);
chances.showDice = rollData.showDice;
@@ -95,7 +122,7 @@ export class RdDResolutionTable {
rolled.bonus = rollData.bonus;
rolled.factorHtml = Misc.getFractionHtml(rollData.diviseurSignificative);
- if (ReglesOptionelles.isUsing("afficher-colonnes-reussite")){
+ if (ReglesOptionelles.isUsing("afficher-colonnes-reussite")) {
rolled.niveauNecessaire = this.findNiveauNecessaire(caracValue, rolled.roll);
rolled.ajustementNecessaire = rolled.niveauNecessaire - finalLevel;
}
@@ -103,13 +130,24 @@ export class RdDResolutionTable {
}
/* -------------------------------------------- */
- static findNiveauNecessaire(caracValue, rollValue) {
- for (let cell of this.resolutionTable[caracValue]) {
- if ( rollValue <= cell.norm) {
- return cell.niveau;
- }
+ static findNiveauNecessaire(carac, rolled) {
+ if (carac == 0) {
+ return NaN;
}
- return 16; // Dummy default
+ if (rolled >= carac){
+ const upper = Math.ceil(rolled/carac);
+ return 2*upper -10
+ }
+ if (rolled > Math.floor(carac/2)) {
+ return -8
+ }
+ if (rolled > Math.floor(carac/4)) {
+ return -9
+ }
+ if (rolled > 1) {
+ return -10
+ }
+ return -11;
}
/* -------------------------------------------- */
@@ -122,7 +160,7 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static _updateChancesWithBonus(chances, bonus, finalLevel) {
- if (bonus && finalLevel>-11) {
+ if (bonus && finalLevel > -11) {
let newScore = Number(chances.score) + bonus;
mergeObject(chances, this._computeCell(undefined, newScore), { overwrite: true });
}
@@ -142,21 +180,19 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static async rollChances(chances, diviseur, forceDiceResult = -1) {
- chances.forceDiceResult = forceDiceResult <= 0 || forceDiceResult > 100 ? undefined : {total: forceDiceResult};
- chances.roll = await RdDDice.rollTotal( "1d100", chances);
+ chances.forceDiceResult = forceDiceResult <= 0 || forceDiceResult > 100 ? undefined : { total: forceDiceResult };
+ chances.roll = await RdDDice.rollTotal("1d100", chances);
mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true });
return chances;
}
/* -------------------------------------------- */
- static computeChances(caracValue, difficulte) {
- if (difficulte < -16) {
- return duplicate(levelImpossible);
- }
- if (difficulte < -10) {
- return duplicate(levelDown.find(levelData => levelData.level == difficulte));
- }
- return duplicate(RdDResolutionTable.resolutionTable[caracValue][difficulte + 10]);
+ static computePercentage(carac, diff) {
+ if (diff < -16) return 0
+ if (diff < -10) return 1
+ if (diff == -10) return Math.max(Math.floor(carac / 4), 1)
+ if (diff == -9) return Math.max(Math.floor(carac / 2), 1)
+ return Math.max(Math.floor(carac * (diff + 10) / 2), 1);
}
/* -------------------------------------------- */
@@ -213,31 +249,6 @@ export class RdDResolutionTable {
return reussite;
}
- /* -------------------------------------------- */
- static _computeRow(caracValue) {
- let dataRow = [
- this._computeCell(-10, Math.max(Math.floor(caracValue / 4), 1)),
- this._computeCell(-9, Math.max(Math.floor(caracValue / 2), 1))
- ]
- for (var diff = -8; diff <= 22; diff++) {
- dataRow[diff + 10] = this._computeCell(diff, Math.max(Math.floor(caracValue * (diff + 10) / 2), 1));
- }
- return dataRow;
- }
-
- /* -------------------------------------------- */
- static _computeCell(niveau, percentage) {
- return {
- niveau: niveau,
- score: percentage,
- norm: Math.min(99, percentage),
- sign: this._reussiteSignificative(percentage),
- part: this._reussitePart(percentage),
- epart: this._echecParticulier(percentage),
- etotal: this._echecTotal(percentage)
- };
- }
-
/* -------------------------------------------- */
static _reussiteSignificative(percentage) {
return Math.floor(percentage / 2);
@@ -261,92 +272,34 @@ export class RdDResolutionTable {
}
/* -------------------------------------------- */
- static buildHTMLResults(caracValue, levelValue) {
- if (caracValue == undefined || isNaN(caracValue)) caracValue = 10;
- if (levelValue == undefined || isNaN(levelValue)) levelValue = 0;
-
- let cell = this.computeChances(caracValue, levelValue);
- cell.epart = cell.epart > 99 ? 'N/A' : cell.epart;
- cell.etotal = cell.etotal > 100 ? 'N/A' : cell.etotal;
- cell.score = Math.min(cell.score, 99);
-
- return `
-
- Particulière: ${cell.part}
- - Significative: ${cell.sign}
- - Réussite: ${cell.score}
- - Echec Particulier: ${cell.epart}
- - Echec Total: ${cell.etotal}
-
- `
+ static subTable(carac, level, delta = { carac: 2, level: 5}) {
+ return {
+ carac,
+ level,
+ minCarac: carac - (delta?.carac ?? 2),
+ maxCarac: carac + (delta?.carac ?? 2),
+ minLevel: level - (delta?.level ?? 5),
+ maxLevel: level + (delta?.level ?? 5)
+ };
}
/* -------------------------------------------- */
- static buildHTMLTableExtract(caracValue, levelValue) {
- return this.buildHTMLTable(caracValue, levelValue, caracValue - 2, caracValue + 2, levelValue - 5, levelValue + 5)
- }
-
- static buildHTMLTable(caracValue, levelValue, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11) {
- return this._buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel)
- }
-
- /* -------------------------------------------- */
- static _buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel) {
- let countColonnes = maxLevel - minLevel;
+ static async buildHTMLTable({ carac: carac, level: level, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11 }) {
+ let colonnes = maxLevel - minLevel;
minCarac = Math.max(minCarac, 1);
- maxCarac = Math.min(maxCarac, caracMaximumResolution);
+ maxCarac = Math.min(maxCarac, minCarac + 20);
minLevel = Math.max(minLevel, -10);
- maxLevel = Math.max(Math.min(maxLevel, 22), minLevel + countColonnes);
-
- let table = $("
{{rencontre.name}} {{rencontre.system.force}} ({{rencontre.system.formule}})
-{{linkCompendium rencontre.pack rencontre.id rencontre.name}}
+{{rencontre.name}} de force {{rencontre.system.force}} ({{rencontre.system.formule}})
+{{linkCompendium row.document.pack row.document.id row.document.name}}
{{#if rencontre.system.description}}