Permettre d'avoir plusieurs fenêtres #590

Merged
uberwald merged 5 commits from VincentVk/foundryvtt-reve-de-dragon:v10 into v10 2022-12-09 10:36:48 +01:00
76 changed files with 998 additions and 1099 deletions

View File

@ -27,15 +27,15 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
if (!this.options.editable) return; if (!this.options.editable) return;
// On competence change // 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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
}); });

View File

@ -23,15 +23,15 @@ export class RdDActorEntiteSheet extends RdDActorSheet {
if (!this.options.editable) return; if (!this.options.editable) return;
// On competence change // 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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) ); this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
} ); } );

View File

@ -118,58 +118,26 @@ export class RdDActorSheet extends ActorSheet {
return formData; 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 */ /* -------------------------------------------- */ /** @override */
activateListeners(html) { activateListeners(html) {
super.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 // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; 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); const item = RdDSheetUtility.getItem(event, this.actor);
RdDSheetUtility.splitItem(item, this.actor); RdDSheetUtility.splitItem(item, this.actor);
}); });
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true)) this.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))); this.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()); this.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()); this.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)); this.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('.subacteur-delete').click(async event => {
const li = RdDSheetUtility.getEventElement(event); const li = RdDSheetUtility.getEventElement(event);
const actorId = li.data("actor-id"); const actorId = li.data("actor-id");
if (actorId) { if (actorId) {
@ -177,54 +145,54 @@ export class RdDActorSheet extends ActorSheet {
RdDUtility.confirmerSuppressionSubacteur(this, subActor, li); RdDUtility.confirmerSuppressionSubacteur(this, subActor, li);
} }
}); });
html.find('.experiencelog-delete').click(async event => { this.html.find('.experiencelog-delete').click(async event => {
const li = $(event.currentTarget)?.parents(".experiencelog"); const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
const key = Number(li.data("key") ?? -1); const key = Number(li.data("key") ?? -1);
await this.actor.deleteExperienceLog(key, 1); await this.actor.deleteExperienceLog(key, 1);
}); });
html.find('.experiencelog-delete-previous').click(async event => { this.html.find('.experiencelog-delete-previous').click(async event => {
const li = $(event.currentTarget)?.parents(".experiencelog"); const li = this.html.find(event.currentTarget)?.parents(".experiencelog");
const key = Number(li.data("key") ?? -1); const key = Number(li.data("key") ?? -1);
await this.actor.deleteExperienceLog(0, 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(); 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) const poss = RdDSheetUtility.getItem(event, this.actor)
this.actor.conjurerPossession(poss) 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) { if (game.user.isGM) {
this.actor.remiseANeuf(); this.actor.remiseANeuf();
} }
}); });
html.find('.creer-tache').click(async event => { this.html.find('.creer-tache').click(async event => {
this.createEmptyTache(); this.createEmptyTache();
}); });
html.find('.creer-un-objet').click(async event => { this.html.find('.creer-un-objet').click(async event => {
RdDUtility.selectObjetType(this); RdDUtility.selectObjetType(this);
}); });
html.find('.creer-une-oeuvre').click(async event => { this.html.find('.creer-une-oeuvre').click(async event => {
RdDUtility.selectTypeOeuvre(this); RdDUtility.selectTypeOeuvre(this);
}); });
html.find('.nettoyer-conteneurs').click(async event => { this.html.find('.nettoyer-conteneurs').click(async event => {
this.actor.nettoyerConteneurs(); this.actor.nettoyerConteneurs();
}); });
// Blessure control // Blessure control
html.find('.blessure-control').click(async event => { this.html.find('.blessure-control').click(async event => {
const tr = $(event.currentTarget).parents(".item"); const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data("blessure-type"); let btype = tr.data("blessure-type");
let index = tr.data('blessure-index'); 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); //console.log(btype, index, active);
await this.actor.manageBlessureFromSheet(btype, index, active); await this.actor.manageBlessureFromSheet(btype, index, active);
}); });
// Blessure data // Blessure data
html.find('.blessure-soins').change(async event => { this.html.find('.blessure-soins').change(async event => {
const tr = $(event.currentTarget).parents(".item"); const tr = this.html.find(event.currentTarget).parents(".item");
let btype = tr.data('blessure-type'); let btype = tr.data('blessure-type');
let index = tr.data('blessure-index'); let index = tr.data('blessure-index');
let psoins = tr.find('.blessure-premiers_soins').val(); let psoins = tr.find('.blessure-premiers_soins').val();
@ -238,57 +206,57 @@ export class RdDActorSheet extends ActorSheet {
}); });
// Equip Inventory Item // Equip Inventory Item
html.find('.item-equip').click(async event => { this.html.find('.item-equip').click(async event => {
this.actor.equiperObjet(RdDSheetUtility.getItemId(event)); this.actor.equiperObjet(RdDSheetUtility.getItemId(event));
}); });
// Roll Carac // 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; let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac(caracName.toLowerCase()); 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'); this.actor.rollCarac('chance-actuelle');
}); });
html.find('.chance-appel').click(async event => { this.html.find('.chance-appel').click(async event => {
this.actor.rollAppelChance(); this.actor.rollAppelChance();
}); });
html.find('#jet-astrologie').click(async event => { this.html.find('[name="jet-astrologie"]').click(async event => {
this.actor.astrologieNombresAstraux(); this.actor.astrologieNombresAstraux();
}); });
// Roll Skill // 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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 actorId = RdDSheetUtility.getEventItemData(event, 'actor-id');
let actor = game.actors.get(actorId); let actor = game.actors.get(actorId);
if (actor) { if (actor) {
@ -297,25 +265,25 @@ export class RdDActorSheet extends ActorSheet {
}); });
// Boutons spéciaux MJs // 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"); this.actor.reinsertionAleatoire("Action MJ");
}); });
html.find('.afficher-tmr').click(async event => { this.html.find('.afficher-tmr').click(async event => {
this.actor.changeTMRVisible(); this.actor.changeTMRVisible();
}); });
// Points de reve actuel // 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'); this.actor.rollCarac('reve-actuel');
}); });
// Roll Weapon1 // Roll Weapon1
html.find('.arme-label a').click(async event => { this.html.find('.arme-label a').click(async event => {
let arme = this._getEventArmeCombat(event); let arme = this._getEventArmeCombat(event);
this.actor.rollArme(duplicate(arme)); this.actor.rollArme(duplicate(arme));
}); });
// Initiative pour l'arme // Initiative pour l'arme
html.find('.arme-initiative a').click(async event => { this.html.find('.arme-initiative a').click(async event => {
let combatant = game.combat.combatants.find(c => c.actor.id == this.actor.id); let combatant = game.combat.combatants.find(c => c.actor.id == this.actor.id);
if (combatant) { if (combatant) {
let action = this._getEventArmeCombat(event); let action = this._getEventArmeCombat(event);
@ -325,88 +293,88 @@ export class RdDActorSheet extends ActorSheet {
} }
}); });
// Display TMR, visualisation // Display TMR, visualisation
html.find('.visu-tmr').click(async event => { this.html.find('.visu-tmr').click(async event => {
this.actor.displayTMR("visu"); this.actor.displayTMR("visu");
}); });
// Display TMR, normal // Display TMR, normal
html.find('.monte-tmr').click(async event => { this.html.find('.monte-tmr').click(async event => {
this.actor.displayTMR("normal"); this.actor.displayTMR("normal");
}); });
// Display TMR, fast // Display TMR, fast
html.find('.monte-tmr-rapide').click(async event => { this.html.find('.monte-tmr-rapide').click(async event => {
this.actor.displayTMR("rapide"); this.actor.displayTMR("rapide");
}); });
html.find('.repos').click(async event => { this.html.find('.repos').click(async event => {
await DialogRepos.create(this.actor); 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) { 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); 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) { if (game.user.isGM) {
await this.actor.removeEffects(); 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)); RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true); 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.", ""); let caracName = event.currentTarget.name.replace("augmenter.", "");
this.actor.updateCaracXPAuto(caracName); 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)); 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)); this.actor.updateCompetenceStress(RdDSheetUtility.getItemId(event));
}); });
if (this.options.vueDetaillee) { if (this.options.vueDetaillee) {
// On carac change // 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.", ""); let caracName = event.currentTarget.name.replace(".value", "").replace("system.carac.", "");
this.actor.updateCarac(caracName, parseInt(event.target.value)); 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.", ""); let caracName = event.currentTarget.name.replace(".xp", "").replace("system.carac.", "");
this.actor.updateCaracXP(caracName, parseInt(event.target.value)); this.actor.updateCaracXP(caracName, parseInt(event.target.value));
}); });
// On competence change // 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; let compName = event.currentTarget.attributes.compname.value;
//console.log("Competence changed :", compName); //console.log("Competence changed :", compName);
this.actor.updateCompetence(compName, parseInt(event.target.value)); this.actor.updateCompetence(compName, parseInt(event.target.value));
}); });
// On competence xp change // 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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceXP(compName, parseInt(event.target.value)); this.actor.updateCompetenceXP(compName, parseInt(event.target.value));
}); });
// On competence xp change // 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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value)); this.actor.updateCompetenceXPSort(compName, parseInt(event.target.value));
}); });
// On competence archetype change // 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; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCompetenceArchetype(compName, parseInt(event.target.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.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true); this.render(true);
}); });
html.find('.recherche') this.html.find('.recherche')
.each((index, field) => { .each((index, field) => {
if (this.options.recherche) { if (this.options.recherche) {
field.focus(); field.focus();
@ -429,92 +397,125 @@ export class RdDActorSheet extends ActorSheet {
.change(async event => .change(async event =>
this.options.recherche = this._optionRecherche(event.currentTarget) 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.options.vueDetaillee = !this.options.vueDetaillee;
this.render(true); this.render(true);
}); });
// On pts de reve change // 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; let reveValue = event.currentTarget.value;
this.actor.update({ "system.reve.reve.value": reveValue }); this.actor.update({ "system.reve.reve.value": reveValue });
}); });
// On seuil de reve change // 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) console.log("seuil-reve-value", event.currentTarget)
this.actor.setPointsDeSeuil(event.currentTarget.value); 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)); this.actor.updateAttributeValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
}); });
// On stress change // 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; let fieldName = event.currentTarget.attributes.name.value;
this.actor.updateCompteurValue(fieldName, parseInt(event.target.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)); 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(); this.actor.transformerStress();
}); });
html.find('.moral-malheureux').click(async event => { this.html.find('.moral-malheureux').click(async event => {
this.actor.jetDeMoral('malheureuse'); this.actor.jetDeMoral('malheureuse');
}); });
html.find('.moral-neutre').click(async event => { this.html.find('.moral-neutre').click(async event => {
this.actor.jetDeMoral('neutre'); this.actor.jetDeMoral('neutre');
}); });
html.find('.moral-heureux').click(async event => { this.html.find('.moral-heureux').click(async event => {
this.actor.jetDeMoral('heureuse'); this.actor.jetDeMoral('heureuse');
}); });
html.find('.ethylisme-test').click(async event => { this.html.find('.ethylisme-test').click(async event => {
this.actor.jetEthylisme(); this.actor.jetEthylisme();
}); });
html.find('.jet-vie').click(async event => { this.html.find('.jet-vie').click(async event => {
this.actor.jetVie(); this.actor.jetVie();
}); });
html.find('.jet-endurance').click(async event => { this.html.find('.jet-endurance').click(async event => {
this.actor.jetEndurance(); 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); 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); 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); 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); 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); 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); 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); 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); this.actor.reveActuelIncDec(-1);
}); });
html.find('.fatigue-plus').click(async event => { this.html.find('.fatigue-plus').click(async event => {
this.actor.santeIncDec("fatigue", 1); 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); 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) { _optionRecherche(target) {
if (!target.value?.length){ if (!target.value?.length){
return undefined; return undefined;
@ -527,7 +528,7 @@ export class RdDActorSheet extends ActorSheet {
} }
_getEventArmeCombat(event) { _getEventArmeCombat(event) {
const li = $(event.currentTarget)?.parents(".item"); const li = this.html.find(event.currentTarget)?.parents(".item");
let armeName = li.data("arme-name"); let armeName = li.data("arme-name");
let compName = li.data('competence-name'); let compName = li.data('competence-name');
const arme = this.armesList.find(a => a.name == armeName && a.system.competence == compName); const arme = this.armesList.find(a => a.name == armeName && a.system.competence == compName);

View File

@ -22,16 +22,16 @@ export class RdDActorVehiculeSheet extends RdDActorSheet {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; 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); 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); 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); 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); this.actor.vehicleIncDec("structure", 1);
}); });
} }

View File

@ -150,17 +150,6 @@ export class RdDActor extends Actor {
this.computeEtatGeneral(); 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) { _prepareCreatureData(actorData) {
this.computeEncombrementTotalEtMalusArmure(); this.computeEncombrementTotalEtMalusArmure();
@ -601,11 +590,14 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async _jetRecuperationConstitution(bonusSoins, message = undefined) { async _jetRecuperationConstitution(bonusSoins, message = undefined) {
const tData = this.system; let difficulte = Misc.toInt(bonusSoins) + Math.min(0, this.system.sante.vie.value - this.system.sante.vie.max);
let difficulte = Misc.toInt(bonusSoins) + Math.min(0, tData.sante.vie.value - tData.sante.vie.max); let rolled = await RdDResolutionTable.roll(this.system.carac.constitution.value, difficulte);
let rolled = await RdDResolutionTable.roll(tData.carac.constitution.value, difficulte);
if (message) { 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; return rolled;
} }
@ -3422,9 +3414,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async encaisser() { async encaisser() {
let dialogData = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; await RdDEncaisser.encaisser(this);
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', dialogData);
new RdDEncaisser(html, this).render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -3600,17 +3590,17 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async accorder(entite, when = 'avant-encaissement') { async accorder(entite, when = 'avant-encaissement') {
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar") if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|| entite == undefined
|| !entite.isEntite([ENTITE_INCARNE]) || !entite.isEntite([ENTITE_INCARNE])
|| entite.isEntiteAccordee(this)) { || entite.isEntiteAccordee(this)) {
return true; return true;
} }
const tplData = this.system; const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value));
let rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value));
const rollData = { const rollData = {
alias: this.name, alias: this.name,
rolled: rolled, rolled: rolled,
entite: entite.name, entite: entite.name,
selectedCarac: tplData.carac.reve selectedCarac: this.system.carac.reve
}; };
if (rolled.isSuccess) { if (rolled.isSuccess) {

View File

@ -62,6 +62,7 @@ export class DialogChronologie extends Dialog {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
} }
async ajouter() { async ajouter() {
@ -74,11 +75,11 @@ export class DialogChronologie extends Dialog {
} }
async forceValidation() { async forceValidation() {
await $("form.rdddialogchrono :input").change(); await this.html.find("form.rdddialogchrono :input").change();
} }
findJournal() { 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); const journalEntry = game.journal.get(journalId);
return { journalId, journalEntry }; return { journalId, journalEntry };
} }
@ -89,15 +90,15 @@ export class DialogChronologie extends Dialog {
extractJournalParameters() { extractJournalParameters() {
return { return {
auteur: $("form.rdddialogchrono :input[name='auteur']").val(), auteur: this.html.find("form.rdddialogchrono :input[name='auteur']").val(),
information: $("form.rdddialogchrono :input[name='information']").val(), information: this.html.find("form.rdddialogchrono :input[name='information']").val(),
dateRdD: { dateRdD: {
jour: $("form.rdddialogchrono :input[name='jourRdD']").val(), jour: this.html.find("form.rdddialogchrono :input[name='jourRdD']").val(),
moisRdD: $("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(), moisRdD: this.html.find("form.rdddialogchrono :input[name='dateRdD.moisRdD.key']").val(),
annee: $("form.rdddialogchrono :input[name='dateRdD.annee']").val() annee: this.html.find("form.rdddialogchrono :input[name='dateRdD.annee']").val()
}, },
heureRdD: $("form.rdddialogchrono :input[name='heureRdD']").val(), heureRdD: this.html.find("form.rdddialogchrono :input[name='heureRdD']").val(),
dateReel: $("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ') dateReel: this.html.find("form.rdddialogchrono :input[name='dateReel']").val().replace('T', ' ')
} }
} }

View File

@ -35,16 +35,16 @@ export class DialogCreateSigneDraconique extends Dialog {
super(conf, options); super(conf, options);
this.dialogData = dialogData; this.dialogData = dialogData;
} }
async _onCreerSigneActeurs() { async _onCreerSigneActeurs() {
await $("[name='signe.system.ephemere']").change(); await this.html.find("[name='signe.system.ephemere']").change();
await $(".signe-xp-sort").change(); await this.html.find(".signe-xp-sort").change();
this.validerSigne(); this.validerSigne();
this.dialogData.actors.filter(it => it.selected) this.dialogData.actors.filter(it => it.selected)
.map(it => game.actors.get(it.id)) .map(it => game.actors.get(it.id))
.forEach(actor => this._createSigneForActor(actor, this.dialogData.signe)); .forEach(actor => this._createSigneForActor(actor, this.dialogData.signe));
} }
async _createSigneForActor(actor, signe) { async _createSigneForActor(actor, signe) {
actor.createEmbeddedDocuments("Item", [signe]); actor.createEmbeddedDocuments("Item", [signe]);
ChatMessage.create({ ChatMessage.create({
@ -57,19 +57,20 @@ export class DialogCreateSigneDraconique extends Dialog {
} }
validerSigne() { validerSigne() {
this.dialogData.signe.name = $("[name='signe.name']").val(); this.dialogData.signe.name = this.html.find("[name='signe.name']").val();
this.dialogData.signe.system.valeur.norm = $("[name='signe.system.valeur.norm']").val(); this.dialogData.signe.system.valeur.norm = this.html.find("[name='signe.system.valeur.norm']").val();
this.dialogData.signe.system.valeur.sign = $("[name='signe.system.valeur.sign']").val(); this.dialogData.signe.system.valeur.sign = this.html.find("[name='signe.system.valeur.sign']").val();
this.dialogData.signe.system.valeur.part = $("[name='signe.system.valeur.part']").val(); this.dialogData.signe.system.valeur.part = this.html.find("[name='signe.system.valeur.part']").val();
this.dialogData.signe.system.difficulte = $("[name='signe.system.difficulte']").val(); this.dialogData.signe.system.difficulte = this.html.find("[name='signe.system.difficulte']").val();
this.dialogData.signe.system.ephemere = $("[name='signe.system.ephemere']").prop("checked"); this.dialogData.signe.system.ephemere = this.html.find("[name='signe.system.ephemere']").prop("checked");
this.dialogData.signe.system.duree = $("[name='signe.system.duree']").val(); this.dialogData.signe.system.duree = this.html.find("[name='signe.system.duree']").val();
this.dialogData.signe.system.typesTMR = TMRUtility.buildListTypesTMRSelection(this.dialogData.tmrs); this.dialogData.signe.system.typesTMR = TMRUtility.buildListTypesTMRSelection(this.dialogData.tmrs);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
this.setEphemere(this.dialogData.signe.system.ephemere); this.setEphemere(this.dialogData.signe.system.ephemere);
html.find(".signe-aleatoire").click(event => this.setSigneAleatoire()); html.find(".signe-aleatoire").click(event => this.setSigneAleatoire());
html.find("[name='signe.system.ephemere']").change((event) => this.setEphemere(event.currentTarget.checked)); html.find("[name='signe.system.ephemere']").change((event) => this.setEphemere(event.currentTarget.checked));
@ -81,27 +82,27 @@ export class DialogCreateSigneDraconique extends Dialog {
async setSigneAleatoire() { async setSigneAleatoire() {
const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true}); const newSigne = await RdDItemSigneDraconique.randomSigneDraconique({ephemere: true});
$("[name='signe.name']").val(newSigne.name); this.html.find("[name='signe.name']").val(newSigne.name);
$("[name='signe.system.valeur.norm']").val(newSigne.system.valeur.norm); this.html.find("[name='signe.system.valeur.norm']").val(newSigne.system.valeur.norm);
$("[name='signe.system.valeur.sign']").val(newSigne.system.valeur.sign); this.html.find("[name='signe.system.valeur.sign']").val(newSigne.system.valeur.sign);
$("[name='signe.system.valeur.part']").val(newSigne.system.valeur.part); this.html.find("[name='signe.system.valeur.part']").val(newSigne.system.valeur.part);
$("[name='signe.system.difficulte']").val(newSigne.system.difficulte); this.html.find("[name='signe.system.difficulte']").val(newSigne.system.difficulte);
$("[name='signe.system.duree']").val(newSigne.system.duree); this.html.find("[name='signe.system.duree']").val(newSigne.system.duree);
$("[name='signe.system.ephemere']").prop("checked", newSigne.system.ephemere); this.html.find("[name='signe.system.ephemere']").prop("checked", newSigne.system.ephemere);
this.dialogData.tmrs = TMRUtility.buildSelectionTypesTMR(newSigne.system.typesTMR); this.dialogData.tmrs = TMRUtility.buildSelectionTypesTMR(newSigne.system.typesTMR);
this.dialogData.tmrs.forEach(t => { 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); this.setEphemere(newSigne.system.ephemere);
} }
async setEphemere(ephemere) { async setEphemere(ephemere) {
this.dialogData.signe.system.ephemere = 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) { 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); const actor = this.dialogData.actors.find(it => it.id == actorId);
if (actor) { if (actor) {
actor.selected = event.currentTarget.checked; actor.selected = event.currentTarget.checked;
@ -109,7 +110,7 @@ export class DialogCreateSigneDraconique extends Dialog {
} }
onSelectTmr(event) { 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); const onTmr = this.tmrs.find(it => it.name == tmrName);
if (onTmr){ if (onTmr){
onTmr.selected = event.currentTarget.checked; onTmr.selected = event.currentTarget.checked;

View File

@ -13,18 +13,12 @@ export class DialogFabriquerPotion extends Dialog {
} }
let potionData = DialogFabriquerPotion.prepareData(actor, item); let potionData = DialogFabriquerPotion.prepareData(actor, item);
let conf = { const html = await renderTemplate(dialogConfig.html, potionData);
title: `Fabriquer une potion de ${potionData.system.categorie}`,
content: await renderTemplate(dialogConfig.html, potionData),
default: potionData.buttonName,
};
let options = { classes: ["dialogfabriquerpotion"], width: 600, height: 160, 'z-index': 99999 }; let options = { classes: ["dialogfabriquerpotion"], width: 600, height: 160, 'z-index': 99999 };
mergeObject(options, dialogConfig.options ?? {}, { overwrite: true }) mergeObject(options, dialogConfig.options ?? {}, { overwrite: true })
const dialog = new DialogFabriquerPotion(actor, potionData, conf, options); new DialogFabriquerPotion(actor, potionData, html, options).render(true);
dialog.render(true);
return dialog;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -40,10 +34,15 @@ export class DialogFabriquerPotion extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(actor, potionData, conf, options) { constructor(actor, potionData, html, options) {
conf.buttons = { const conf = {
[potionData.buttonName]: { title: `Fabriquer une potion de ${potionData.system.categorie}`,
label: potionData.buttonName, callback: it => this.onFabriquer(it) 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; 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) { static nombreBrinsMinimum(herbeData) {
switch (herbeData.system.categorie ?? '') { switch (herbeData.system.categorie ?? '') {
case "Soin": return 1 + Math.max(0, 12 - 2 * herbeData.system.niveau); case "Soin": return 1 + Math.max(0, 12 - 2 * herbeData.system.niveau);
@ -68,22 +85,4 @@ export class DialogFabriquerPotion extends Dialog {
} }
return 1; 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();
}
} }

View File

@ -42,8 +42,7 @@ export class DialogItemAchat extends Dialog {
static async onAcheter(venteData) { static async onAcheter(venteData) {
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData); const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-item-achat.html`, venteData);
const dialog = new DialogItemAchat(html, venteData); new DialogItemAchat(html, venteData).render(true);
dialog.render(true);
} }
constructor(html, venteData) { constructor(html, venteData) {
@ -65,12 +64,11 @@ export class DialogItemAchat extends Dialog {
}; };
super(conf, options); super(conf, options);
this.venteData = venteData; this.venteData = venteData;
} }
async onAchat() { async onAchat() {
await $(".nombreLots").change(); await this.html.find(".nombreLots").change();
(this.venteData.vendeur ?? this.venteData.acheteur).achatVente({ (this.venteData.vendeur ?? this.venteData.acheteur).achatVente({
userId: game.user.id, userId: game.user.id,
vendeurId: this.venteData.vendeur?.id, vendeurId: this.venteData.vendeur?.id,
@ -90,9 +88,9 @@ export class DialogItemAchat extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
html.find(".nombreLots").change(event => this.setNombreLots(Number(event.currentTarget.value))); this.html.find(".nombreLots").change(event => this.setNombreLots(Number(event.currentTarget.value)));
html.find(".se-forcer").change(event => this.setSeForcer(event)); this.html.find(".se-forcer").change(event => this.setSeForcer(event));
} }
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.choix.nombreLots = Math.min(nombreLots, this.venteData.quantiteNbLots);
this.venteData.prixTotal = (nombreLots * this.venteData.prixLot).toFixed(2); this.venteData.prixTotal = (nombreLots * this.venteData.prixLot).toFixed(2);
$(".nombreLots").val(this.venteData.choix.nombreLots); this.html.find(".nombreLots").val(this.venteData.choix.nombreLots);
$(".prixTotal").text(this.venteData.prixTotal); this.html.find(".prixTotal").text(this.venteData.prixTotal);
} }
} }

View File

@ -17,7 +17,7 @@ export class DialogConsommer extends Dialog {
buttons: { buttons: {
[consommerData.buttonName]: { [consommerData.buttonName]: {
label: consommerData.buttonName, callback: async it => { label: consommerData.buttonName, callback: async it => {
await this.onConsommer(it); await this.onConsommer();
await onActionItem(); await onActionItem();
} }
} }
@ -31,9 +31,16 @@ export class DialogConsommer extends Dialog {
this.consommerData = consommerData; this.consommerData = consommerData;
} }
async onConsommer(event) { activateListeners(html) {
await $(".se-forcer").change(); super.activateListeners(html);
await $(".consommer-doses").change(); 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); 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) { setSeForcer(event) {
this.consommerData.choix.seForcer = event.currentTarget.checked; this.consommerData.choix.seForcer = event.currentTarget.checked;
} }
@ -107,7 +106,7 @@ export class DialogConsommer extends Dialog {
selectDoses(event) { selectDoses(event) {
this.consommerData.choix.doses = Number(event.currentTarget.value); this.consommerData.choix.doses = Number(event.currentTarget.value);
DialogConsommer.calculDoses(this.consommerData, this.item); DialogConsommer.calculDoses(this.consommerData, this.item);
$(".total-sust").text(this.consommerData.totalSust); this.html.find(".total-sust").text(this.consommerData.totalSust);
$(".total-desaltere").text(this.consommerData.totalDesaltere); this.html.find(".total-desaltere").text(this.consommerData.totalDesaltere);
} }
} }

View File

@ -37,26 +37,26 @@ export class DialogItemVente extends Dialog {
this.venteData = venteData; this.venteData = venteData;
} }
async onProposer(it) {
await $(".tailleLot").change();
await $(".quantiteNbLots").change();
await $(".quantiteIllimite").change();
await $(".prixLot").change();
this.callback(this.venteData);
}
/* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
HtmlUtility._showControlWhen($(".quantiteNbLots"), !this.venteData.quantiteIllimite) this.html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value)));
this.html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value)));
html.find(".tailleLot").change(event => this.setTailleLot(Number(event.currentTarget.value))); this.html.find(".quantiteIllimite").change(event => this.setQuantiteIllimite(event.currentTarget.checked));
html.find(".quantiteNbLots").change(event => this.setNbLots(Number(event.currentTarget.value))); this.html.find(".prixLot").change(event => this.setPrixLot(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)));
} }
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) { setPrixLot(prixLot) {
this.venteData.prixLot = prixLot; this.venteData.prixLot = prixLot;
} }
@ -65,15 +65,15 @@ export class DialogItemVente extends Dialog {
// recalculer le prix du lot // recalculer le prix du lot
if (tailleLot != this.venteData.tailleLot) { if (tailleLot != this.venteData.tailleLot) {
this.venteData.prixLot = (tailleLot * this.venteData.prixOrigine).toFixed(2); 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; this.venteData.tailleLot = tailleLot;
if (this.venteData.isOwned) { if (this.venteData.isOwned) {
// recalculer le nombre de lots max // recalculer le nombre de lots max
this.venteData.quantiteMaxLots = Math.floor(this.venteData.quantiteMax / tailleLot); this.venteData.quantiteMaxLots = Math.floor(this.venteData.quantiteMax / tailleLot);
this.venteData.quantiteNbLots = Math.min(this.venteData.quantiteMaxLots, this.venteData.quantiteNbLots); this.venteData.quantiteNbLots = Math.min(this.venteData.quantiteMaxLots, this.venteData.quantiteNbLots);
$(".quantiteNbLots").val(this.venteData.quantiteNbLots); this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
$(".quantiteNbLots").attr("max", this.venteData.quantiteMaxLots) 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)); nbLots = Math.max(0, Math.min(nbLots, this.venteData.quantiteMaxLots));
} }
this.venteData.quantiteNbLots = nbLots; this.venteData.quantiteNbLots = nbLots;
$(".quantiteNbLots").val(this.venteData.quantiteNbLots); this.html.find(".quantiteNbLots").val(this.venteData.quantiteNbLots);
} }
setQuantiteIllimite(checked) { setQuantiteIllimite(checked) {
this.venteData.quantiteIllimite = checked; this.venteData.quantiteIllimite = checked;
$(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles"); this.html.find(".label-quantiteIllimite").text(this.venteData.quantiteIllimite ? "Illimités" : "disponibles");
HtmlUtility._showControlWhen($(".quantiteNbLots"), !this.venteData.quantiteIllimite) HtmlUtility._showControlWhen(this.html.find(".quantiteNbLots"), !this.venteData.quantiteIllimite)
} }
} }

View File

@ -21,13 +21,18 @@ export class DialogRepos extends Dialog {
super(conf, options); super(conf, options);
this.actor = actor; this.actor = actor;
} }
activateListeners(html) {
super.activateListeners(html);
this.html = html;
}
/* -------------------------------------------- */
async repos() { async repos() {
await $("[name='nb-heures']").change(); await this.html.find("[name='nb-heures']").change();
await $("[name='nb-jours']").change(); await this.html.find("[name='nb-jours']").change();
const selection = await $("[name='repos']:checked").val(); const selection = await this.html.find("[name='repos']:checked").val();
const nbHeures = Number.parseInt(await $("[name='nb-heures']").val()); const nbHeures = Number.parseInt(await this.html.find("[name='nb-heures']").val());
const nbJours = Number.parseInt(await $("[name='nb-jours']").val()); const nbJours = Number.parseInt(await this.html.find("[name='nb-jours']").val());
switch (selection) { switch (selection) {
case "sieste": { case "sieste": {
await this.actor.dormir(nbHeures); await this.actor.dormir(nbHeures);
@ -35,7 +40,7 @@ export class DialogRepos extends Dialog {
} }
case "nuit": { case "nuit": {
let heuresDormies = await this.actor.dormir(nbHeures); let heuresDormies = await this.actor.dormir(nbHeures);
if (heuresDormies == nbHeures){ if (heuresDormies == nbHeures) {
await this.actor.dormirChateauDormant(); await this.actor.dormirChateauDormant();
} }
return; return;
@ -49,8 +54,4 @@ export class DialogRepos extends Dialog {
} }
} }
} }
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
}
} }

View File

@ -20,8 +20,9 @@ export class DialogSelectTarget extends Dialog {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
html.find("li.select-target").click((event) => { this.html = html;
this.targetSelected($(event.currentTarget)?.data("token-id")); this.html.find("li.select-target").click((event) => {
this.targetSelected(this.html.find(event.currentTarget)?.data("token-id"));
}); });
} }

View File

@ -13,39 +13,33 @@ export class DialogSplitItem extends Dialog {
constructor(item, splitData, html, callback) { constructor(item, splitData, html, callback) {
let options = { classes: ["dialogsplit"], width: 300, height: 160, 'z-index': 99999 }; let options = { classes: ["dialogsplit"], width: 300, height: 160, 'z-index': 99999 };
let conf = { let conf = {
title: "Séparer en deux", title: "Séparer en deux",
content: html, content: html,
default: "separer", default: "separer",
buttons: { buttons: {
"separer": { "separer": { label: "Séparer", callback: it => this.onSplit() }
label: "Séparer", callback: it => {
this.onSplit();
}
}
} }
}; };
super(conf, options); super(conf, options);
this.callback = callback; this.callback = callback;
this.item = item; this.item = item;
this.splitData = splitData; this.splitData = splitData;
} }
async onSplit(){
await $(".choix-quantite").change();
this.callback(this.item, this.splitData.choix.quantite);
}
/* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
html.find(".choix-quantite").change(event => { this.html.find(".choix-quantite").change(event => {
this.splitData.choix.quantite = Number(event.currentTarget.value); 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);
}
} }

View File

@ -37,24 +37,24 @@ export class DialogStress extends Dialog {
this.dialogData = dialogData; this.dialogData = dialogData;
} }
activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.html.find("input.select-actor").change((event) => this.onSelectActor(event));
}
async onStress() { async onStress() {
const motif = $("form.rdddialogstress input[name='motif']").val(); const motif = this.html.find("form.rdddialogstress input[name='motif']").val();
const stress = Number($("form.rdddialogstress input[name='stress']").val()); const stress = Number(this.html.find("form.rdddialogstress input[name='stress']").val());
const compteur = ($("form.rdddialogstress input[name='immediat']").prop("checked")) ? 'experience' : 'stress'; const compteur = (this.html.find("form.rdddialogstress input[name='immediat']").prop("checked")) ? 'experience' : 'stress';
this.dialogData.actors.filter(it => it.selected) this.dialogData.actors.filter(it => it.selected)
.map(it => game.actors.get(it.id)) .map(it => game.actors.get(it.id))
.forEach(actor => actor.distribuerStress(compteur, stress, motif)); .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) { 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); const actor = this.dialogData.actors.find(it => it.id == actorId);
if (actor) { if (actor) {
actor.selected = event.currentTarget.checked; actor.selected = event.currentTarget.checked;

View File

@ -35,7 +35,7 @@ export class DialogValidationEncaissement extends Dialog {
} }
let dialogOptions = { let dialogOptions = {
classes: ["rdddialog"], classes: ["rdd-roll-dialog"],
width: 350, width: 350,
height: 290 height: 290
} }
@ -55,11 +55,12 @@ export class DialogValidationEncaissement extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.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.forceDiceResult.total = event.currentTarget.value;
this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: HIDE_DICE, forceDiceResult: this.forceDiceResult}); this.encaissement = await RdDUtility.jetEncaissement(this.rollData, this.armure, { showDice: HIDE_DICE, forceDiceResult: this.forceDiceResult});
$('label.encaissement-total').text(this.encaissement.total); this.html.find('label.encaissement-total').text(this.encaissement.total);
$('label.encaissement-blessure').text(this.encaissement.blessures) this.html.find('label.encaissement-blessure').text(this.encaissement.blessures)
}); });
} }

View File

@ -147,29 +147,29 @@ export class EnvironmentSheetHelper {
}); });
} }
static activateListeners(sheet, html) { static activateListeners(sheet) {
if (!sheet.options.editable) return; 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') { if (event.keyCode == '13') {
EnvironmentSheetHelper.onAddMilieu(html, sheet, event); EnvironmentSheetHelper.onAddMilieu(sheet, event);
} }
event.stopPropagation(); event.stopPropagation();
}) })
html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(html, sheet, event)); sheet.html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(sheet, event));
html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event)); sheet.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, sheet.html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event,
updated => EnvironmentSheetHelper.$changeRarete(event, updated))); updated => EnvironmentSheetHelper.$changeRarete(sheet, event, updated)));
html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event, sheet.html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event,
updated => EnvironmentSheetHelper.$changeFrequence(updated, event))); updated => EnvironmentSheetHelper.$changeFrequence(sheet, event, updated)));
} }
static $changeFrequence(updated, event) { static $changeFrequence(sheet, event, updated) {
updated.frequence = Number($(event.currentTarget).val()); updated.frequence = Number(sheet.html.find(event.currentTarget).val());
} }
static $changeRarete(event, updated) { static $changeRarete(sheet, event, updated) {
const name = $(event.currentTarget).val(); const name = sheet.html.find(event.currentTarget).val();
const rarete = Environnement.getRarete(name); const rarete = Environnement.getRarete(name);
updated.rarete = rarete.name; updated.rarete = rarete.name;
updated.frequence = rarete.frequence; updated.frequence = rarete.frequence;
@ -178,8 +178,8 @@ export class EnvironmentSheetHelper {
// rarete.max); // rarete.max);
} }
static async onAddMilieu(html, sheet, event) { static async onAddMilieu(sheet, event) {
const milieu = html.find('input.input-selection-milieu').val(); const milieu = sheet.html.find('input.input-selection-milieu').val();
if (!milieu) { if (!milieu) {
ui.notifications.warn(`Choisissez le milieu dans lequel se trouve le/la ${sheet.item.name}`); ui.notifications.warn(`Choisissez le milieu dans lequel se trouve le/la ${sheet.item.name}`);
return return
@ -206,7 +206,7 @@ export class EnvironmentSheetHelper {
static async onChange(sheet, event, doMutation) { static async onChange(sheet, event, doMutation) {
const list = sheet.item.system.environnement; 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); const updated = list.find(it => it.milieu == milieu);
if (updated) { if (updated) {
doMutation(updated); doMutation(updated);
@ -216,8 +216,8 @@ export class EnvironmentSheetHelper {
} }
} }
static $getEventMilieu(event) { static $getEventMilieu(sheet, event) {
return $(event.currentTarget)?.parents("div.environnement-milieu").data("milieu"); return sheet.html.find(event.currentTarget)?.parents("div.environnement-milieu").data("milieu");
} }
} }

View File

@ -1,10 +1,10 @@
export class HtmlUtility{ export class HtmlUtility{
static _showControlWhen(control, condition) { static _showControlWhen(jQuerySelector, condition) {
if (condition) { if (condition) {
control.show(); jQuerySelector.show();
} }
else { else {
control.hide(); jQuerySelector.hide();
} }
} }
} }

View File

@ -16,9 +16,10 @@ export class RdDConteneurItemSheet extends RdDItemSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; 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)); RdDUtility.toggleAfficheContenu(RdDSheetUtility.getItemId(event));
this.render(true); this.render(true);
}); });

View File

@ -23,7 +23,7 @@ export class RdDFauneItemSheet extends RdDItemSheet {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; 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.linked-actor-delete").click(event => this.onDeleteLinkedActor());
html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event)); html.find("a.preparer-nourriture").click(event => this.preparerNourriture(event));

View File

@ -20,6 +20,6 @@ export class RdDHerbeItemSheet extends RdDItemSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
EnvironmentSheetHelper.activateListeners(this, html); EnvironmentSheetHelper.activateListeners(this);
} }
} }

View File

@ -20,6 +20,6 @@ export class RdDIngredientItemSheet extends RdDItemSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
EnvironmentSheetHelper.activateListeners(this, html); EnvironmentSheetHelper.activateListeners(this);
} }
} }

View File

@ -51,15 +51,15 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.options.editable) return;
html.find("a.effet-add").click(event => this.onAddEffet(event)); this.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-delete").click(event => this.onDeleteEffet(event));
} }
async onAddEffet(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 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); const liste = RdDRencontre.getListeEffets(this.item, resultat);
liste.push(code); liste.push(code);
@ -67,10 +67,10 @@ export class RdDRencontreItemSheet extends RdDItemSheet {
} }
async onDeleteEffet(event) { 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 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); const liste = RdDRencontre.getListeEffets(this.item, resultat);
liste.splice(pos, 1); liste.splice(pos, 1);

View File

@ -157,36 +157,39 @@ export class RdDItemSheet extends ItemSheet {
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
let itemSheetDialog = this; let itemSheetDialog = this;
HtmlUtility._showControlWhen($(".item-cout"), ReglesOptionelles.isUsing('afficher-prix-joueurs') || game.user.isGM || !this.item.isOwned); HtmlUtility._showControlWhen(this.html.find(".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-magique"), this.item.isMagique());
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
this.form.ondragstart = (event) => this._onDragStart(event); this.form.ondragstart = (event) => this._onDragStart(event);
this.form.ondrop = (event) => this._onDrop(event); this.form.ondrop = (event) => this._onDrop(event);
// Select competence categorie // 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()) { if (this.item.isCompetencePersonnage()) {
RdDUtility.checkThanatosXP(this.item.name); RdDUtility.checkThanatosXP(this.item.name);
} }
}); });
html.find('.enchanteDate').change((event) => { this.html.find('.enchanteDate').change((event) => {
let jour = Number($('#jourMois').val()); let jour = Number(this.html.find('[name="splitDate.day"]').val());
let mois = $('#nomMois').val(); let mois = this.html.find('[name="splitDate.month"]').val();
this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois); this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois);
}); });
html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item)); this.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)); this.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-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); let actor = this._getEventActor(event);
if (actor) { if (actor) {
let recetteId = event.currentTarget.attributes['data-recette-id'].value; 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))); this.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)); this.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))); this.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()); this.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()); this.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-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => itemSheetDialog.render(true)));
} }
_getEventActor(event) { _getEventActor(event) {
@ -219,7 +222,7 @@ export class RdDItemSheet extends ItemSheet {
if (this.item.isCompetence()) { if (this.item.isCompetence()) {
let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value); let level = RdDItemCompetence.getNiveauBase(event.currentTarget.value);
this.item.system.base = level; this.item.system.base = level;
$("#base").val(level); this.html.find('[name="system.base"]').val(level);
} }
} }

View File

@ -15,13 +15,19 @@
// Common conf // Common conf
let dialogConf = { content: html, title: "Editeur d'Astrologie", buttons: myButtons, default: "saveButton" }; 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) super(dialogConf, dialogOptions)
this.calendrier = calendrier; this.calendrier = calendrier;
this.updateData( calendrierData ); this.updateData( calendrierData );
} }
activateListeners(html) {
super.activateListeners(html);
this.html = html;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async resetNombreAstraux() { async resetNombreAstraux() {
game.system.rdd.calendrier.resetNombreAstral(); game.system.rdd.calendrier.resetNombreAstral();
@ -39,15 +45,4 @@
this.calendrierData = duplicate(calendrierData); this.calendrierData = duplicate(calendrierData);
} }
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
let astrologieData = this.astrologieData;
$(function () {
});
}
} }

View File

@ -20,7 +20,7 @@ export class RdDAstrologieJoueur extends Dialog {
astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie') astrologie: RdDItemCompetence.findCompetence(actor.items, 'Astrologie')
} }
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', dialogData); 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) { if (dialogConfig.options) {
mergeObject(options, dialogConfig.options, { overwrite: true }); mergeObject(options, dialogConfig.options, { overwrite: true });
} }
@ -29,21 +29,35 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor, dialogData) { constructor(html, actor, dialogData) {
const dialogConf = {
let myButtons = { title: "Nombres Astraux",
saveButton: { label: "Fermer", callback: html => this.quitDialog() } content: html,
default: "saveButton",
buttons: {
saveButton: { label: "Fermer", callback: html => this.quitDialog() }
},
}; };
const dialogOptions = { classes: ["rdd-roll-dialog"], width: 600, height: 300, 'z-index': 99999 };
// 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 };
super(dialogConf, dialogOptions); super(dialogConf, dialogOptions);
this.actor = actor; this.actor = actor;
this.dataNombreAstral = duplicate(dialogData); 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) { static organizeNombres(actor) {
let itemNombres = actor.listItemsData('nombreastral'); let itemNombres = actor.listItemsData('nombreastral');
@ -68,8 +82,8 @@ export class RdDAstrologieJoueur extends Dialog {
carac_vue: this.actor.system.carac['vue'].value, carac_vue: this.actor.system.carac['vue'].value,
etat: this.dataNombreAstral.etat, etat: this.dataNombreAstral.etat,
astrologie: this.dataNombreAstral.astrologie, astrologie: this.dataNombreAstral.astrologie,
conditions: $("#diffConditions").val(), conditions: this.html.find('[name="diffConditions"]').val(),
date: $("#joursAstrologie").val(), date: this.html.find('[name="joursAstrologie"]').val(),
userId: game.user.id userId: game.user.id
} }
if (Misc.isUniqueConnectedGM()) { if (Misc.isUniqueConnectedGM()) {
@ -87,17 +101,4 @@ export class RdDAstrologieJoueur extends Dialog {
quitDialog() { quitDialog() {
} }
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
$(function () {
$("#diffConditions").val(0);
});
html.find('#jet-astrologie').click((event) => {
this.requestJetAstrologie();
});
}
} }

View File

@ -23,15 +23,24 @@ export class RdDCalendrierEditeur extends Dialog {
this.calendrierData = calendrierData; 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() { fillData() {
this.calendrierData.annee = $("input[name='annee']").val(); this.calendrierData.annee = this.html.find("input[name='annee']").val();
this.calendrierData.moisKey = $("select[name='nomMois']").val(); this.calendrierData.moisKey = this.html.find("select[name='nomMois']").val();
this.calendrierData.heureKey = $("select[name='nomHeure']").val(); this.calendrierData.heureKey = this.html.find("select[name='nomHeure']").val();
this.calendrierData.jourMois = $("select[name='jourMois']").val(); this.calendrierData.jourMois = this.html.find("select[name='jourMois']").val();
this.calendrierData.minutesRelative = $("select[name='minutesRelative']").val(); this.calendrierData.minutesRelative = this.html.find("select[name='minutesRelative']").val();
console.log("UPDATE ", this.calendrierData);
this.calendrier.saveEditeur(this.calendrierData) this.calendrier.saveEditeur(this.calendrierData)
} }
@ -40,21 +49,4 @@ export class RdDCalendrierEditeur extends Dialog {
this.calendrierData = duplicate(calendrierData); 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);
});
}
} }

View File

@ -43,6 +43,14 @@ const MAX_NOMBRE_ASTRAL = 12;
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDCalendrier extends Application { 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() { static createCalendrierPos() {
return { top: 200, left: 200 }; return { top: 200, left: 200 };
} }
@ -121,20 +129,103 @@ export class RdDCalendrier extends Application {
console.log('RdDCalendrier.constructor()', this.calendrier, this.calendrierPos, this.listeNombreAstral); 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() { getListeNombreAstral() {
return game.settings.get(SYSTEM_RDD, "liste-nombre-astral") ?? []; 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) { getDateFromIndex(index) {
const dateRdD = this.getCalendrier(index); const dateRdD = this.getCalendrier(index);
@ -555,97 +646,4 @@ export class RdDCalendrier extends Application {
astrologieEditeur.updateData(calendrierData); astrologieEditeur.updateData(calendrierData);
astrologieEditeur.render(true); 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);
}
});
}
} }

View File

@ -767,7 +767,7 @@ export class RdDCombat {
// whisper: ChatMessage.getWhisperRecipients("GM")}) // whisper: ChatMessage.getWhisperRecipients("GM")})
// } // }
if (!await this.accorderEntite('avant-attaque')) { if (!await this.attacker.accorder(this.defender, 'avant-attaque')) {
return; return;
} }
if (arme.system.cac == 'empoignade' && this.attacker.isCombatTouche()) { 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'); 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; return;
} }
@ -1319,35 +1319,6 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); 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) + "<br>",
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) { static async displayActorCombatStatus(combat, actor) {
let formData = { let formData = {

View File

@ -14,7 +14,7 @@ const levelDown = [
{ level: -15, score: 1, norm: 1, sign: 0, part: 0, epart: 2, etotal: 10 }, { 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 } { 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 = [ 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 }, { 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; 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) { static getResultat(code) {
let resultat = reussites.find(r => code == r.code); let resultat = reussites.find(r => code == r.code);
@ -51,17 +89,6 @@ export class RdDResolutionTable {
return resultat; return resultat;
} }
/* -------------------------------------------- */
static explain(rolled) {
let message = "<br>Jet : <strong>" + rolled.roll + "</strong> 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 += '<strong>' + rolled.quality + '</strong>'
return message;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') { static async displayRollData(rollData, actor = undefined, template = 'chat-resultat-general.html') {
return await ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, { return await ChatUtility.createChatWithRollMode(actor?.userName ?? game.user.name, {
@ -82,8 +109,8 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async roll(caracValue, finalLevel, rollData = {}){ static async roll(caracValue, finalLevel, rollData = {}) {
let chances = this.computeChances(caracValue, finalLevel); let chances = duplicate(this.computeChances(caracValue, finalLevel));
this._updateChancesWithBonus(chances, rollData.bonus, finalLevel); this._updateChancesWithBonus(chances, rollData.bonus, finalLevel);
this._updateChancesFactor(chances, rollData.diviseurSignificative); this._updateChancesFactor(chances, rollData.diviseurSignificative);
chances.showDice = rollData.showDice; chances.showDice = rollData.showDice;
@ -95,7 +122,7 @@ export class RdDResolutionTable {
rolled.bonus = rollData.bonus; rolled.bonus = rollData.bonus;
rolled.factorHtml = Misc.getFractionHtml(rollData.diviseurSignificative); 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.niveauNecessaire = this.findNiveauNecessaire(caracValue, rolled.roll);
rolled.ajustementNecessaire = rolled.niveauNecessaire - finalLevel; rolled.ajustementNecessaire = rolled.niveauNecessaire - finalLevel;
} }
@ -103,13 +130,24 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static findNiveauNecessaire(caracValue, rollValue) { static findNiveauNecessaire(carac, rolled) {
for (let cell of this.resolutionTable[caracValue]) { if (carac == 0) {
if ( rollValue <= cell.norm) { return NaN;
return cell.niveau;
}
} }
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) { static _updateChancesWithBonus(chances, bonus, finalLevel) {
if (bonus && finalLevel>-11) { if (bonus && finalLevel > -11) {
let newScore = Number(chances.score) + bonus; let newScore = Number(chances.score) + bonus;
mergeObject(chances, this._computeCell(undefined, newScore), { overwrite: true }); mergeObject(chances, this._computeCell(undefined, newScore), { overwrite: true });
} }
@ -142,21 +180,19 @@ export class RdDResolutionTable {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollChances(chances, diviseur, forceDiceResult = -1) { static async rollChances(chances, diviseur, forceDiceResult = -1) {
chances.forceDiceResult = forceDiceResult <= 0 || forceDiceResult > 100 ? undefined : {total: forceDiceResult}; chances.forceDiceResult = forceDiceResult <= 0 || forceDiceResult > 100 ? undefined : { total: forceDiceResult };
chances.roll = await RdDDice.rollTotal( "1d100", chances); chances.roll = await RdDDice.rollTotal("1d100", chances);
mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true }); mergeObject(chances, this.computeReussite(chances, chances.roll, diviseur), { overwrite: true });
return chances; return chances;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeChances(caracValue, difficulte) { static computePercentage(carac, diff) {
if (difficulte < -16) { if (diff < -16) return 0
return duplicate(levelImpossible); if (diff < -10) return 1
} if (diff == -10) return Math.max(Math.floor(carac / 4), 1)
if (difficulte < -10) { if (diff == -9) return Math.max(Math.floor(carac / 2), 1)
return duplicate(levelDown.find(levelData => levelData.level == difficulte)); return Math.max(Math.floor(carac * (diff + 10) / 2), 1);
}
return duplicate(RdDResolutionTable.resolutionTable[caracValue][difficulte + 10]);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -213,31 +249,6 @@ export class RdDResolutionTable {
return reussite; 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) { static _reussiteSignificative(percentage) {
return Math.floor(percentage / 2); return Math.floor(percentage / 2);
@ -261,92 +272,34 @@ export class RdDResolutionTable {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildHTMLResults(caracValue, levelValue) { static subTable(carac, level, delta = { carac: 2, level: 5}) {
if (caracValue == undefined || isNaN(caracValue)) caracValue = 10; return {
if (levelValue == undefined || isNaN(levelValue)) levelValue = 0; carac,
level,
let cell = this.computeChances(caracValue, levelValue); minCarac: carac - (delta?.carac ?? 2),
cell.epart = cell.epart > 99 ? 'N/A' : cell.epart; maxCarac: carac + (delta?.carac ?? 2),
cell.etotal = cell.etotal > 100 ? 'N/A' : cell.etotal; minLevel: level - (delta?.level ?? 5),
cell.score = Math.min(cell.score, 99); maxLevel: level + (delta?.level ?? 5)
};
return `
<span class="table-proba-reussite competence-label">
Particulière: <span class="rdd-roll-part">${cell.part}</span>
- Significative: <span class="rdd-roll-sign">${cell.sign}</span>
- Réussite: <span class="rdd-roll-norm">${cell.score}</span>
- Echec Particulier: <span class="rdd-roll-epart">${cell.epart}</span>
- Echec Total: <span class="rdd-roll-etotal">${cell.etotal}</span>
</span>
`
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildHTMLTableExtract(caracValue, levelValue) { static async buildHTMLTable({ carac: carac, level: level, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11 }) {
return this.buildHTMLTable(caracValue, levelValue, caracValue - 2, caracValue + 2, levelValue - 5, levelValue + 5) let colonnes = maxLevel - minLevel;
}
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;
minCarac = Math.max(minCarac, 1); minCarac = Math.max(minCarac, 1);
maxCarac = Math.min(maxCarac, caracMaximumResolution); maxCarac = Math.min(maxCarac, minCarac + 20);
minLevel = Math.max(minLevel, -10); minLevel = Math.max(minLevel, -10);
maxLevel = Math.max(Math.min(maxLevel, 22), minLevel + countColonnes); maxLevel = Math.max(Math.min(maxLevel, 30), minLevel + colonnes);
return await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/resolution-table.html', {
let table = $("<table class='table-resolution'/>") carac: carac,
.append(this._buildHTMLHeader(RdDResolutionTable.resolutionTable[0], minLevel, maxLevel)); difficulte: level,
min: minLevel,
for (var rowIndex = minCarac; rowIndex <= maxCarac; rowIndex++) { rows: RdDResolutionTable.incrementalArray(minCarac, maxCarac),
table.append(this._buildHTMLRow(RdDResolutionTable.resolutionTable[rowIndex], rowIndex, caracValue, levelValue, minLevel, maxLevel)); cols: RdDResolutionTable.incrementalArray(minLevel, maxLevel)
} });
table.append("</table>");
return table;
} }
static incrementalArray(min, max) {
/* -------------------------------------------- */ return Array.from(Array(max-min+1).keys()).map(i=>i+min)
static _buildHTMLHeader(dataRow, minLevel, maxLevel) {
let tr = $("<tr/>");
if (minLevel > -8) {
tr.append($("<th class='table-resolution-level'/>").text("-8"))
}
if (minLevel > -7) {
tr.append($("<th class='table-resolution-level'/>").text("..."));
}
for (let difficulte = minLevel; difficulte <= maxLevel; difficulte++) {
tr.append($("<th class='table-resolution-level'/>").text(Misc.toSignedString(difficulte)));
}
return tr;
}
/* -------------------------------------------- */
static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) {
let tr = $("<tr/>");
let max = maxLevel;
if (minLevel > -8) {
let score = dataRow[-8 + 10].score;
tr.append($("<td class='table-resolution-carac'/>").text(score))
}
if (minLevel > -7) {
tr.append($("<td/>"))
}
for (let difficulte = minLevel; difficulte <= max; difficulte++) {
let td = $("<td/>");
let score = dataRow[difficulte + 10].score;
if (rowIndex == caracValue && levelValue == difficulte) {
td.addClass('table-resolution-target');
} else if (difficulte == -8) {
td.addClass('table-resolution-carac');
}
tr.append(td.text(score));
}
return tr;
} }
} }

View File

@ -1,4 +1,5 @@
import { ENTITE_BLURETTE, ENTITE_INCARNE} from "./constants.js"; import { ENTITE_BLURETTE, ENTITE_INCARNE } from "./constants.js";
import { RdDUtility } from "./rdd-utility.js";
/** /**
* Extend the base Dialog entity by defining a custom window to perform roll. * Extend the base Dialog entity by defining a custom window to perform roll.
@ -6,32 +7,37 @@ import { ENTITE_BLURETTE, ENTITE_INCARNE} from "./constants.js";
*/ */
export class RdDEncaisser extends Dialog { export class RdDEncaisser extends Dialog {
static async encaisser(actor) {
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html',
{ ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }
);
new RdDEncaisser(html, actor).render(true);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(html, actor) { constructor(html, actor) {
// Common conf let dialogConf = {
let buttons = {}; title: "Jet d'Encaissement",
if (!actor.isEntite()){ content: html,
buttons = { }
if (!actor.isEntite()) {
dialogConf.default = "mortel";
dialogConf.buttons = {
"mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") }, "mortel": { label: "Mortel", callback: html => this.performEncaisser("mortel") },
"non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") }, "non-mortel": { label: "Non-mortel", callback: html => this.performEncaisser("non-mortel") },
"sonne": { label: "Sonné", callback: html => this.actor.setSonne() }, "sonne": { label: "Sonné", callback: html => this.actor.setSonne() },
}; };
} }
else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])){ else if (actor.isEntite([ENTITE_BLURETTE, ENTITE_INCARNE])) {
buttons = { dialogConf.default = "cauchemar"
"cauchemar": { label: "cauchemar", callback: html => this.performEncaisser("cauchemar") } dialogConf.buttons = {
"cauchemar": { label: "Cauchemar", callback: html => this.performEncaisser("cauchemar") }
} }
} }
let dialogConf = {
title: "Jet d'Encaissement",
content: html,
buttons: buttons,
default: "mortel"
}
let dialogOptions = { let dialogOptions = {
classes: ["rdddialog"], classes: ["rdd-roll-dialog"],
width: 320, width: 320,
height: 'fit-content' height: 'fit-content'
} }
@ -44,7 +50,18 @@ export class RdDEncaisser extends Dialog {
this.encaisserSpecial = "aucun"; this.encaisserSpecial = "aucun";
} }
activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.html.find('[name="modificateurDegats"]').val("0");
this.html.find('[name="modificateurDegats"]').change((event) => {
this.modifier = event.currentTarget.value; // Update the selected bonus/malus
});
this.html.find('[name="encaisserSpecial"]').change((event) => {
this.encaisserSpecial = event.currentTarget.value; // Update the selected bonus/malus
});
}
/* -------------------------------------------- */ /* -------------------------------------------- */
performEncaisser(mortalite) { performEncaisser(mortalite) {
@ -58,22 +75,4 @@ export class RdDEncaisser extends Dialog {
} }
}); });
} }
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
// Setup everything onload
$(function () {
$("#modificateurDegats").val("0");
});
html.find('#modificateurDegats').change((event) => {
this.modifier = event.currentTarget.value; // Update the selected bonus/malus
});
html.find('#encaisserSpecial').change((event) => {
this.encaisserSpecial = event.currentTarget.value; // Update the selected bonus/malus
});
}
} }

View File

@ -13,47 +13,33 @@ export class RdDRollDialogEthylisme extends Dialog {
title: "Test d'éthylisme", title: "Test d'éthylisme",
content: html, content: html,
default: "rollButton", default: "rollButton",
buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => this.onButton(html) } } buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => onRoll(this.rollData) } }
}; };
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 'fit-content', 'z-index': 99999 } let dialogOptions = { classes: ["rdd-roll-dialog"], width: 400, height: 'fit-content', 'z-index': 99999 }
super(dialogConf, dialogOptions) super(dialogConf, dialogOptions)
//console.log("ETH", rollData);
this.onRoll = onRoll;
this.rollData = rollData; this.rollData = rollData;
this.actor = actor; this.actor = actor;
} }
async onButton(html) { activateListeners(html) {
this.onRoll(this.rollData); super.activateListeners(html);
this.html = html;
this.bringToTop();
this.html.find(".force-alcool").change((event) => {
this.rollData.forceAlcool = Misc.toInt(event.currentTarget.value);
this.updateRollResult();
});
this.html.find(".force-alcool").val(Misc.toInt(this.rollData.forceAlcool));
this.updateRollResult();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
this.bringToTop(); // Ensure top level
// Get the rollData stuff
var rollData = this.rollData;
var dialog = this;
// Setup everything onload
$(function () {
$("#forceAlcool").val(Misc.toInt(rollData.forceAlcool));
dialog.updateRollResult();
});
// Update !
html.find('#forceAlcool').change((event) => {
rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
dialog.updateRollResult();
});
}
async updateRollResult() { async updateRollResult() {
this.html.find(".roll-ethylisme").text(this.rollData.vie + " / " + Misc.toSignedString(Number(this.rollData.etat) + Number(this.rollData.forceAlcool) + this.rollData.diffNbDoses));
// Mise à jour valeurs this.html.find(".table-resolution").remove();
$("#roll-param").text(this.rollData.vie + " / " + Misc.toSignedString(Number(this.rollData.etat) + Number(this.rollData.forceAlcool) + this.rollData.diffNbDoses));
$(".table-resolution").remove();
} }
} }

View File

@ -9,12 +9,19 @@ const titleTableDeResolution = 'Table de résolution';
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDRollResolutionTable extends Dialog { export class RdDRollResolutionTable extends Dialog {
static resolutionTable = undefined;
/* -------------------------------------------- */ /* -------------------------------------------- */
static async open(rollData = {}) { static async open() {
RdDRollResolutionTable._setDefaultOptions(rollData); if (RdDRollResolutionTable.resolutionTable == undefined) {
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', rollData); const rollData = {}
const dialog = new RdDRollResolutionTable(rollData, html); RdDRollResolutionTable._setDefaultOptions(rollData);
dialog.render(true); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', rollData);
RdDRollResolutionTable.resolutionTable = new RdDRollResolutionTable(rollData, html);
RdDRollResolutionTable.resolutionTable.render(true);
}
else{
RdDRollResolutionTable.resolutionTable.bringToTop();
}
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -53,11 +60,40 @@ export class RdDRollResolutionTable extends Dialog {
'lancer-fermer': { label: 'Lancer les dés et fermer', callback: html => this.onLancerFermer() } 'lancer-fermer': { label: 'Lancer les dés et fermer', callback: html => this.onLancerFermer() }
} }
}; };
super(conf, { classes: ["rdddialog"], width: 800, height: 'fit-content', 'z-index': 99999 }); super(conf, { classes: ["rdd-roll-dialog"], top: 50, width: 'fit-content', height: 'fit-content', 'z-index': 99999 });
this.rollData = rollData; this.rollData = rollData;
} }
activateListeners(html) {
super.activateListeners(html);
this.html = html;
this.bringToTop();
this.html.find("[name='diffLibre']").val(Misc.toInt(this.rollData.diffLibre));
this.html.find("[name='diffConditions']").val(Misc.toInt(this.rollData.diffConditions));
this.updateRollResult();
this.html.find('.lancer-table-resolution').click((event) => {
this.onLancer();
});
// Update !
this.html.find("[name='diffLibre']").change((event) => {
this.rollData.diffLibre = Misc.toInt(event.currentTarget.value);
this.updateRollResult();
});
this.html.find("[name='diffConditions']").change((event) => {
this.rollData.diffConditions = Misc.toInt(event.currentTarget.value);
this.updateRollResult();
});
this.html.find("[name='carac']").change((event) => {
let caracKey = event.currentTarget.value;
this.rollData.selectedCarac = this.rollData.carac[caracKey];
this.updateRollResult();
});
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async onLancer() { async onLancer() {
await RdDResolutionTable.rollData(this.rollData); await RdDResolutionTable.rollData(this.rollData);
@ -72,65 +108,37 @@ export class RdDRollResolutionTable extends Dialog {
await RdDResolutionTable.displayRollData(this.rollData); await RdDResolutionTable.displayRollData(this.rollData);
} }
/* -------------------------------------------- */
activateListeners(html) {
super.activateListeners(html);
this.bringToTop();
var dialog = this;
// Setup everything onload
function onLoad(){
$("#diffLibre").val(Misc.toInt(dialog.rollData.diffLibre));
$("#diffConditions").val(Misc.toInt(dialog.rollData.diffConditions));
dialog.updateRollResult();
}
$(function () { onLoad();});
html.find('#lancer').click((event) => {
this.onLancer();
});
// Update !
html.find('#diffLibre').change((event) => {
this.rollData.diffLibre = Misc.toInt(event.currentTarget.value);
this.updateRollResult();
});
html.find('#diffConditions').change((event) => {
this.rollData.diffConditions = Misc.toInt(event.currentTarget.value);
this.updateRollResult();
});
html.find('#carac').change((event) => {
let caracKey = event.currentTarget.value;
this.rollData.selectedCarac = this.rollData.carac[caracKey];
this.updateRollResult();
});
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async updateRollResult() { async updateRollResult() {
let rollData = this.rollData; let rollData = this.rollData;
rollData.caracValue = parseInt(rollData.selectedCarac.value) rollData.caracValue = parseInt(rollData.selectedCarac.value)
rollData.finalLevel = this._computeFinalLevel(rollData); rollData.finalLevel = this._computeFinalLevel(rollData);
const htmlTable = await RdDResolutionTable.buildHTMLTable({
carac:rollData.caracValue,
level: rollData.finalLevel
});
// Mise à jour valeurs // Mise à jour valeurs
$("#carac").val(rollData.caracValue); this.html.find("[name='carac']").val(rollData.caracValue);
$("#roll-param").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel)); this.html.find(".roll-param-resolution").text(rollData.selectedCarac.value + " / " + Misc.toSignedString(rollData.finalLevel));
$(".table-resolution").remove(); this.html.find(".table-resolution").remove();
$(".table-proba-reussite").remove(); this.html.find(".table-proba-reussite").remove();
$("#tableResolution").append(RdDResolutionTable.buildHTMLTable(rollData.caracValue, rollData.finalLevel));
$("#tableProbaReussite").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel)); this.html.find("div.placeholder-resolution").append(htmlTable)
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_computeFinalLevel(rollData) { _computeFinalLevel(rollData) {
const diffConditions = Misc.toInt(rollData.diffConditions); const diffConditions = Misc.toInt(rollData.diffConditions);
const diffLibre = this._computeDiffLibre(rollData); const diffLibre = Misc.toInt(rollData.diffLibre);
return diffLibre + diffConditions; return diffLibre + diffConditions;
} }
/* -------------------------------------------- */ async close() {
_computeDiffLibre(rollData) { await super.close();
return Misc.toInt(rollData.diffLibre); RdDRollResolutionTable.resolutionTable = undefined;
} }
} }

View File

@ -16,24 +16,17 @@ import { ReglesOptionelles } from "./settings/regles-optionelles.js";
export class RdDRoll extends Dialog { export class RdDRoll extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, rollData, dialogConfig, ...actions) { static async create(actor, rollData, dialogConfig, action) {
RdDRoll._ensureCorrectAction(action);
if (actor.isRollWindowsOpened()) {
ui.notifications.warn("Vous avez déja une fenêtre de Test ouverte, il faut la fermer avant d'en ouvrir une autre.")
return;
}
actor.setRollWindowsOpened(true);
RdDRoll._ensureCorrectActions(actions);
RdDRoll._setDefaultOptions(actor, rollData); RdDRoll._setDefaultOptions(actor, rollData);
const html = await renderTemplate(dialogConfig.html, rollData); const html = await renderTemplate(dialogConfig.html, rollData);
let options = { classes: ["rdddialog"], width: 600, height: 'fit-content', 'z-index': 99999 }; let options = { classes: ["rdd-roll-dialog"], width: 600, height: 'fit-content', 'z-index': 99999, close: html => {} };
if (dialogConfig.options) { if (dialogConfig.close) {
mergeObject(options, dialogConfig.options, { overwrite: true }) options.close = dialogConfig.close;
} }
return new RdDRoll(actor, rollData, html, options, actions, dialogConfig.close); return new RdDRoll(actor, rollData, html, options, action);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -67,7 +60,7 @@ export class RdDRoll extends Dialog {
forceDiceResult: -1 forceDiceResult: -1
} }
// Mini patch :Ajout du rêve actuel // Mini patch :Ajout du rêve actuel
if ( actor.system.type == "personnage") { if (actor.system.type == "personnage") {
defaultRollData.carac["reve-actuel"] = actor.system.reve.reve defaultRollData.carac["reve-actuel"] = actor.system.reve.reve
} }
@ -79,6 +72,7 @@ export class RdDRoll extends Dialog {
RollDataAjustements.calcul(rollData, actor); RollDataAjustements.calcul(rollData, actor);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getDiviseurSignificative(rollData) { static getDiviseurSignificative(rollData) {
let facteurSign = 1; let facteurSign = 1;
@ -97,171 +91,132 @@ export class RdDRoll extends Dialog {
return facteurSign; return facteurSign;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _ensureCorrectActions(actions) { static _ensureCorrectAction(action) {
if (actions.length == 0) { if (action.callbacks == undefined) {
throw 'No action defined'; console.warn('No callback defined for ', action.name);
action.callbacks = [{ action: r => console.warn(action.name, r) }];
} }
actions.forEach(action => {
if (action.callbacks == undefined) {
action.callbacks = [{ action: r => console.log(action.name, r) }];
}
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
constructor(actor, rollData, html, options, actions, close = undefined) { constructor(actor, rollData, html, options, action) {
let conf = { let conf = {
title: actions[0].label, title: action.label,
content: html, content: html,
buttons: {}, buttons: {
default: actions[0].name, "onAction": {
close: close label: action.label, callback: html => {
}; this.rollData.canClose = true;
for (let action of actions) { this.onAction(action)
conf.buttons[action.name] = { }
label: action.label, callback: html => {
this.rollData.canClose = true;
this.onAction(action, html)
} }
}; },
} default: "onAction",
close: options.close
};
super(conf, options); super(conf, options);
this.actor = actor; this.actor = actor;
this.rollData = rollData; this.rollData = rollData;
} }
close() {
if (this.rollData.canClose) {
this.actor.setRollWindowsOpened(false);
return super.close();
}
ui.notifications.info("Vous devez faire ce jet de dés!");
}
/* -------------------------------------------- */
async onAction(action, html) {
this.rollData.forceDiceResult = Number.parseInt($('#force-dice-result').val()) ?? -1;
await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
this.actor.setRollWindowsOpened(false);
if (action.callbacks)
for (let callback of action.callbacks) {
if (callback.condition == undefined || callback.condition(this.rollData)) {
await callback.action(this.rollData);
}
}
}
/* -------------------------------------------- */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
this.bringToTop(); this.bringToTop();
var dialog = this; console.log('RdDRoll.activateListeners', this.rollData);
function onLoad() { // Update html, according to rollData
let rollData = dialog.rollData; if (this.rollData.competence) {
console.log('Ouverture RdDRoll', rollData); const defaut_carac = this.rollData.competence.system.defaut_carac
// Update html, according to rollData // Set the default carac from the competence item
if (rollData.competence) { this.rollData.selectedCarac = this.rollData.carac[defaut_carac];
const defaut_carac = rollData.competence.system.defaut_carac this.html.find("[name='carac']").val(defaut_carac);
// Set the default carac from the competence item
rollData.selectedCarac = rollData.carac[defaut_carac];
$("#carac").val(defaut_carac);
}
if (rollData.selectedSort) {
dialog.setSelectedSort(rollData.selectedSort);
$(".draconic").val(rollData.selectedSort.system.listIndex); // Uniquement a la selection du sort, pour permettre de changer
}
RdDItemSort.setCoutReveReel(rollData.selectedSort);
$("#diffLibre").val(Misc.toInt(rollData.diffLibre));
$("#diffConditions").val(Misc.toInt(rollData.diffConditions));
dialog.updateRollResult();
} }
if (this.rollData.selectedSort) {
this.setSelectedSort(this.rollData.selectedSort);
this.html.find(".draconic").val(this.rollData.selectedSort.system.listIndex); // Uniquement a la selection du sort, pour permettre de changer
}
RdDItemSort.setCoutReveReel(this.rollData.selectedSort);
this.html.find("[name='diffLibre']").val(Misc.toInt(this.rollData.diffLibre));
this.html.find("[name='diffConditions']").val(Misc.toInt(this.rollData.diffConditions));
this.updateRollResult(html);
// Setup everything onload this.html.find("[name='diffLibre']").change((event) => {
$(function () { onLoad(); });
// Update !
html.find('#diffLibre').change((event) => {
this.rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus this.rollData.diffLibre = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('#diffConditions').change((event) => { this.html.find("[name='diffConditions']").change((event) => {
this.rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus this.rollData.diffConditions = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('#force-dice-result').change((event) => { this.html.find("[name='force-dice-result']").change((event) => {
this.rollData.forceDiceResult = Misc.toInt(event.currentTarget.value); this.rollData.forceDiceResult = Misc.toInt(event.currentTarget.value);
}); });
html.find('#carac').change((event) => { this.html.find("[name='carac']").change((event) => {
let caracKey = event.currentTarget.value; let caracKey = event.currentTarget.value;
this.rollData.selectedCarac = this.rollData.carac[caracKey]; // Update the selectedCarac this.rollData.selectedCarac = this.rollData.carac[caracKey]; // Update the selectedCarac
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.roll-draconic').change((event) => { this.html.find('.roll-draconic').change((event) => {
let draconicKey = Misc.toInt(event.currentTarget.value); let draconicKey = Misc.toInt(event.currentTarget.value);
this.rollData.competence = this.rollData.draconicList[draconicKey]; // Update the selectedCarac this.rollData.competence = this.rollData.draconicList[draconicKey]; // Update the selectedCarac
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.roll-sort').change((event) => { this.html.find('.roll-sort').change((event) => {
let sortKey = Misc.toInt(event.currentTarget.value); let sortKey = Misc.toInt(event.currentTarget.value);
this.setSelectedSort(this.rollData.sortList[sortKey]); this.setSelectedSort(this.rollData.sortList[sortKey]);
this.updateRollResult(); this.updateRollResult(html);
$("#diffLibre").val(this.rollData.diffLibre); this.html.find("[name='diffLibre']").val(this.rollData.diffLibre);
}); });
html.find('.roll-carac-competence').change((event) => { this.html.find('.roll-carac-competence').change((event) => {
const competence = event.currentTarget.value; const competence = event.currentTarget.value;
this.rollData.competence = this.rollData.competences.find(it => it.name == competence); this.rollData.competence = this.rollData.competences.find(it => it.name == competence);
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.roll-signedraconique').change((event) => { this.html.find('.roll-signedraconique').change((event) => {
let sortKey = Misc.toInt(event.currentTarget.value); let sortKey = Misc.toInt(event.currentTarget.value);
this.setSelectedSigneDraconique(this.rollData.signes[sortKey]); this.setSelectedSigneDraconique(this.rollData.signes[sortKey]);
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('#ptreve-variable').change((event) => { this.html.find("[name='ptreve-variable']").change((event) => {
let ptreve = Misc.toInt(event.currentTarget.value); let ptreve = Misc.toInt(event.currentTarget.value);
this.rollData.selectedSort.system.ptreve_reel = ptreve; this.rollData.selectedSort.system.ptreve_reel = ptreve;
console.log("RdDRollSelectDialog - Cout reve", ptreve); console.log("RdDRollSelectDialog - Cout reve", ptreve);
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find("[name='coupsNonMortels']").change((event) => { this.html.find("[name='coupsNonMortels']").change((event) => {
this.rollData.dmg.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel"; this.rollData.dmg.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel";
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.cuisine-proportions').change((event) => { this.html.find('.cuisine-proportions').change((event) => {
this.rollData.proportions = Number(event.currentTarget.value); this.rollData.proportions = Number(event.currentTarget.value);
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.select-by-name').change((event) => { this.html.find('.select-by-name').change((event) => {
const attribute = event.currentTarget.attributes['name'].value; const attribute = event.currentTarget.attributes['name'].value;
this.rollData[attribute] = event.currentTarget.value; this.rollData[attribute] = event.currentTarget.value;
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.checkbox-by-name').change((event) => { this.html.find('.checkbox-by-name').change((event) => {
const attribute = event.currentTarget.attributes['name'].value; const attribute = event.currentTarget.attributes['name'].value;
this.rollData[attribute] = event.currentTarget.checked; this.rollData[attribute] = event.currentTarget.checked;
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('input.use-encTotal').change((event) => { this.html.find('input.use-encTotal').change((event) => {
this.rollData.use.encTotal = event.currentTarget.checked; this.rollData.use.encTotal = event.currentTarget.checked;
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('input.use-surenc').change((event) => { this.html.find('input.use-surenc').change((event) => {
this.rollData.use.surenc = event.currentTarget.checked; this.rollData.use.surenc = event.currentTarget.checked;
this.updateRollResult(); this.updateRollResult(html);
}); });
html.find('.appel-moral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ this.html.find('.appel-moral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */
this.rollData.use.moral = !this.rollData.use.moral; this.rollData.use.moral = !this.rollData.use.moral;
const appelMoral = html.find('.icon-appel-moral')[0]; const appelMoral = this.html.find('.icon-appel-moral')[0];
const tooltip = html.find('.tooltipAppelAuMoralText')[0]; const tooltip = this.html.find('.tooltipAppelAuMoralText')[0];
if (this.rollData.use.moral) { if (this.rollData.use.moral) {
if (this.rollData.moral > 0) { if (this.rollData.moral > 0) {
tooltip.innerHTML = "Appel au moral"; tooltip.innerHTML = "Appel au moral";
@ -274,16 +229,36 @@ export class RdDRoll extends Dialog {
tooltip.innerHTML = "Sans appel au moral"; tooltip.innerHTML = "Sans appel au moral";
appelMoral.src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg"; appelMoral.src = "/systems/foundryvtt-reve-de-dragon/icons/moral-neutre.svg";
} }
this.updateRollResult(); this.updateRollResult(html);
}); });
// Section Méditation // Section Méditation
html.find('.conditionMeditation').change((event) => { this.html.find('.conditionMeditation').change((event) => {
let condition = event.currentTarget.attributes['id'].value; let condition = event.currentTarget.attributes['name'].value;
this.rollData.conditionMeditation[condition] = event.currentTarget.checked; this.rollData.conditionMeditation[condition] = event.currentTarget.checked;
this.updateRollResult(); this.updateRollResult(html);
}); });
} }
/* -------------------------------------------- */
close() {
if (this.rollData.canClose) {
return super.close();
}
ui.notifications.info("Vous devez faire ce jet de dés!");
}
async onAction(action) {
this.rollData.forceDiceResult = Number.parseInt(this.html.find("[name='force-dice-result']").val()) ?? -1;
await RdDResolutionTable.rollData(this.rollData);
console.log("RdDRoll -=>", this.rollData, this.rollData.rolled);
if (action.callbacks)
for (let callback of action.callbacks) {
if (callback.condition == undefined || callback.condition(this.rollData)) {
await callback.action(this.rollData);
}
}
}
async setSelectedSort(sort) { async setSelectedSort(sort) {
this.rollData.selectedSort = sort; // Update the selectedCarac this.rollData.selectedSort = sort; // Update the selectedCarac
this.rollData.competence = RdDItemCompetence.getVoieDraconic(this.rollData.draconicList, sort.system.draconic); this.rollData.competence = RdDItemCompetence.getVoieDraconic(this.rollData.draconicList, sort.system.draconic);
@ -291,31 +266,31 @@ export class RdDRoll extends Dialog {
this.rollData.diffLibre = RdDItemSort.getDifficulte(sort, -7); this.rollData.diffLibre = RdDItemSort.getDifficulte(sort, -7);
RdDItemSort.setCoutReveReel(sort); RdDItemSort.setCoutReveReel(sort);
const htmlSortDescription = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html", { sort: sort }); const htmlSortDescription = await renderTemplate("systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html", { sort: sort });
$(".sort-ou-rituel").text(sort.system.isrituel ? "rituel" : "sort"); this.html.find(".sort-ou-rituel").text(sort.system.isrituel ? "rituel" : "sort");
$(".bonus-case").text(`${this.rollData.bonus}%`); this.html.find(".bonus-case").text(`${this.rollData.bonus}%`);
$(".details-sort").remove(); this.html.find(".placeholder-description-sort").children().remove();
$(".description-sort").append(htmlSortDescription); this.html.find(".placeholder-description-sort").append(htmlSortDescription);
$(".roll-draconic").val(sort.system.listIndex); this.html.find(".roll-draconic").val(sort.system.listIndex);
$(".div-sort-difficulte-fixe").text(Misc.toSignedString(sort.system.difficulte)); this.html.find(".div-sort-difficulte-fixe").text(Misc.toSignedString(sort.system.difficulte));
$(".div-sort-ptreve-fixe").text(sort.system.ptreve); this.html.find(".div-sort-ptreve-fixe").text(sort.system.ptreve);
const diffVariable = RdDItemSort.isDifficulteVariable(sort); const diffVariable = RdDItemSort.isDifficulteVariable(sort);
const coutVariable = RdDItemSort.isCoutVariable(sort); const coutVariable = RdDItemSort.isCoutVariable(sort);
HtmlUtility._showControlWhen($(".div-sort-non-rituel"), !sort.system.isrituel); HtmlUtility._showControlWhen(this.html.find(".div-sort-non-rituel"), !sort.system.isrituel);
HtmlUtility._showControlWhen($(".div-sort-difficulte-var"), diffVariable); HtmlUtility._showControlWhen(this.html.find(".div-sort-difficulte-var"), diffVariable);
HtmlUtility._showControlWhen($(".div-sort-difficulte-fixe"), !diffVariable); HtmlUtility._showControlWhen(this.html.find(".div-sort-difficulte-fixe"), !diffVariable);
HtmlUtility._showControlWhen($(".div-sort-ptreve-var"), coutVariable); HtmlUtility._showControlWhen(this.html.find(".div-sort-ptreve-var"), coutVariable);
HtmlUtility._showControlWhen($(".div-sort-ptreve-fixe"), !coutVariable); HtmlUtility._showControlWhen(this.html.find(".div-sort-ptreve-fixe"), !coutVariable);
} }
async setSelectedSigneDraconique(signe){ async setSelectedSigneDraconique(signe) {
this.rollData.signe = signe; this.rollData.signe = signe;
this.rollData.diffLibre = signe.system.difficulte, this.rollData.diffLibre = signe.system.difficulte,
$(".signe-difficulte").text(Misc.toSignedString(this.rollData.diffLibre)); $(".signe-difficulte").text(Misc.toSignedString(this.rollData.diffLibre));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async updateRollResult() { async updateRollResult(html) {
let rollData = this.rollData; let rollData = this.rollData;
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat()) rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat())
@ -325,39 +300,35 @@ export class RdDRoll extends Dialog {
rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac); rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac);
let dmgText = Misc.toSignedString(rollData.dmg.total); let dmgText = Misc.toSignedString(rollData.dmg.total);
switch (rollData.mortalite){ switch (rollData.mortalite) {
case 'non-mortel': dmgText = `(${dmgText}) non-mortel`; break; case 'non-mortel': dmgText = `(${dmgText}) non-mortel`; break;
case 'empoignade': dmgText = `empoignade`; break; case 'empoignade': dmgText = `empoignade`; break;
} }
RollDataAjustements.calcul(rollData, this.actor); RollDataAjustements.calcul(rollData, this.actor);
rollData.finalLevel = this._computeFinalLevel(rollData); rollData.finalLevel = this._computeFinalLevel(rollData);
HtmlUtility._showControlWhen($(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac)); const resolutionTable = await RdDResolutionTable.buildHTMLTable(RdDResolutionTable.subTable(rollData.caracValue, rollData.finalLevel))
HtmlUtility._showControlWhen($(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac)); const adjustements = await this.buildAjustements(rollData);
HtmlUtility._showControlWhen($(".utilisation-moral"), rollData.use.appelAuMoral);
HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); HtmlUtility._showControlWhen(this.html.find(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac));
HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral); HtmlUtility._showControlWhen(this.html.find(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac));
HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData)); HtmlUtility._showControlWhen(this.html.find(".utilisation-moral"), rollData.use.appelAuMoral);
HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); HtmlUtility._showControlWhen(this.html.find(".diffMoral"), rollData.ajustements.moralTotal.used);
HtmlUtility._showControlWhen(this.html.find(".divAppelAuMoral"), rollData.use.appelAuMoral);
// Mise à jour valeurs // Mise à jour valeurs
$(".dialog-roll-title").text(this._getTitle(rollData)); this.html.find(".dialog-roll-title").text(this._getTitle(rollData));
$("[name='coupsNonMortels']").prop('checked', rollData.mortalite == 'non-mortel'); this.html.find("[name='coupsNonMortels']").prop('checked', rollData.mortalite == 'non-mortel');
$(".dmg-arme-actor").text(dmgText); this.html.find(".dmg-arme-actor").text(dmgText);
$('.table-ajustement').remove(); this.html.find("div.placeholder-ajustements").empty().append(adjustements);
$(".table-resolution").remove(); this.html.find("div.placeholder-resolution").empty().append(resolutionTable)
$(".table-proba-reussite").remove();
$("#tableAjustements").append(await this.buildAjustements(rollData));
$("#tableResolution").append(RdDResolutionTable.buildHTMLTableExtract(rollData.caracValue, rollData.finalLevel));
$("#tableProbaReussite").append(RdDResolutionTable.buildHTMLResults(rollData.caracValue, rollData.finalLevel));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async buildAjustements(rollData) { async buildAjustements(rollData) {
const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html`, rollData); return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html`, rollData);
return html;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -375,23 +346,11 @@ export class RdDRoll extends Dialog {
return 0; return 0;
} }
/* -------------------------------------------- */
_computeDiffLibre(rollData) {
let diffLibre = Misc.toInt(rollData.diffLibre);
if (rollData.draconicList && rollData.selectedSort) {
return RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre);
}
return diffLibre;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_computeMalusArmure(rollData) { _computeMalusArmure(rollData) {
let malusArmureValue = 0; let malusArmureValue = 0;
if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) { if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) {
$("#addon-message").text("Malus armure appliqué : " + rollData.malusArmureValue);
malusArmureValue = rollData.malusArmureValue; malusArmureValue = rollData.malusArmureValue;
} else {
$("#addon-message").text("");
} }
return malusArmureValue; return malusArmureValue;
} }

View File

@ -5,7 +5,6 @@ import { TMRUtility } from "./tmr-utility.js";
import { tmrConstants } from "./tmr-constants.js"; import { tmrConstants } from "./tmr-constants.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js"; import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
import { TMRRencontres } from "./tmr-rencontres.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDRoll } from "./rdd-roll.js"; import { RdDRoll } from "./rdd-roll.js";
import { Poetique } from "./poetique.js"; import { Poetique } from "./poetique.js";
@ -198,32 +197,33 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async activateListeners(html) { async activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
this.html = html;
document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view); document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view);
if (this.viewOnly) { if (this.viewOnly) {
html.find('.lancer-sort').remove(); this.html.find('.lancer-sort').remove();
html.find('.lire-signe-draconique').remove(); this.html.find('.lire-signe-draconique').remove();
return; return;
} }
HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue")); HtmlUtility._showControlWhen(this.html.find(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
HtmlUtility._showControlWhen($(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord())); HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(this._getActorCoord()));
// Roll Sort // Roll Sort
html.find('.lancer-sort').click((event) => { this.html.find('.lancer-sort').click((event) => {
this.actor.rollUnSort(this._getActorCoord()); this.actor.rollUnSort(this._getActorCoord());
}); });
html.find('.lire-signe-draconique').click((event) => { this.html.find('.lire-signe-draconique').click((event) => {
this.actor.rollLireSigneDraconique(this._getActorCoord()); this.actor.rollLireSigneDraconique(this._getActorCoord());
}); });
html.find('#dir-top').click((event) => this.moveFromKey("top")); this.html.find('#dir-top').click((event) => this.moveFromKey("top"));
html.find('#dir-top-left').click((event) => this.moveFromKey("top-left")); this.html.find('#dir-top-left').click((event) => this.moveFromKey("top-left"));
html.find('#dir-top-right').click((event) => this.moveFromKey("top-right")); this.html.find('#dir-top-right').click((event) => this.moveFromKey("top-right"));
html.find('#dir-bottom-left').click((event) => this.moveFromKey("bottom-left")); this.html.find('#dir-bottom-left').click((event) => this.moveFromKey("bottom-left"));
html.find('#dir-bottom-right').click((event) => this.moveFromKey("bottom-right")); this.html.find('#dir-bottom-right').click((event) => this.moveFromKey("bottom-right"));
html.find('#dir-bottom').click((event) => this.moveFromKey("bottom")); this.html.find('#dir-bottom').click((event) => this.moveFromKey("bottom"));
// Gestion du cout de montée en points de rêve // Gestion du cout de montée en points de rêve
let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1) - this.actor.countMonteeLaborieuse(); let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1) - this.actor.countMonteeLaborieuse();
@ -245,7 +245,7 @@ export class RdDTMRDialog extends Dialog {
} }
const coord = this._getActorCoord(); const coord = this._getActorCoord();
HtmlUtility._showControlWhen($(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord)); HtmlUtility._showControlWhen(this.html.find(".lire-signe-draconique"), this.actor.isResonanceSigneDraconique(coord));
let ptsreve = document.getElementById("tmr-pointsreve-value"); let ptsreve = document.getElementById("tmr-pointsreve-value");
ptsreve.innerHTML = this.actor.system.reve.reve.value; ptsreve.innerHTML = this.actor.system.reve.reve.value;
@ -280,7 +280,7 @@ export class RdDTMRDialog extends Dialog {
} }
await this.actor.santeIncDec("fatigue", this.cumulFatigue) await this.actor.santeIncDec("fatigue", this.cumulFatigue)
} }
await super.close(); // moving 1 cell costs 1 fatigue await super.close();
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -15,6 +15,7 @@ import { RdDConfirm } from "./rdd-confirm.js";
import { RdDCalendrier } from "./rdd-calendrier.js"; import { RdDCalendrier } from "./rdd-calendrier.js";
import { Environnement } from "./environnement.js"; import { Environnement } from "./environnement.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
// This table starts at 0 -> niveau -10 // This table starts at 0 -> niveau -10
@ -237,6 +238,8 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/partial-item-hautrevant.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-item-hautrevant.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-item-frequence.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-item-frequence.html',
'systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html',
'systems/foundryvtt-reve-de-dragon/templates/roll/explain.hbs',
'systems/foundryvtt-reve-de-dragon/templates/resolution-table.html',
// Dialogs // Dialogs
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html',
'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html',
@ -282,6 +285,8 @@ export class RdDUtility {
]; ];
Handlebars.registerHelper('either', (a, b) => a ?? b); Handlebars.registerHelper('either', (a, b) => a ?? b);
Handlebars.registerHelper('computeResolutionScore', (row, col) => RdDResolutionTable.computePercentage(row, col));
Handlebars.registerHelper('computeResolutionChances', (row, col) => RdDResolutionTable.computeChances(row, col));
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null')); Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null')); Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null'));
Handlebars.registerHelper('upper', str => str?.toUpperCase() ?? 'NULL'); Handlebars.registerHelper('upper', str => str?.toUpperCase() ?? 'NULL');

View File

@ -1,6 +1,7 @@
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { RdDUtility } from "./rdd-utility.js";
import { SystemCompendiums, CompendiumTable, CompendiumTableHelpers } from "./settings/system-compendiums.js"; import { SystemCompendiums, CompendiumTable, CompendiumTableHelpers } from "./settings/system-compendiums.js";
import { TMRUtility } from "./tmr-utility.js"; import { TMRUtility } from "./tmr-utility.js";
@ -100,19 +101,21 @@ export class TMRRencontres {
const row = await this.table.getRandom(frequence, filtreMauvaise); const row = await this.table.getRandom(frequence, filtreMauvaise);
if (row) { if (row) {
row.document = this.createRencontre(row.document, tmr); const rencontre = await this.createRencontre(row.document, tmr);
await this.$chatRolledRencontre(row, tmr); await this.$chatRolledRencontre(row, rencontre, tmr);
return rencontre;
} }
return row?.document; return undefined;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async $chatRolledRencontre(row, tmr) { async $chatRolledRencontre(row, rencontre,tmr) {
const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.html', const flavorContent = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-compendium-table-roll-rencontre.html',
{ {
roll: row.roll, roll: row.roll,
rencontre: row?.document, rencontre,
row,
percentages: (row.total == 100) ? '%' : '', percentages: (row.total == 100) ? '%' : '',
tmr, tmr,
isGM: game.user.isGM, isGM: game.user.isGM,

View File

@ -618,13 +618,10 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
opacity: 0.7 ; opacity: 0.7 ;
} }
.rdddialog .dialog-roll-sort { .rdd-roll-dialog .description-sort {
width: 600px; max-width: 550px;
height: 430px;
z-index: 9999;
display: block;
} }
.rdd-roll-part{ .rdd-roll-part {
align-items: center; align-items: center;
border-radius: 6px; padding: 3px; border-radius: 6px; padding: 3px;
background: var(--gradient-gold); background: var(--gradient-gold);
@ -659,6 +656,10 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
text-align: right; text-align: right;
} }
.placeholder-ajustements {
flex-direction: column;
}
.table-resolution-carac { .table-resolution-carac {
background-color: yellow; background-color: yellow;
} }
@ -668,7 +669,7 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
background-color: lightblue; background-color: lightblue;
} }
#tableProbaReussite{ div.placeholder-resolution span.table-proba-reussite{
font-size: 0.8rem; font-size: 0.8rem;
padding: 5px; padding: 5px;
} }

View File

@ -1,2 +1,2 @@
<h3>Astrologie</h3> <h3>Astrologie</h3>
<span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span> <span class="astrologie-label"><a name="jet-astrologie">Astrologie : Nombres Astraux</a></span>

View File

@ -23,7 +23,7 @@
<span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span> <span class="tooltiptext ttt-fatigue">{{{calc.fatigue.html}}}</span>
Fatigue Fatigue
<a class="fatigue-moins"><i class="fas fa-minus-square"></i></a> <a class="fatigue-moins"><i class="fas fa-minus-square"></i></a>
<input class="resource-content" id="fatigue-value" type="text" name="system.sante.fatigue.value" value="{{system.sante.fatigue.value}}" data-dtype="Number" /> <input class="resource-content" type="text" name="system.sante.fatigue.value" value="{{system.sante.fatigue.value}}" data-dtype="Number" />
<span>/ {{system.sante.fatigue.max}}</span> <span>/ {{system.sante.fatigue.max}}</span>
<a class="fatigue-plus"><i class="fas fa-plus-square"></i></a> <a class="fatigue-plus"><i class="fas fa-plus-square"></i></a>
</label> </label>
@ -32,7 +32,7 @@
<label class="compteur"> <label class="compteur">
<span class="ptreve-actuel"><a>Rêve</a></span> <span class="ptreve-actuel"><a>Rêve</a></span>
<a class="ptreve-actuel-moins"><i class="fas fa-minus-square"></i></a> <a class="ptreve-actuel-moins"><i class="fas fa-minus-square"></i></a>
<input class="resource-content" id="pointsreve-value" type="text" name="system.reve.reve.value" value="{{system.reve.reve.value}}" data-dtype="Number" /> <input class="resource-content" class="pointsreve-value" type="text" name="system.reve.reve.value" value="{{system.reve.reve.value}}" data-dtype="Number" />
<span>/ {{system.reve.seuil.value}}</span> <span>/ {{system.reve.seuil.value}}</span>
<a class="ptreve-actuel-plus"><i class="fas fa-plus-square"></i></a> <a class="ptreve-actuel-plus"><i class="fas fa-plus-square"></i></a>
</label> </label>

View File

@ -1,11 +1,11 @@
<img class="chat-icon" src="{{rencontre.img}}" alt="{{rencontre.name}}" /> <img class="chat-icon" src="{{rencontre.img}}" alt="{{rencontre.name}}" />
<h4>{{#if mauvaise}}Mauvaise rencontre{{else}}Rencontre{{/if}} en {{typeTmr-name tmr.type}}</h4> <h4>{{#if mauvaise}}Mauvaise rencontre{{else}}Rencontre{{/if}} en {{typeTmr-name tmr.type}}</h4>
<div>{{rencontre.pack}}</div> <div>{{row.document.pack}}</div>
<div>Jet: {{roll.formula}} : {{roll.total}}{{percentages}}</div> <div>Jet: {{row.roll.formula}} : {{row.roll.total}}{{percentages}}</div>
<hr> <hr>
<div> <div>
<p>{{rencontre.name}} {{rencontre.system.force}} ({{rencontre.system.formule}})</p> <p>{{rencontre.name}} de force {{rencontre.system.force}} ({{rencontre.system.formule}})</p>
<p>{{linkCompendium rencontre.pack rencontre.id rencontre.name}}</p> <p>{{linkCompendium row.document.pack row.document.id row.document.name}}</p>
{{#if rencontre.system.description}} {{#if rencontre.system.description}}
<div class="poesie-extrait"> <div class="poesie-extrait">
{{{rencontre.system.description}}} {{{rencontre.system.description}}}

View File

@ -6,7 +6,7 @@
</header> </header>
<label>&nbsp;&nbsp;Conditions</label> <label>&nbsp;&nbsp;Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="Number"> <select name="diffConditions" data-dtype="Number">
{{#select diffConditions}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -14,7 +14,7 @@
{{/select}} {{/select}}
</select> </select>
<label>&nbsp;&nbsp;Jours</label> <label>&nbsp;&nbsp;Jours</label>
<select name="joursAstrologie" id="joursAstrologie" data-dtype="Number"> <select name="joursAstrologie" data-dtype="Number">
{{#select joursSuivants}} {{#select joursSuivants}}
{{#each dates as |date key|}} {{#each dates as |date key|}}
<option value={{date.index}}>{{date.label}}</option> <option value={{date.index}}>{{date.label}}</option>
@ -22,7 +22,7 @@
{{/select}} {{/select}}
</select> </select>
<label>Etat Général: {{etat}}</label> <label>Etat Général: {{etat}}</label>
<label>&nbsp;&nbsp;<a id='jet-astrologie'>Faire un jet d'Astrologie</a></label> <label>&nbsp;&nbsp;<a name="jet-astrologie">Faire un jet d'Astrologie</a></label>
{{!-- Sheet Body --}} {{!-- Sheet Body --}}
<section class="sheet-body"> <section class="sheet-body">

View File

@ -5,7 +5,7 @@
<div class="form-group"> <div class="form-group">
<label>Nombre de brins</label> <label>Nombre de brins</label>
<select name="nbBrins" id="nbBrins" data-dtype="number"> <select name="nbBrins" data-dtype="number">
{{#select nbBrins}} {{#select nbBrins}}
{{{nbBrinsSelect}}} {{{nbBrinsSelect}}}
{{/select}} {{/select}}

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<div> <div>
<div class="flexrow flex-center"> <div class="flexrow flex-center">
<div> <div>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" /> <img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" />
<h4>{{item.name}}</h4> <h4>{{item.name}}</h4>
<div class="flexrow"> <div class="flexrow">

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" /> <img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" />
<h4>{{item.name}}</h4> <h4>{{item.name}}</h4>
<label>Quantité totale : {{item.system.quantite}}</label> <label>Quantité totale : {{item.system.quantite}}</label>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" /> <img class="chat-icon" src="{{item.img}}" title="{{item.name}}" alt="{{item.name}}" />
<h4>{{item.name}}</h4> <h4>{{item.name}}</h4>
<div class="flexcol"> <div class="flexcol">

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Fabrication: {{recette.name}}</h2> <h2>Fabrication: {{recette.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
<div class="flex-group-left"> <div class="flex-group-left">
@ -20,12 +20,12 @@
{{/if}} {{/if}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution">
<div id="tableProbaReussite"></div> </div>
</form> </form>
<script> <script>

View File

@ -14,12 +14,10 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div class="placeholder-resolution"></div>
<div id="tableResolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Chanter: {{oeuvre.name}}</h2> <h2>Chanter: {{oeuvre.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -15,12 +15,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -41,7 +41,7 @@
{{/if}} {{/if}}
{{#if ajustements.attaqueDefenseurSurpris.used}} {{#if ajustements.attaqueDefenseurSurpris.used}}
<div class="flexrow"> <div class="flexrow">
<label id="defenseur-surprise">{{ajustements.attaqueDefenseurSurpris.label}}</label> <label>{{ajustements.attaqueDefenseurSurpris.label}}</label>
</div> </div>
{{/if}} {{/if}}
@ -75,12 +75,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -16,12 +16,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -16,12 +16,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,8 +1,7 @@
<form class="encaisse-roll-dialog"> <form class="encaisse-roll-dialog">
<h2 class="encaisserdialog" id="encaisserTitle"></h2>
<div class="flexrow"> <div class="flexrow">
<label>Modificateurs aux Dommages:</label> <label>Modificateurs aux Dommages:</label>
<select class="competence-value flex-shrink" name="modificateurDegats" id="modificateurDegats" data-dtype="number"> <select class="competence-value flex-shrink" name="modificateurDegats" data-dtype="number">
{{#select modificateurDegats}} {{#select modificateurDegats}}
{{#each ajustementsEncaissement as |key|}} {{#each ajustementsEncaissement as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -11,11 +10,14 @@
</select> </select>
</div> </div>
<div class="flexcol"> <div class="flexcol">
<label >Cas particuliers:</label> <label>Cas particuliers:</label>
<select name="encaisserSpecial" id="encaisserSpecial" data-dtype="String"> <select name="encaisserSpecial" data-dtype="String">
<option value="aucun">Aucun</option> <option value="aucun">Aucun</option>
<option value="noarmure">Ne pas compter les Armures</option> <option value="noarmure">Ne pas compter les Armures</option>
<option value="chute">Chute : Limiter les armures à 2 PA</option> <option value="chute">Chute : Limiter les armures à 2 PA</option>
</select> </select>
</div> </div>
<div class="flexcol">
<label>&nbsp;</label>
</div>
</form> </form>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Boire</h2> <h2>Boire</h2>
<img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/objets/chope_gres.webp" alt="Chope d'alcool"/> <img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/objets/chope_gres.webp" alt="Chope d'alcool"/>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -6,14 +6,14 @@
<label>Etat général</label><label class="flexrow">{{etat}}</label> <label>Etat général</label><label class="flexrow">{{etat}}</label>
<label>Déjà bu</label><label class="flexrow">{{diffNbDoses}}</label> <label>Déjà bu</label><label class="flexrow">{{diffNbDoses}}</label>
<label>Force du breuvage</label> <label>Force du breuvage</label>
<select name="forceAlcool" id="forceAlcool" data-dtype="number"> <select class="force-alcool" data-dtype="number">
{{#select forceAlcool}} {{#select forceAlcool}}
{{#each ajustementsForce as |key|}} {{#each ajustementsForce as |key|}}
<option value={{key}}>{{key}}</option> <option value={{key}}>{{key}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
<label>Ajustement final</label><label id="roll-param">10 / 0</label> <label>Ajustement final</label><label class="roll-ethylisme">10 / 0</label>
</div> </div>
</form> </form>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Jouer à : {{oeuvre.name}}</h2> <h2>Jouer à : {{oeuvre.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -16,13 +16,12 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" oeuvre.system}} {{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" oeuvre.system}}
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -17,12 +17,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -20,29 +20,28 @@
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label>Comportement antérieur : {{upperFirst meditation.system.comportement}}</label> <label>Comportement antérieur : {{upperFirst meditation.system.comportement}}</label>
<input class="attribute-value conditionMeditation" type="checkbox" id="isComportement" {{#if conditionMeditation.isComportement}}checked{{/if}} /> <input class="attribute-value conditionMeditation" type="checkbox" name="isComportement" {{#if conditionMeditation.isComportement}}checked{{/if}} />
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label>Heure : {{upperFirst meditation.system.heure}}</label> <label>Heure : {{upperFirst meditation.system.heure}}</label>
<input class="attribute-value conditionMeditation" type="checkbox" id="isHeure" {{#if conditionMeditation.isHeure}}checked{{/if}} /> <input class="attribute-value conditionMeditation" type="checkbox" name="isHeure" {{#if conditionMeditation.isHeure}}checked{{/if}} />
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label>Purification : {{upperFirst meditation.system.purification}}</label> <label>Purification : {{upperFirst meditation.system.purification}}</label>
<input class="attribute-value conditionMeditation" type="checkbox" id="isPurification" {{#if conditionMeditation.isPurification}}checked{{/if}} /> <input class="attribute-value conditionMeditation" type="checkbox" name="isPurification" {{#if conditionMeditation.isPurification}}checked{{/if}} />
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label>Vêture : {{upperFirst meditation.system.veture}}</label> <label>Vêture : {{upperFirst meditation.system.veture}}</label>
<input class="attribute-value conditionMeditation" type="checkbox" id="isVeture" {{#if conditionMeditation.isVeture}}checked{{/if}} /> <input class="attribute-value conditionMeditation" type="checkbox" name="isVeture" {{#if conditionMeditation.isVeture}}checked{{/if}} />
</div> </div>
<hr> <hr>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
<div id="tableAjustements"></div> <div class="placeholder-ajustements"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Interpréter la mélodie: {{oeuvre.name}}</h2> <h2>Interpréter la mélodie: {{oeuvre.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -15,12 +15,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Interpréter une Œuvre: {{oeuvre.name}}</h2> <h2>Interpréter une Œuvre: {{oeuvre.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -16,12 +16,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,4 +1,4 @@
<form class="rdddialog"> <form class="rdd-roll-dialog">
<h2>Cuisiner: {{oeuvre.name}}</h2> <h2>Cuisiner: {{oeuvre.name}}</h2>
<div class="grid grid-2col"> <div class="grid grid-2col">
@ -29,12 +29,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" oeuvre.system}} {{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" oeuvre.system}}
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -6,8 +6,7 @@
</div> </div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
<button id="lancer" type="button">Lancer les dés</button> <button class="lancer-table-resolution" type="button">Lancer les dés</button>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>

View File

@ -12,12 +12,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -33,12 +33,11 @@
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffFixe.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html"}}
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script> <script>

View File

@ -1,16 +1,18 @@
<form class="dialog-roll-sort"> <form class="dialog-roll-sort">
<h2 class="flexrow">Lancer le {{#if sort.system.isrituel}}rituel{{else}}sort{{/if}}: <img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}" />
<div>
<h2 class="flexrow">Lancer le {{#if sort.system.isrituel}}rituel{{else}}sort{{/if}}</h2>
<select name="sort" class="roll-sort" data-dtype="String"> <select name="sort" class="roll-sort" data-dtype="String">
{{#select sort}} {{#select sort}}
{{#each sortList as |sort key|}} {{#each sortList as |choix key|}}
<option value={{key}}>{{this.name}} - {{#if this.system.caseTMRspeciale}} {{this.system.caseTMRspeciale}} <option value={{key}}>{{choix.name}}
{{else}}{{this.system.caseTMR}}{{/if}} / R{{this.system.difficulte}} r {{sort.system.ptreve}} ({{sort.system.draconic}}) - {{#if choix.system.caseTMRspeciale}} {{choix.system.caseTMRspeciale}}
{{else}}{{choix.system.caseTMR}}{{/if}} / R{{choix.system.difficulte}} r {{choix.system.ptreve}} ({{choix.system.draconic}})
</option> </option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
</h2> </div>
<img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}" />
<div class="grid grid-2col"> <div class="grid grid-2col">
<div class="flex-group-left"> <div class="flex-group-left">
<div class="flexrow"> <div class="flexrow">
@ -21,7 +23,7 @@
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label for="ptreve-variable">Points de Rêve: </label> <label for="ptreve-variable">Points de Rêve: </label>
<select name="ptreve-variable" class="div-sort-ptreve-var" id="ptreve-variable" data-dtype="number"> <select name="ptreve-variable" class="div-sort-ptreve-var" data-dtype="number">
{{#select ptreve-variable}} {{#select ptreve-variable}}
{{#each coutreve as |cout key|}} {{#each coutreve as |cout key|}}
<option value={{cout}}>{{cout}}</option> <option value={{cout}}>{{cout}}</option>
@ -49,7 +51,7 @@
</div> </div>
<div class="flexrow"> <div class="flexrow">
<label for="diffLibre">Difficulté</label> <label for="diffLibre">Difficulté</label>
<select name="diffLibre" class="div-sort-difficulte-var" id="diffLibre" data-dtype="number"> <select name="diffLibre" class="div-sort-difficulte-var" data-dtype="number">
{{#select diffLibre}} {{#select diffLibre}}
{{#each difficultesLibres as |key|}} {{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -64,17 +66,11 @@
<label for="bonus-case">Bonus de case </label> <label for="bonus-case">Bonus de case </label>
<label name="bonus-case" class="bonus-case">0%</label> <label name="bonus-case" class="bonus-case">0%</label>
</div> </div>
<div id="tableAjustements" class="flexrow"></div> <div class="placeholder-ajustements" class="flexrow"></div>
</div> </div>
</div> </div>
<div class="description-sort"> <div class="placeholder-description-sort">
<hr>
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-sort.html" sort=selectedSort}}
</div> </div>
<div id="tableResolution"></div> <div class="placeholder-resolution"></div>
<div id="tableProbaReussite"></div>
</form> </form>
<script>
</script>

View File

@ -33,13 +33,13 @@
<div class="form-group"> <div class="form-group">
<label for="base">Niveau de base </label> <label for="base">Niveau de base </label>
{{#if isGM}} {{#if isGM}}
<select name="system.base" id="base" data-dtype="Number"> <select name="system.base" data-dtype="Number">
{{#select system.base}} {{#select system.base}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-base-competence.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-base-competence.html"}}
{{/select}} {{/select}}
</select> </select>
{{else}} {{else}}
<label id="base">{{system.base}}</label> <label name="system.base">{{system.base}}</label>
{{/if}} {{/if}}
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -85,14 +85,14 @@
<label>Date de l'Enchantement : Jour/Mois (date actuelle : {{dateActuelle}})</label> <label>Date de l'Enchantement : Jour/Mois (date actuelle : {{dateActuelle}})</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<select name="splitDate.day" class="enchanteDate" id="jourMois" data-dtype="String"> <select name="splitDate.day" class="enchanteDate" data-dtype="String">
{{#select splitDate.day}} {{#select splitDate.day}}
{{#each jourMoisOptions as |key|}} {{#each jourMoisOptions as |key|}}
<option value="{{key}}">{{numberFormat key decimals=0}}</option> <option value="{{key}}">{{numberFormat key decimals=0}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
<select name="splitDate.month" class="enchanteDate" id="nomMois" data-dtype="String"> <select name="splitDate.month" class="enchanteDate" data-dtype="String">
{{#select splitDate.month}} {{#select splitDate.month}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-heures.html"}}
{{/select}} {{/select}}

View File

@ -4,7 +4,7 @@
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<label for="xp">Caractéristique</label> <label for="xp">Caractéristique</label>
<select name="system.carac" id="caracselect" data-dtype="String"> <select name="system.carac" data-dtype="String">
{{#select system.carac}} {{#select system.carac}}
{{#each caracList as |carac key|}} {{#each caracList as |carac key|}}
<option value="{{key}}">{{carac.label}}</option> <option value="{{key}}">{{carac.label}}</option>
@ -14,7 +14,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="xp">Compétence</label> <label for="xp">Compétence</label>
<select name="system.competence" id="competenceselect" data-dtype="String"> <select name="system.competence" data-dtype="String">
{{#select system.competence}} {{#select system.competence}}
<option value="">Sans compétence</option> <option value="">Sans compétence</option>
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}}

View File

@ -5,6 +5,6 @@
{{#if sort.system.duree}}<label><strong>Durée</strong>: {{sort.system.duree}}&nbsp;&nbsp;</label>{{/if}} {{#if sort.system.duree}}<label><strong>Durée</strong>: {{sort.system.duree}}&nbsp;&nbsp;</label>{{/if}}
{{#if sort.system.coutseuil}}<label><strong>Coût de seuil</strong>: {{sort.system.coutseuil}}</label>{{/if}} {{#if sort.system.coutseuil}}<label><strong>Coût de seuil</strong>: {{sort.system.coutseuil}}</label>{{/if}}
</div> </div>
<div class="details-sort"> <div class="description-sort">
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" sort.system}} {{> "systems/foundryvtt-reve-de-dragon/templates/partial-description-overflow.html" sort.system}}
</div> </div>

View File

@ -1,7 +1,7 @@
<div class="table-ajustement"> <div class="table-ajustement">
<span class="tooltip tooltip-dotted"> <span class="tooltip tooltip-dotted">
<span>Ajustement Final:</span> <span>Ajustement Final:</span>
<span id="roll-param">{{selectedCarac.value}} / {{numberFormat finalLevel decimals=0 sign=true}}</span> <span class="roll-param-resolution">{{selectedCarac.value}} / {{numberFormat finalLevel decimals=0 sign=true}}</span>
<div class="tooltiptext ttt-ajustements"> <div class="tooltiptext ttt-ajustements">
{{#each ajustements as |item key|}} {{#each ajustements as |item key|}}
{{#if item.used}} {{#if item.used}}

View File

@ -1,6 +1,6 @@
<div class="flexrow"> <div class="flexrow">
<label for="diffConditions">Conditions</label> <label for="diffConditions">Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}> <select name="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>

View File

@ -1,6 +1,6 @@
<div class="flexrow"> <div class="flexrow">
<label for="diffLibre">Difficulté choisie</label> <label for="diffLibre">Difficulté choisie</label>
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}> <select name="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}>
{{#select diffLibre}} {{#select diffLibre}}
{{#each difficultesLibres as |key|}} {{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>

View File

@ -1,6 +1,6 @@
{{#if isGM}} {{#if isGM}}
<div class="flexrow"> <div class="flexrow">
<label for="force-dice-result">Résultat du dé</label> <label for="force-dice-result">Résultat du dé</label>
<input name='force-dice-result' id='force-dice-result' value='{{forceDiceResult}}'> <input name='force-dice-result' value='{{forceDiceResult}}'>
</div> </div>
{{/if}} {{/if}}

View File

@ -1,4 +1,4 @@
<select name="carac" id="carac" class="flex-grow select-carac" data-dtype="String"> <select name="carac" class="flex-grow" data-dtype="String">
{{#select carac}} {{#select carac}}
{{#each carac as |caracitem key|}} {{#each carac as |caracitem key|}}
<option value={{key}}>{{caracitem.label}}</option> <option value={{key}}>{{caracitem.label}}</option>

View File

@ -0,0 +1,44 @@
<table class='table-resolution'>
<tr>
{{#if (gt min -8)}}
<th class="table-resolution-level">-8</th>
{{/if}}
{{#if (gt min -7)}}
<th class="table-resolution-level">...</th>
{{/if}}
{{#each cols as |col|}}
<th class="table-resolution-level">{{numberFormat col decimals=0 sign=true}}</th>
{{/each}}
</tr>
{{#each rows as |row|}}
<tr>
{{#if (gt @root.min -8)}}
<td class="table-resolution-carac" data-row="{{row}}" data-col="{{col}}">{{computeResolutionScore row -8}}</td>
{{/if}}
{{#if (gt @root.min -7)}}
<td class=""></td>
{{/if}}
{{#each @root.cols as |col|}}
{{#if (and (eq row @root.carac) (eq col @root.difficulte))}}
<td class="table-resolution-target">{{computeResolutionScore row col}}</td>
{{else if (eq col -8)}}
<td class="table-resolution-carac">{{computeResolutionScore row col}}</td>
{{else}}
<td>{{computeResolutionScore row col}}</td>
{{/if}}
</td>
{{/each}}
</tr>
{{/each}}
</table>
{{#with (computeResolutionChances carac difficulte) as |cell|}}
<div>
<span class="table-proba-reussite">
Particulière: <span class="rdd-roll-part">{{cell.part}}</span>
- Significative: <span class="rdd-roll-sign">{{cell.sign}}</span>
- Réussite: <span class="rdd-roll-norm">{{cell.score}}</span>
- Echec Particulier: <span class="rdd-roll-epart">{{cell.epart}}</span>
- Echec Total: <span class="rdd-roll-etotal">{{cell.etotal}}</span>
</span>
</div>
{{/with}}

View File

@ -0,0 +1,11 @@
<img class="chat-icon" src="{{actor.img}}" title="{{actor.name}}" alt="{{actor.name}}" />
<p>Jet de {{carac.label}} à {{rolled.finalLevel}}:
<strong>
{{rolled.roll}}
</strong> sur {{rolled.score}}%
{{#if (and rolled.caracValue rolled.finalLevel)}}
({{#if (gt rolled.diviseurSignificative 1)}}1/{{rolled.diviseurSignificative}}{{/if}}
de {{rolled.caracValue}} à {{numberFormat rolled.finalLevel decimals=0 sign=true}})
{{/if}}
<strong>{{rolled.quality}}</strong>
</p>