Merge branch 'ajout-morsure' into 'v1.2'

Ajout arme morsure au chafouin

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!108
This commit is contained in:
Leratier Bretonnien 2021-01-09 08:52:01 +00:00
commit f9b799db2f
25 changed files with 543 additions and 595 deletions

View File

@ -7,22 +7,23 @@ import { RdDUtility } from "./rdd-utility.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { RdDItem } from "./item.js"; import { RdDItem } from "./item.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDActorSheet extends ActorSheet { export class RdDActorSheet extends ActorSheet {
/** @override */ /** @override */
static get defaultOptions() { static get defaultOptions() {
RdDUtility.initAfficheContenu(); RdDUtility.initAfficheContenu();
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"], classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html", template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
width: 640, width: 640,
//height: 720, //height: 720,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}], tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}], dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editCaracComp: false, editCaracComp: false,
montrerCompetencesNiveauBase: false, showCompNiveauBase: false,
montrerArchetype: false montrerArchetype: false
}); });
} }
@ -32,79 +33,67 @@ export class RdDActorSheet extends ActorSheet {
let data = super.getData(); let data = super.getData();
if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut
data.data.editCaracComp = this.options.editCaracComp; data.data.editCaracComp = this.options.editCaracComp;
data.data.montrerCompetencesNiveauBase = this.options.montrerCompetencesNiveauBase; data.data.showCompNiveauBase = this.options.showCompNiveauBase;
data.data.montrerArchetype = this.options.montrerArchetype; data.data.montrerArchetype = this.options.montrerArchetype;
let compCategorieNiveau = RdDUtility.getLevelCategory(); // recup catégorie
data.itemsByType = RdDItem.buildItemsClassification(data.items); data.itemsByType = RdDItem.buildItemsClassification(data.items);
// Competence per category // Competence per category
data.competenceByCategory = {};
let competenceXPTotal = 0; let competenceXPTotal = 0;
if (data.itemsByType.competence) { data.competenceByCategory = RdDItem.classify(
for (const item of data.itemsByType.competence) { data.itemsByType.competence,
this.actor.checkCompetenceXP( item.name ); // Petite vérification experience item => item.data.categorie,
//console.log("Push...", item, item.data.categorie); item => {
let list = data.competenceByCategory[item.data.categorie]; this.actor.checkCompetenceXP(item.name); // Petite vérification experience
if (!list) { item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie)));
list = []; // Ignorer les compétences 'troncs' à ce stade
data.competenceByCategory[item.data.categorie] = list; competenceXPTotal += RdDItemCompetence.isTronc(item.name) ? 0 : RdDItemCompetence.computeCompetenceXPCost(item);
} return item;
if (!RdDUtility.isTronc( item.name ) ) // Ignorer les compétences 'troncs' à ce stade });
competenceXPTotal += RdDUtility.computeCompetenceXPCost(item); competenceXPTotal += RdDItemCompetence.computeCompetenceTroncXP(data.itemsByType.competence);
item.data.afficherCompetence = true;
if ( data.data.montrerCompetencesNiveauBase && (Number(item.data.niveau) == Number(compCategorieNiveau[item.data.categorie]) ) ) {
item.data.afficherCompetence = false;
}
list.push(item);
}
}
this.competenceByCategory = duplicate(data.competenceByCategory); // Sauvegarde locale
competenceXPTotal += RdDUtility.computeCompetenceTroncXP(data.itemsByType.competence);
data.data.competenceXPTotal = competenceXPTotal; data.data.competenceXPTotal = competenceXPTotal;
//console.log("XP competence : ", competenceXPTotal);
// Compute current carac sum // Compute current carac sum
let sum = 0; let sum = 0;
for (let caracName in data.data.carac) { for (let caracName in data.data.carac) {
let carac = data.data.carac[caracName]; let currentCarac = data.data.carac[caracName];
if (!carac.derivee) { if (!currentCarac.derivee) {
sum += parseInt(carac.value); sum += parseInt(currentCarac.value);
} }
} }
data.data.caracSum = sum; data.data.caracSum = sum;
// Force empty arme, at least for Esquive // Force empty arme, at least for Esquive
if (data.itemsByType.arme == undefined ) data.itemsByType.arme = []; if (data.itemsByType.arme == undefined) data.itemsByType.arme = [];
for (const arme of data.itemsByType.arme) { for (const arme of data.itemsByType.arme) {
arme.data.niveau = 0; // Per default, TODO to be fixed arme.data.niveau = 0; // Per default, TODO to be fixed
for ( const melee of data.competenceByCategory.melee ) { for (const melee of data.competenceByCategory.melee) {
if (melee.name == arme.data.competence ) if (melee.name == arme.data.competence)
arme.data.niveau = melee.data.niveau arme.data.niveau = melee.data.niveau
} }
for ( const tir of data.competenceByCategory.tir ) { for (const tir of data.competenceByCategory.tir) {
if (tir.name == arme.data.competence ) if (tir.name == arme.data.competence)
arme.data.niveau = tir.data.niveau arme.data.niveau = tir.data.niveau
} }
for ( const lancer of data.competenceByCategory.lancer ) { for (const lancer of data.competenceByCategory.lancer) {
if (lancer.name == arme.data.competence ) if (lancer.name == arme.data.competence)
arme.data.niveau = lancer.data.niveau arme.data.niveau = lancer.data.niveau
} }
} }
// To avoid armour and so on... // To avoid armour and so on...
data.data.combat = duplicate( RdDUtility.checkNull(data.itemsByType['arme'])); data.data.combat = duplicate(RdDUtility.checkNull(data.itemsByType['arme']));
data.data.combat = RdDUtility._finalizeArmeList( data.data.combat, data.itemsByType.competence, data.data.carac ); data.data.combat = RdDUtility._finalizeArmeList(data.data.combat, data.itemsByType.competence, data.data.carac);
if (data.competenceByCategory && data.competenceByCategory.melee) { if (data.competenceByCategory && data.competenceByCategory.melee) {
//Specific case for Esquive and Corps à Corps //Specific case for Esquive and Corps à Corps
for ( const melee of data.competenceByCategory.melee ) { for (const melee of data.competenceByCategory.melee) {
if (melee.name == "Esquive") if (melee.name == "Esquive")
data.data.combat.push( { name: "Esquive", data: { niveau: melee.data.niveau, description: "", force: 6, initiative: "", competence: "Esquive", dommages: 0} } ); data.data.combat.push({ name: "Esquive", data: { niveau: melee.data.niveau, description: "", force: 6, initiative: "", competence: "Esquive", dommages: 0 } });
if (melee.name == "Corps à corps") { if (melee.name == "Corps à corps") {
let cc_init = RdDUtility.calculInitiative(melee.data.niveau, data.data.carac['melee'].value); let cc_init = RdDUtility.calculInitiative(melee.data.niveau, data.data.carac['melee'].value);
data.data.combat.push( RdDItemArme.mainsNues({ niveau: melee.data.niveau, initiative: cc_init }) ); data.data.combat.push(RdDItemArme.mainsNues({ niveau: melee.data.niveau, initiative: cc_init }));
} }
} }
} }
@ -125,20 +114,19 @@ export class RdDActorSheet extends ActorSheet {
// low is normal, this the base used to compute the grid. // low is normal, this the base used to compute the grid.
data.data.fatigue = { data.data.fatigue = {
malus: RdDUtility.calculMalusFatigue(data.data.sante.fatigue.value, data.data.sante.endurance.max), malus: RdDUtility.calculMalusFatigue(data.data.sante.fatigue.value, data.data.sante.endurance.max),
html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix( data.data.sante.fatigue.value, data.data.sante.endurance.max ).html() + "</table>" html: "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(data.data.sante.fatigue.value, data.data.sante.endurance.max).html() + "</table>"
} }
RdDUtility.filterItemsPerTypeForSheet(data ); RdDUtility.filterItemsPerTypeForSheet(data);
data.data.sortReserve = data.data.reve.reserve.list; data.data.sortReserve = data.data.reve.reserve.list;
data.data.caseSpeciales = data.itemsByType['casetmr']; data.data.caseSpeciales = data.itemsByType['casetmr'];
RdDUtility.buildArbreDeConteneur( this, data ); RdDUtility.buildArbreDeConteneur(this, data);
data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : "";
return data; return data;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onDrop(event) { async _onDrop(event) {
await RdDUtility.processItemDropEvent(this, event); await RdDUtility.processItemDropEvent(this, event);
@ -187,41 +175,41 @@ export class RdDActorSheet extends ActorSheet {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async createEmptyTache( ) { async createEmptyTache() {
await this.actor.createOwnedItem( { name: 'Nouvelle tache', type: 'tache'}, { renderSheet: true } ); await this.actor.createOwnedItem({ name: 'Nouvelle tache', type: 'tache' }, { renderSheet: true });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async creerObjet( ) { async creerObjet() {
let itemType = $("#creer-equipement").val(); let itemType = $("#creer-equipement").val();
await this.actor.createOwnedItem( { name: 'Nouveau '+itemType, type: itemType}, { renderSheet: true } ); await this.actor.createOwnedItem({ name: 'Nouveau ' + itemType, type: itemType }, { renderSheet: true });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async selectObjetType( ) { async selectObjetType() {
let itemType = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "monnaie"]; let itemType = ["objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "monnaie"];
let options = '<span class="competence-label">Selectionnez le type d\'équipement</span><select id="creer-equipement">'; let options = '<span class="competence-label">Selectionnez le type d\'équipement</span><select id="creer-equipement">';
for( let typeName of itemType) { for (let typeName of itemType) {
options += '<option value="'+typeName+'">'+typeName+'</option>' options += '<option value="' + typeName + '">' + typeName + '</option>'
} }
options += '</select>'; options += '</select>';
let d = new Dialog( { let d = new Dialog({
title: "Créer un équipement", title: "Créer un équipement",
content: options, content: options,
buttons: { buttons: {
one: { one: {
icon: '<i class="fas fa-check"></i>', icon: '<i class="fas fa-check"></i>',
label: "Créer l'objet", label: "Créer l'objet",
callback: () => this.creerObjet() callback: () => this.creerObjet()
}
} }
}); }
});
d.render(true); d.render(true);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
@ -239,7 +227,7 @@ export class RdDActorSheet extends ActorSheet {
// Delete Inventory Item // Delete Inventory Item
html.find('.item-delete').click(ev => { html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
this.confirmerSuppression( li ); this.confirmerSuppression(li);
}); });
html.find('#encaisser-direct').click(ev => { html.find('#encaisser-direct').click(ev => {
@ -263,25 +251,25 @@ export class RdDActorSheet extends ActorSheet {
// Blessure control // Blessure control
html.find('.blessure-control').click(ev => { html.find('.blessure-control').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
let btype = li.data("blessure-type"); let btype = li.data("blessure-type");
let index = li.data('blessure-index'); let index = li.data('blessure-index');
let active = $(ev.currentTarget).data('blessure-active'); let active = $(ev.currentTarget).data('blessure-active');
//console.log(btype, index, active); //console.log(btype, index, active);
this.actor.manageBlessureFromSheet(btype, index, active).then( this.render(true) ); this.actor.manageBlessureFromSheet(btype, index, active).then(this.render(true));
}); });
// Blessure data // Blessure data
html.find('.blessures-soins').change(ev => { html.find('.blessures-soins').change(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
let btype = li.data('blessure-type'); let btype = li.data('blessure-type');
let index = li.data('blessure-index'); let index = li.data('blessure-index');
let psoins = li.find('input[name=premiers_soins]').val(); let psoins = li.find('input[name=premiers_soins]').val();
let pcomplets = li.find('input[name=soins_complets]').val(); let pcomplets = li.find('input[name=soins_complets]').val();
let jours = li.find('input[name=jours]').val(); let jours = li.find('input[name=jours]').val();
let loc = li.find('input[name=localisation]').val(); let loc = li.find('input[name=localisation]').val();
//console.log(btype, index, psoins, pcomplets, jours, loc); //console.log(btype, index, psoins, pcomplets, jours, loc);
this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then( this.render(true) ); this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then(this.render(true));
}); });
// Equip Inventory Item // Equip Inventory Item
@ -294,11 +282,11 @@ export class RdDActorSheet extends ActorSheet {
// Roll Carac // Roll Carac
html.find('.carac-label a').click((event) => { html.find('.carac-label a').click((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((event) => { html.find('#chance-actuelle').click((event) => {
this.actor.rollCarac( 'chance-actuelle' ); this.actor.rollCarac('chance-actuelle');
}); });
html.find('#chance-appel').click((event) => { html.find('#chance-appel').click((event) => {
@ -312,22 +300,22 @@ export class RdDActorSheet extends ActorSheet {
// Roll Skill // Roll Skill
html.find('.competence-label a').click((event) => { html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text; let compName = event.currentTarget.text;
this.actor.rollCompetence( compName); this.actor.rollCompetence(compName);
}); });
html.find('.tache-label a').click((event) => { html.find('.tache-label a').click((event) => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");
let tacheId = li.data('item-id'); let tacheId = li.data('item-id');
this.actor.rollTache( tacheId ); this.actor.rollTache(tacheId);
}); });
html.find('.meditation-label a').click((event) => { html.find('.meditation-label a').click((event) => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");
let meditationId = li.data('item-id'); let meditationId = li.data('item-id');
this.actor.rollMeditation( meditationId ); this.actor.rollMeditation(meditationId);
}); });
// Points de reve actuel // Points de reve actuel
html.find('.ptreve-actuel a').click((event) => { html.find('.ptreve-actuel a').click((event) => {
this.actor.rollCarac( 'reve-actuel' ); this.actor.rollCarac('reve-actuel');
}); });
// Roll Weapon1 // Roll Weapon1
@ -338,28 +326,28 @@ export class RdDActorSheet extends ActorSheet {
}); });
// Initiative pour l'arme // Initiative pour l'arme
html.find('.arme-initiative a').click((event) => { html.find('.arme-initiative a').click((event) => {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id ); let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
if ( combatant ) { if (combatant) {
let armeName = event.currentTarget.attributes['data-arme-name'].value; let armeName = event.currentTarget.attributes['data-arme-name'].value;
let arme = this.armesList.find( a => a.name == armeName); let arme = this.armesList.find(a => a.name == armeName);
RdDUtility.rollInitiativeCompetence( combatant._id, arme); RdDUtility.rollInitiativeCompetence(combatant._id, arme);
} else { } else {
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat."); ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
} }
}); });
// Display TMR, visuualisation // Display TMR, visuualisation
html.find('#visu-tmr').click((event) => { html.find('#visu-tmr').click((event) => {
this.actor.displayTMR( "visu"); this.actor.displayTMR("visu");
}); });
// Display TMR, normal // Display TMR, normal
html.find('#monte-tmr').click((event) => { html.find('#monte-tmr').click((event) => {
this.actor.displayTMR( "normal" ); this.actor.displayTMR("normal");
}); });
// Display TMR, fast // Display TMR, fast
html.find('#monte-tmr-rapide').click((event) => { html.find('#monte-tmr-rapide').click((event) => {
this.actor.displayTMR( "rapide" ); this.actor.displayTMR("rapide");
}); });
html.find('#dormir-une-heure').click((event) => { html.find('#dormir-une-heure').click((event) => {
@ -391,7 +379,7 @@ export class RdDActorSheet extends ActorSheet {
// Display info about queue // Display info about queue
html.find('.conteneur-name a').click((event) => { html.find('.conteneur-name a').click((event) => {
let myID = event.currentTarget.attributes['data-item-id'].value; let myID = event.currentTarget.attributes['data-item-id'].value;
RdDUtility.toggleAfficheContenu( myID ); RdDUtility.toggleAfficheContenu(myID);
this.render(true); this.render(true);
}); });
@ -400,29 +388,29 @@ export class RdDActorSheet extends ActorSheet {
html.find('.carac-value').change((event) => { html.find('.carac-value').change((event) => {
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", ""); let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName); //console.log("Value changed :", event, caracName);
this.actor.updateCarac( caracName, parseInt(event.target.value) ); this.actor.updateCarac(caracName, parseInt(event.target.value));
} ); });
html.find('.carac-xp').change((event) => { html.find('.carac-xp').change((event) => {
let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", ""); let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName); //console.log("Value changed :", event, caracName);
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((event) => { html.find('.competence-value').change((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('.competence-xp').change((event) => { html.find('.competence-xp').change((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 archetype change // On competence archetype change
html.find('.competence-archetype').change((event) => { html.find('.competence-archetype').change((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));
} ); });
} }
// Gestion du bouton lock/unlock // Gestion du bouton lock/unlock
@ -431,7 +419,7 @@ export class RdDActorSheet extends ActorSheet {
this.render(true); this.render(true);
}); });
html.find('#show-hide-competences').click((event) => { html.find('#show-hide-competences').click((event) => {
this.options.montrerCompetencesNiveauBase = !this.options.montrerCompetencesNiveauBase; this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true); this.render(true);
}); });
html.find('#show-hide-archetype').click((event) => { html.find('#show-hide-archetype').click((event) => {
@ -442,30 +430,30 @@ export class RdDActorSheet extends ActorSheet {
// On pts de reve change // On pts de reve change
html.find('.pointsreve-value').change((event) => { html.find('.pointsreve-value').change((event) => {
let reveValue = event.currentTarget.value; let reveValue = event.currentTarget.value;
let reve = duplicate( this.actor.data.data.reve.reve ); let reve = duplicate(this.actor.data.data.reve.reve);
reve.value = reveValue; reve.value = reveValue;
this.actor.update( { "data.reve.reve": reve } ); this.actor.update({ "data.reve.reve": reve });
} ); });
// On seuil de reve change // On seuil de reve change
html.find('.seuil-reve-value').change((event) => { html.find('.seuil-reve-value').change((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((event) => { html.find('#attribut-protection-edit').change((event) => {
this.actor.updateProtectionValue( event.currentTarget.attributes.name.value, parseInt(event.target.value) ); this.actor.updateProtectionValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
} ); });
// On stress change // On stress change
html.find('.compteur-edit').change((event) => { html.find('.compteur-edit').change((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((event) => { html.find('#ethylisme').change((event) => {
this.actor.setEthylisme(parseInt(event.target.value) ); this.actor.setEthylisme(parseInt(event.target.value));
} ); });
html.find('#stress-test').click((event) => { html.find('#stress-test').click((event) => {
this.actor.stressTest(); this.actor.stressTest();
this.render(true); this.render(true);
@ -494,12 +482,12 @@ export class RdDActorSheet extends ActorSheet {
html.find('.monnaie-plus').click((event) => { html.find('.monnaie-plus').click((event) => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");
this.actor.monnaieIncDec( li.data("item-id"), 1 ); this.actor.monnaieIncDec(li.data("item-id"), 1);
this.render(true); this.render(true);
}); });
html.find('.monnaie-moins').click((event) => { html.find('.monnaie-moins').click((event) => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");
this.actor.monnaieIncDec( li.data("item-id"), -1 ); this.actor.monnaieIncDec(li.data("item-id"), -1);
this.render(true); this.render(true);
}); });
@ -541,7 +529,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
setPosition(options={}) { setPosition(options = {}) {
const position = super.setPosition(options); const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body"); const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192; const bodyHeight = position.height - 192;

View File

@ -46,13 +46,13 @@ export class RdDActor extends Actor {
} }
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic // If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
if (data.items) { if (data.items) {
let actor = super.create(data, options);
if (data.type == "personnage") { if (data.type == "personnage") {
await RdDActor.checkMonnaiePresence( data.items ); await actor.checkMonnaiePresence( data.items );
} }
return super.create(data, options); return actor;
} }
data.items = [];
let compendiumName = ""; let compendiumName = "";
if (data.type == "personnage") { if (data.type == "personnage") {
compendiumName = "foundryvtt-reve-de-dragon.competences"; compendiumName = "foundryvtt-reve-de-dragon.competences";
@ -61,16 +61,7 @@ export class RdDActor extends Actor {
} else if (data.type == "entite") { } else if (data.type == "entite") {
compendiumName = "foundryvtt-reve-de-dragon.competences-entites"; compendiumName = "foundryvtt-reve-de-dragon.competences-entites";
} }
let competences = []; data.items = RdDUtility.loadCompendium(compendiumName);
const pack = game.packs.get(compendiumName);
await pack.getIndex().then(index => competences = index);
for (let comp of competences)
{
let compItem = undefined;
await pack.getEntity(comp._id).then(skill => compItem = skill);
data.items.push(compItem);
}
// Ajout monnaie // Ajout monnaie
if (data.type == "personnage" ) { if (data.type == "personnage" ) {
await RdDActor.ajouterMonnaie( data.items ); await RdDActor.ajouterMonnaie( data.items );
@ -207,12 +198,12 @@ export class RdDActor extends Actor {
return this.data.data.compteurs?.surenc?.value ?? 0; return this.data.data.compteurs?.surenc?.value ?? 0;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCompetenceList() { loadCompendiumNames() {
return this.data.items.filter( (item) => item.type == 'competence'); return this.data.items.filter( (item) => item.type == 'competence');
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getCompetence(compName) { getCompetence(compName) {
return RdDUtility.findCompetence(this.data.items, compName); return RdDItemCompetence.findCompetence(this.data.items, compName);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getTache( id ) { getTache( id ) {
@ -1413,9 +1404,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async checkCompetenceXP( compName ) { async checkCompetenceXP( compName ) {
let competence = RdDUtility.findCompetence( this.data.items, compName); let competence = RdDItemCompetence.findCompetence( this.data.items, compName);
if ( competence && competence.data.xp > 0) { if ( competence && competence.data.xp > 0) {
let xpNeeded = RdDUtility.getCompetenceNextXp( competence.data.niveau ); let xpNeeded = RdDItemCompetence.getCompetenceNextXp( competence.data.niveau );
if ( competence.data.xp >= xpNeeded ) { if ( competence.data.xp >= xpNeeded ) {
competence.data.xp -= xpNeeded; competence.data.xp -= xpNeeded;
competence.data.niveau += 1; competence.data.niveau += 1;
@ -1937,7 +1928,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async ajouteNombreAstral( data ) { async ajouteNombreAstral( data ) {
// Gestion expérience (si existante) // Gestion expérience (si existante)
data.competence = RdDUtility.findCompetence( this.data.items, "astrologie"); data.competence = RdDItemCompetence.findCompetence( this.data.items, "astrologie");
data.selectedCarac = this.data.data.carac["vue"]; data.selectedCarac = this.data.data.carac["vue"];
this._appliquerAjoutExperience( data ); this._appliquerAjoutExperience( data );

View File

@ -1,17 +1,37 @@
const competenceTroncs = [["Esquive", "Dague", "Corps à corps"],
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"]];
const competence_xp_par_niveau = [5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100];
export class RdDItemCompetence extends Item { export class RdDItemCompetence extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCompetenceMelee(name) { static isCompetenceArme(competence) {
return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/); switch (competence.data.categorie) {
case 'melee':
return competence.name.toLowerCase() != 'esquive';
case 'tir':
case 'lancer':
return true;
}
return false;
} }
/* -------------------------------------------- */
static isArmeUneMain(competence) { static isArmeUneMain(competence) {
return competence && competence.name.toLowerCase().includes("1 main"); return competence?.name.toLowerCase().includes("1 main");
}
static isArme2Main(competence) {
return competence?.name.toLowerCase().includes("2 main");
} }
/* -------------------------------------------- */
static isMalusEncombrementTotal(competence) { static isMalusEncombrementTotal(competence) {
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/); return competence?.name.toLowerCase().match(/(natation|acrobatie)/);
} }
/* -------------------------------------------- */
static setRollDataCreature(rollData) { static setRollDataCreature(rollData) {
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } }; rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
rollData.competence = duplicate(rollData.competence); rollData.competence = duplicate(rollData.competence);
@ -19,4 +39,65 @@ export class RdDItemCompetence extends Item {
rollData.competence.data.categorie = "creature"; rollData.competence.data.categorie = "creature";
rollData.selectedCarac = rollData.carac.carac_creature rollData.selectedCarac = rollData.carac.carac_creature
} }
/* -------------------------------------------- */
static isTronc(compName) {
for (let troncList of competenceTroncs) {
for (let troncName of troncList) {
if (troncName == compName)
return troncList;
}
}
return false;
}
/* -------------------------------------------- */
static computeCompetenceXPCost(competence) {
let minLevel = competence.data.base;
if (minLevel == competence.data.niveau) return 0;
if (competence.data.niveau < -10) return 0;
let xp = 0;
for (let i = minLevel + 1; i <= competence.data.niveau; i++) {
xp += competence_xp_par_niveau[i + 10];
//console.log(i, i+10, competence_xp_par_niveau[i+10]);
}
if (competence.data.categorie == 'draconic') {
xp += competence.data.xp_sort;
}
return xp;
}
/* -------------------------------------------- */
static computeCompetenceTroncXP(competences) {
let xp = 0;
for (let troncList of competenceTroncs) {
let minNiveau = 0;
for (let troncName of troncList) {
let comp = RdDItemCompetence.findCompetence(competences, troncName);
if (comp) {
minNiveau = Math.min(comp.data.niveau, minNiveau);
}
}
minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun
let minNiveauXP = competence_xp_par_niveau[minNiveau + 10];
xp += minNiveauXP;
for (let troncName of troncList) {
let comp = RdDItemCompetence.findCompetence(competences, troncName);
if (comp) {
xp += competence_xp_par_niveau[comp.data.niveau + 10] - minNiveauXP;
}
}
}
return xp;
}
/* -------------------------------------------- */
static findCompetence(list, name) {
name = name.toLowerCase();
return list.find(item => item.name.toLowerCase() == name && (item.type == "competence" || item.type == "competencecreature"))
}
/* -------------------------------------------- */
static getCompetenceNextXp(niveau) {
return competence_xp_par_niveau[niveau + 10];
}
} }

View File

@ -2,6 +2,7 @@ import { RdDItemSort } from "./item-sort.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { RdDItem } from "./item-rdd.js"; import { RdDItem } from "./item-rdd.js";
import { RdDAlchimie } from "./rdd-alchimie.js"; import { RdDAlchimie } from "./rdd-alchimie.js";
import { RdDItemCompetence } from "./item-competence.js";
/** /**
* Extend the basic ItemSheet with some very simple modifications * Extend the basic ItemSheet with some very simple modifications
@ -47,10 +48,13 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async getData() { async getData() {
let data = super.getData(); let data = super.getData();
data.categorieCompetences = RdDUtility.getCategorieCompetences();
if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') { if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') {
data.caracList = duplicate(game.system.model.Actor.personnage.carac); data.caracList = duplicate(game.system.model.Actor.personnage.carac);
data.competenceList = await RdDUtility.getCompetenceList( 'foundryvtt-reve-de-dragon.competences' ); data.competences = await RdDUtility.loadCompendiumNames( 'foundryvtt-reve-de-dragon.competences' );
}
if (data.item.type == 'arme') {
data.competences = await RdDUtility.loadCompendium( 'foundryvtt-reve-de-dragon.competences', it => RdDItemCompetence.isCompetenceArme(it));
} }
if ( data.item.type == 'recettealchimique' ) { if ( data.item.type == 'recettealchimique' ) {
RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id ); RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id );
@ -101,8 +105,7 @@ export class RdDItemSheet extends ItemSheet {
async _onClickSelectCategorie(event) { async _onClickSelectCategorie(event) {
event.preventDefault(); event.preventDefault();
const category = event.currentTarget.value; let level = RdDUtility.getLevelCategory(event.currentTarget.value);
let level = CONFIG.RDD.level_category[category];
this.object.data.data.base = level; this.object.data.data.base = level;
$("#base").val( level ); $("#base").val( level );
} }

View File

@ -3,16 +3,26 @@
export class RdDItem { export class RdDItem {
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildItemsClassification( items ) { static buildItemsClassification(items) {
let itemsByType = {}; return RdDItem.classify(items, it => it.type)
}
static classify(items, classifier = it => it.type, transform = it => it) {
let itemsBy = {};
RdDItem.classifyInto(itemsBy, items, classifier, transform);
return itemsBy;
}
static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) {
for (const item of items) { for (const item of items) {
let list = itemsByType[item.type]; const classification = classifier(item);
let list = itemsBy[classification];
if (!list) { if (!list) {
list = []; list = [];
itemsByType[item.type] = list; itemsBy[classification] = list;
} }
list.push(item); list.push(transform(item));
} }
return itemsByType;
} }
} }

View File

@ -1,3 +1,4 @@
import { RdDItemCompetence } from "./item-competence.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
import { RdDCalendrier } from "./rdd-calendrier.js"; import { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
@ -15,7 +16,7 @@ export class RdDAstrologieJoueur extends Dialog {
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ), dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
etat: actor.getEtatGeneral(), etat: actor.getEtatGeneral(),
ajustementsConditions: CONFIG.RDD.ajustementsConditions, ajustementsConditions: CONFIG.RDD.ajustementsConditions,
astrologie: RdDUtility.findCompetence( actor.data.items, 'Astrologie') astrologie: RdDItemCompetence.findCompetence( actor.data.items, 'Astrologie')
} }
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data); const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', data);
let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 }; let options = { classes: ["rdddialog"], width: 600, height: 500, 'z-index': 99999 };

View File

@ -22,6 +22,7 @@ import { RdDTokenHud } from "./rdd-token-hud.js";
import { RdDCommands } from "./rdd-commands.js"; import { RdDCommands } from "./rdd-commands.js";
import { RdDCombat } from "./rdd-combat.js"; import { RdDCombat } from "./rdd-combat.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -65,7 +66,7 @@ const _patch_initiative = () => {
} }
} }
let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence; let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence;
competence = RdDUtility.findCompetence( c.actor.data.items, compName ); competence = RdDItemCompetence.findCompetence( c.actor.data.items, compName );
rollFormula = RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value); rollFormula = RdDUtility.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value);
} }
} }
@ -190,7 +191,6 @@ Hooks.once("init", async function() {
CONFIG.Actor.entityClass = RdDActor; CONFIG.Actor.entityClass = RdDActor;
CONFIG.RDD = { CONFIG.RDD = {
resolutionTable : RdDResolutionTable.resolutionTable, resolutionTable : RdDResolutionTable.resolutionTable,
level_category : RdDUtility.getLevelCategory(),
carac_array : RdDUtility.getCaracArray(), carac_array : RdDUtility.getCaracArray(),
ajustementsConditions : RdDUtility.getAjustementsConditions(), ajustementsConditions : RdDUtility.getAjustementsConditions(),
difficultesLibres : RdDUtility.getDifficultesLibres() difficultesLibres : RdDUtility.getDifficultesLibres()

View File

@ -6,46 +6,26 @@ import { RdDCombat } from "./rdd-combat.js";
import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js"; import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
const level_category = { const categorieCompetences = {
"generale": "-4", "generale": { level: "-4", label: "Générales" },
"particuliere": "-8", "particuliere": { level: "-8", label: "Particulières" },
"specialisee": "-11", "specialisee": { level: "-11", label: "Spécialisées" },
"connaissance": "-11", "connaissance": { level: "-11", label: "Connaissances" },
"draconic": "-11", "draconic": { level: "-11", label: "Draconics" },
"melee": "-6", "melee": { level: "-6", label: "Mêlée" },
"tir": "-8", "tir": { level: "-8", label: "Tir" },
"lancer": "-8" "lancer": { level: "-8", label: "Lancer" }
}
/* -------------------------------------------- */
const label_category = {
"generale": "Générales",
"particuliere": "Particulières",
"specialisee": "Spécialisées",
"connaissance": "Connaissances",
"draconic": "Draconics",
"melee": "Mêlée",
"tir": "Tir",
"lancer": "Lancer"
}
/* -------------------------------------------- */
const competenceTroncs = [ ["Esquive", "Dague", "Corps à corps"],
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"] ];
const competence_xp = {
"-11" : [ 5, 10, 15, 25, 35, 45, 55, 70, 85, 100, 115, 135, 155, 175 ],
"-8" : [ 10, 20, 30, 40, 55, 70, 85, 100, 120, 140,160],
"-6" : [ 10, 20, 35, 50, 65, 80, 100, 120, 140],
"-4" : [ 15, 30, 45, 60, 80, 100, 120]
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
// This table starts at 0 -> niveau -10 // This table starts at 0 -> niveau -10
const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100]; const carac_array = ["taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"];
const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10];
const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10];
const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25];
const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25];
const carac_xp_par_valeur = [6, 6, 7, 7, 8, 8, 9, 9, 10, 20, 30, 40, 50, 60, 70]; const carac_xp_par_valeur = [6, 6, 7, 7, 8, 8, 9, 9, 10, 20, 30, 40, 50, 60, 70];
const XP_CARAC_OFFSET = 7; const XP_CARAC_OFFSET = 7;
@ -54,12 +34,12 @@ function _buildAllSegmentsFatigue(max) {
const cycle = [5, 2, 4, 1, 3, 0]; const cycle = [5, 2, 4, 1, 3, 0];
let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]; let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
for (let i = 0; i <= max; i++) { for (let i = 0; i <= max; i++) {
const ligneFatigue= duplicate(fatigue[i]); const ligneFatigue = duplicate(fatigue[i]);
const caseIncrementee = cycle[i % 6]; const caseIncrementee = cycle[i % 6];
ligneFatigue[caseIncrementee]++; ligneFatigue[caseIncrementee]++;
ligneFatigue[caseIncrementee + 6]++; ligneFatigue[caseIncrementee + 6]++;
ligneFatigue.fatigueMax = 2 * (i + 1); ligneFatigue.fatigueMax = 2 * (i + 1);
fatigue[i + 1] = ligneFatigue ; fatigue[i + 1] = ligneFatigue;
} }
return fatigue; return fatigue;
@ -68,8 +48,7 @@ function _buildAllSegmentsFatigue(max) {
/* -------------------------------------------- */ /* -------------------------------------------- */
function _cumulSegmentsFatigue(matrix) { function _cumulSegmentsFatigue(matrix) {
let cumulMatrix = []; let cumulMatrix = [];
for (let line of matrix) for (let line of matrix) {
{
let cumul = duplicate(line); let cumul = duplicate(line);
for (let i = 1; i < 12; i++) { for (let i = 1; i < 12; i++) {
@ -84,33 +63,37 @@ function _cumulSegmentsFatigue(matrix) {
const fatigueMatrix = _buildAllSegmentsFatigue(60); const fatigueMatrix = _buildAllSegmentsFatigue(60);
const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix); const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix);
const fatigueMalus = [ 0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7 ]; // Provides the malus for each segment of fatigue const fatigueMalus = [0, 0, 0, -1, -1, -1, -2, -3, -4, -5, -6, -7]; // Provides the malus for each segment of fatigue
const fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12]; const fatigueLineSize = [3, 6, 7, 8, 9, 10, 11, 12];
const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ]; const fatigueLineMalus = [0, -1, -2, -3, -4, -5, -6, -7];
const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 }, const fatigueMarche = {
"malaise": { "4":2, "6":3, "8":4, "10":6 }, "aise": { "4": 1, "6": 2, "8": 3, "10": 4, "12": 6 },
"difficile": { "4":3, "6":4, "8":6 }, "malaise": { "4": 2, "6": 3, "8": 4, "10": 6 },
"tresdifficile": { "4":4, "6":6 } } "difficile": { "4": 3, "6": 4, "8": 6 },
"tresdifficile": { "4": 4, "6": 6 }
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Static tables for commands /table */ /* Static tables for commands /table */
const table2func = { "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open }, const table2func = {
"queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue}, "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open },
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre }, "queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue },
"tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR}, "ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
"tete" : { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete}, "tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR },
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle}, "tete": { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete },
"tarot" : { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot} }; "souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle },
"tarot": { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot }
};
/* -------------------------------------------- */ /* -------------------------------------------- */
const definitionsBlessures = [ const definitionsBlessures = [
{ type: "legere", facteur: 2 }, { type: "legere", facteur: 2 },
{ type: "grave", facteur : 4 }, { type: "grave", facteur: 4 },
{ type: "critique", facteur : 6 } { type: "critique", facteur: 6 }
] ]
/* -------------------------------------------- */ /* -------------------------------------------- */
const nomEthylisme = [ "Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"]; const nomEthylisme = ["Emeché", "Gris", "Pinté", "Pas frais", "Ivre", "Bu", "Complètement fait", "Ivre mort"];
/* -------------------------------------------- */ /* -------------------------------------------- */
const definitionsEncaissement = { const definitionsEncaissement = {
@ -138,9 +121,9 @@ const definitionsEncaissement = {
}; };
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDUtility { export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async preloadHandlebarsTemplates( ) { static async preloadHandlebarsTemplates() {
const templatePaths = [ const templatePaths = [
//Character Sheets //Character Sheets
'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html',
@ -168,14 +151,14 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/item-ombre-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-ombre-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-monnaie-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html', 'systems/foundryvtt-reve-de-dragon/templates/enum-rarete.html',
'systems/foundryvtt-reve-de-dragon/templates/arme-competence.html',
'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html', 'systems/foundryvtt-reve-de-dragon/templates/sort-draconic.html',
'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html', 'systems/foundryvtt-reve-de-dragon/templates/sort-tmr.html',
'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html', 'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html',
@ -234,46 +217,46 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getNomEthylisme( niveauEthylisme ) { static getNomEthylisme(niveauEthylisme) {
let index = -niveauEthylisme; let index = -niveauEthylisme;
return index <0 ? 'Aucun' : nomEthylisme[index]; return index < 0 ? 'Aucun' : nomEthylisme[index];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static initAfficheContenu( actorId ) { // persistent handling of conteneur show/hide static initAfficheContenu(actorId) { // persistent handling of conteneur show/hide
if ( !this.afficheContenu ) if (!this.afficheContenu)
this.afficheContenu = {}; this.afficheContenu = {};
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static toggleAfficheContenu( conteneurId) { static toggleAfficheContenu(conteneurId) {
this.afficheContenu[conteneurId] = !this.afficheContenu[conteneurId]; this.afficheContenu[conteneurId] = !this.afficheContenu[conteneurId];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getAfficheContenu( conteneurId) { static getAfficheContenu(conteneurId) {
return this.afficheContenu[conteneurId]; return this.afficheContenu[conteneurId];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static filterItemsPerTypeForSheet( data ) { static filterItemsPerTypeForSheet(data) {
data.data.materiel = this.checkNull(data.itemsByType['objet']); data.data.materiel = this.checkNull(data.itemsByType['objet']);
data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']); data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']);
data.data.armes = this.checkNull(data.itemsByType['arme']); data.data.armes = this.checkNull(data.itemsByType['arme']);
data.data.armures = this.checkNull(data.itemsByType['armure']); data.data.armures = this.checkNull(data.itemsByType['armure']);
data.data.livres = this.checkNull(data.itemsByType['livre']); data.data.livres = this.checkNull(data.itemsByType['livre']);
data.data.potions = this.checkNull(data.itemsByType['potion']); data.data.potions = this.checkNull(data.itemsByType['potion']);
data.data.ingredients = this.checkNull(data.itemsByType['ingredient']); data.data.ingredients = this.checkNull(data.itemsByType['ingredient']);
data.data.munitions = this.checkNull(data.itemsByType['munition']); data.data.munitions = this.checkNull(data.itemsByType['munition']);
data.data.herbes = this.checkNull(data.itemsByType['herbe']); data.data.herbes = this.checkNull(data.itemsByType['herbe']);
data.data.sorts = this.checkNull(data.itemsByType['sort']); data.data.sorts = this.checkNull(data.itemsByType['sort']);
data.data.queues = this.checkNull(data.itemsByType['queue']); data.data.queues = this.checkNull(data.itemsByType['queue']);
data.data.souffles = this.checkNull(data.itemsByType['souffle']); data.data.souffles = this.checkNull(data.itemsByType['souffle']);
data.data.ombres = this.checkNull(data.itemsByType['ombre']); data.data.ombres = this.checkNull(data.itemsByType['ombre']);
data.data.tetes = this.checkNull(data.itemsByType['tete']); data.data.tetes = this.checkNull(data.itemsByType['tete']);
data.data.taches = this.checkNull(data.itemsByType['tache']); data.data.taches = this.checkNull(data.itemsByType['tache']);
data.data.monnaie = this.checkNull(data.itemsByType['monnaie']); data.data.monnaie = this.checkNull(data.itemsByType['monnaie']);
data.data.meditations = this.checkNull(data.itemsByType['meditation']); data.data.meditations = this.checkNull(data.itemsByType['meditation']);
data.data.recettesAlchimiques = this.checkNull(data.itemsByType['recettealchimique']); data.data.recettesAlchimiques = this.checkNull(data.itemsByType['recettealchimique']);
data.data.objets = data.data.conteneurs.concat(data.data.materiel).concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients); data.data.objets = data.data.conteneurs.concat(data.data.materiel).concat(data.data.armes).concat(data.data.armures).concat(data.data.munitions).concat(data.data.livres).concat(data.data.potions).concat(data.data.herbes).concat(data.data.ingredients);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -303,19 +286,19 @@ export class RdDUtility {
//conteneur.data.encTotal = ; Deja calculé //conteneur.data.encTotal = ; Deja calculé
if (conteneur.data.contenu) { if (conteneur.data.contenu) {
for (let id of conteneur.data.contenu) { for (let id of conteneur.data.contenu) {
let objet = data.data.objets.find( objet => (id == objet._id) ); let objet = data.data.objets.find(objet => (id == objet._id));
if (objet) { if (objet) {
if (!objet.data.encombrement) objet.data.encombrement = 0; // Auto-fix if (!objet.data.encombrement) objet.data.encombrement = 0; // Auto-fix
objet.estContenu = true; // Permet de filtrer ce qifui est porté dans le template objet.estContenu = true; // Permet de filtrer ce qifui est porté dans le template
actorSheet.objetVersConteneur[id] = conteneur._id; actorSheet.objetVersConteneur[id] = conteneur._id;
conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite)?objet.data.quantite:1)); conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite) ? objet.data.quantite : 1));
conteneur.subItems.push( objet ); conteneur.subItems.push(objet);
} }
} }
} }
} }
// Construit la liste des conteneurs de niveau 1 (c'est à dire non contenu eux-même dans un conteneur) // Construit la liste des conteneurs de niveau 1 (c'est à dire non contenu eux-même dans un conteneur)
let newConteneurs = data.data.conteneurs.filter(function(conteneur, index, arr) { return !conteneur.estContenu } ); let newConteneurs = data.data.conteneurs.filter(function (conteneur, index, arr) { return !conteneur.estContenu });
data.data.conteneurs = newConteneurs; data.data.conteneurs = newConteneurs;
//console.log(newConteneurs); //console.log(newConteneurs);
} }
@ -324,20 +307,20 @@ export class RdDUtility {
/** Construit la structure récursive des conteneurs, avec imbrication potentielle /** Construit la structure récursive des conteneurs, avec imbrication potentielle
* *
*/ */
static buildConteneur( objet, niveau ) { static buildConteneur(objet, niveau) {
if (!niveau) niveau = 1; if (!niveau) niveau = 1;
objet.niveau = niveau; objet.niveau = niveau;
//console.log("OBJ:", objet); //console.log("OBJ:", objet);
let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']( { item: objet} ); let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']({ item: objet });
if (objet.type == 'conteneur') { if (objet.type == 'conteneur') {
//console.log("ITEM DISPLAYED", this.getAfficheContenu(objet._id) ); //console.log("ITEM DISPLAYED", this.getAfficheContenu(objet._id) );
if ( this.getAfficheContenu(objet._id) ) { if (this.getAfficheContenu(objet._id)) {
str = str + "<ul class='item-list alterne-list item-display-show list-item-margin"+niveau+"'>"; str = str + "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
} else { } else {
str = str + "<ul class='item-list alterne-list item-display-hide list-item-margin"+niveau+"'>"; str = str + "<ul class='item-list alterne-list item-display-hide list-item-margin" + niveau + "'>";
} }
for (let subItem of objet.subItems) { for (let subItem of objet.subItems) {
str = str + this.buildConteneur(subItem, niveau+1); str = str + this.buildConteneur(subItem, niveau + 1);
} }
str = str + "</ul>"; str = str + "</ul>";
} }
@ -345,146 +328,51 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildResolutionTable( ) { static getCategorieCompetences() {
let tableRes = [] return categorieCompetences;
for (var j=0; j<=21; j++) {
let subtab = [];
for (var i=-10; i<=22; i++) {
var m = (i + 10) * 0.5;
var v;
if (i == -9) {
v = Math.floor(j / 2);
} else if (i == -10) {
v = Math.floor(j / 4);
} else {
if (j % 2 == 0) {
var v = Math.ceil(j * m);
} else {
var v = Math.floor(j * m);
}
}
if (v < 1) v = 1;
let specResults
if ( v > 100 )
specResults = { part: Math.ceil(v / 5), epart: 1000, etotal: 1000 };
else
specResults = specialResults[Math.ceil(v / 5 )];
let tabIndex = i+10;
subtab[tabIndex] = { niveau: i, score: v, part: specResults.part, epart: specResults.epart, etotal: specResults.etotal }
}
tableRes[j] = subtab;
}
return tableRes;
} }
static getLevelCategory(category) {
/* -------------------------------------------- */ return categorieCompetences[category].level;
static getLevelCategory( )
{
return level_category;
} }
static getLabelCategory( ) static getLabelCategory(category) {
{ return categorieCompetences[category].label;
return label_category;
} }
static getCaracArray() static getCaracArray() {
{
return carac_array; return carac_array;
} }
static getDifficultesLibres() static getDifficultesLibres() {
{
return difficultesLibres; return difficultesLibres;
} }
static getAjustementsConditions() static getAjustementsConditions() {
{
return ajustementsConditions; return ajustementsConditions;
} }
static getAjustementsEncaissement() static getAjustementsEncaissement() {
{
return ajustementsEncaissement; return ajustementsEncaissement;
} }
static getDefinitionsBlessures() { static getDefinitionsBlessures() {
return definitionsBlessures; return definitionsBlessures;
} }
/* -------------------------------------------- */
static isTronc( compName )
{
for (let troncList of competenceTroncs) {
for (let troncName of troncList) {
if ( troncName == compName)
return troncList;
}
}
return false;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getCaracNextXp( value ) { static getCaracNextXp(value) {
return carac_xp_par_valeur[value - XP_CARAC_OFFSET]; return carac_xp_par_valeur[value - XP_CARAC_OFFSET];
} }
/* -------------------------------------------- */
static getCompetenceNextXp( niveau ) {
return competence_xp_par_niveau[niveau+10];
}
/* -------------------------------------------- */
static computeCompetenceXPCost( competence )
{
let minLevel = competence.data.base;
if ( minLevel == competence.data.niveau) return 0;
if ( competence.data.niveau < -10) return 0;
let xp = 0;
for (let i=minLevel+1; i<=competence.data.niveau; i++) {
xp += competence_xp_par_niveau[i+10];
//console.log(i, i+10, competence_xp_par_niveau[i+10]);
}
if (competence.data.categorie == 'draconic') {
xp+= competence.data.xp_sort;
}
return xp;
}
/* -------------------------------------------- */
static computeCompetenceTroncXP( competenceList )
{
let xp = 0;
for (let troncList of competenceTroncs) {
let minNiveau = 0;
for (let troncName of troncList) {
let comp = RdDUtility.findCompetence( competenceList, troncName);
if (comp) {
minNiveau = Math.min(comp.data.niveau, minNiveau);
}
}
minNiveau = Math.max(minNiveau, 0); // Clamp à 0, pour le tronc commun
let minNiveauXP = competence_xp_par_niveau[minNiveau+10];
xp += minNiveauXP;
for (let troncName of troncList) {
let comp = RdDUtility.findCompetence( competenceList, troncName);
if (comp){
xp += competence_xp_par_niveau[comp.data.niveau+10] - minNiveauXP;
}
}
}
return xp;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
/** Retourne une liste triée d'armes avec le split arme1 main / arme 2 main */ /** Retourne une liste triée d'armes avec le split arme1 main / arme 2 main */
static _finalizeArmeList( armes, competenceList, carac ) { static _finalizeArmeList(armes, competences, carac) {
// Gestion des armes 1/2 mains // Gestion des armes 1/2 mains
let armesEquipe = []; let armesEquipe = [];
for (const arme of armes) { for (const arme of armes) {
if (arme.data.equipe) { if (arme.data.equipe) {
armesEquipe.push( arme ); armesEquipe.push(arme);
let comp = competenceList.find(c => c.name == arme.data.competence); let comp = competences.find(c => c.name == arme.data.competence);
arme.data.initiative = RdDUtility.calculInitiative(arme.data.niveau, carac[comp.data.defaut_carac].value); arme.data.initiative = RdDUtility.calculInitiative(arme.data.niveau, carac[comp.data.defaut_carac].value);
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence // Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
if (arme.data.unemain && !arme.data.deuxmains ) { if (arme.data.unemain && !arme.data.deuxmains) {
arme.data.mainInfo = "(1m)"; arme.data.mainInfo = "(1m)";
} else if ( !arme.data.unemain && arme.data.deuxmains ) { } else if (!arme.data.unemain && arme.data.deuxmains) {
arme.data.mainInfo = "(2m)"; arme.data.mainInfo = "(2m)";
} else if (arme.data.unemain && arme.data.deuxmains) { } else if (arme.data.unemain && arme.data.deuxmains) {
arme.data.mainInfo = "(1m)"; arme.data.mainInfo = "(1m)";
@ -492,35 +380,34 @@ export class RdDUtility {
arme2main.data.mainInfo = "(2m)"; arme2main.data.mainInfo = "(2m)";
arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK arme2main.data.dommages = arme2main.data.dommages.split("/")[1]; // Existence temporaire uniquement dans la liste des armes, donc OK
arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace ! arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace !
let comp = competenceList.find(c => c.name == arme2main.data.competence); let comp = competences.find(c => c.name == arme2main.data.competence);
arme2main.data.niveau = comp.data.niveau; arme2main.data.niveau = comp.data.niveau;
arme2main.data.initiative = RdDUtility.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value); arme2main.data.initiative = RdDUtility.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
armesEquipe.push(arme2main); armesEquipe.push(arme2main);
} }
} }
} }
return armesEquipe.sort((a, b) => { return armesEquipe.sort((a, b) => {
const nameA = a.name + (a.data.mainInfo ?? ''); const nameA = a.name + (a.data.mainInfo ?? '');
const nameB = b.name + (b.data.mainInfo ?? ''); const nameB = b.name + (b.data.mainInfo ?? '');
if ( nameA > nameB) return 1; if (nameA > nameB) return 1;
if ( nameA < nameB) return -1; if (nameA < nameB) return -1;
return 0; return 0;
} ); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static calculInitiative(niveau, caracValue) { static calculInitiative(niveau, caracValue) {
let base = niveau + Math.floor(caracValue/2); let base = niveau + Math.floor(caracValue / 2);
return "1d6" + (base >= 0 ? "+" : "") + base; return "1d6" + (base >= 0 ? "+" : "") + base;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeCarac( data) static computeCarac(data) {
{
data.carac.force.value = Math.min(data.carac.force.value, parseInt(data.carac.taille.value) + 4); data.carac.force.value = Math.min(data.carac.force.value, parseInt(data.carac.taille.value) + 4);
data.carac.derobee.value = Math.floor(parseInt(((21 - data.carac.taille.value)) + parseInt(data.carac.agilite.value)) / 2); data.carac.derobee.value = Math.floor(parseInt(((21 - data.carac.taille.value)) + parseInt(data.carac.agilite.value)) / 2);
let bonusDomKey = Math.floor( (parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2); let bonusDomKey = Math.floor((parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2);
// TODO: gérer table des bonus dommages (et autres) des créatures // TODO: gérer table des bonus dommages (et autres) des créatures
data.attributs.plusdom.value = 2 data.attributs.plusdom.value = 2
@ -532,30 +419,30 @@ export class RdDUtility {
data.attributs.plusdom.value = 1; data.attributs.plusdom.value = 1;
data.attributs.encombrement.value = (parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2; data.attributs.encombrement.value = (parseInt(data.carac.force.value) + parseInt(data.carac.taille.value)) / 2;
data.carac.melee.value = Math.floor( (parseInt(data.carac.force.value) + parseInt(data.carac.agilite.value)) / 2); data.carac.melee.value = Math.floor((parseInt(data.carac.force.value) + parseInt(data.carac.agilite.value)) / 2);
data.carac.tir.value = Math.floor( (parseInt(data.carac.vue.value) + parseInt(data.carac.dexterite.value)) / 2); data.carac.tir.value = Math.floor((parseInt(data.carac.vue.value) + parseInt(data.carac.dexterite.value)) / 2);
data.carac.lancer.value = Math.floor( (parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2); data.carac.lancer.value = Math.floor((parseInt(data.carac.tir.value) + parseInt(data.carac.force.value)) / 2);
data.sante.vie.max = Math.ceil( (parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value)) /2 ); data.sante.vie.max = Math.ceil((parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value)) / 2);
data.sante.vie.value = Math.min(data.sante.vie.value, data.sante.vie.max) data.sante.vie.value = Math.min(data.sante.vie.value, data.sante.vie.max)
data.sante.endurance.max = Math.max( parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value) ); data.sante.endurance.max = Math.max(parseInt(data.carac.taille.value) + parseInt(data.carac.constitution.value), parseInt(data.sante.vie.max) + parseInt(data.carac.volonte.value));
data.sante.endurance.value = Math.min(data.sante.endurance.value, data.sante.endurance.max); data.sante.endurance.value = Math.min(data.sante.endurance.value, data.sante.endurance.max);
data.sante.fatigue.max = data.sante.endurance.max*2; data.sante.fatigue.max = data.sante.endurance.max * 2;
data.sante.fatigue.value = Math.min(data.sante.fatigue.value, data.sante.fatigue.max); data.sante.fatigue.value = Math.min(data.sante.fatigue.value, data.sante.fatigue.max);
data.attributs.sconst.value = 5; // Max ! data.attributs.sconst.value = 5; // Max !
if ( data.carac.constitution.value < 9 ) if (data.carac.constitution.value < 9)
data.attributs.sconst.value = 2; data.attributs.sconst.value = 2;
else if (data.carac.constitution.value < 12 ) else if (data.carac.constitution.value < 12)
data.attributs.sconst.value = 3; data.attributs.sconst.value = 3;
else if (data.carac.constitution.value < 15 ) else if (data.carac.constitution.value < 15)
data.attributs.sconst.value = 4; data.attributs.sconst.value = 4;
data.attributs.sust.value = 4; // Max ! data.attributs.sust.value = 4; // Max !
if ( data.carac.taille.value < 10 ) if (data.carac.taille.value < 10)
data.attributs.sust.value = 2; data.attributs.sust.value = 2;
else if (data.carac.taille.value < 14 ) else if (data.carac.taille.value < 14)
data.attributs.sust.value = 3; data.attributs.sust.value = 3;
//Compteurs //Compteurs
@ -573,12 +460,11 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static calculMalusFatigue(fatigue, maxEnd) static calculMalusFatigue(fatigue, maxEnd) {
{
maxEnd = Math.max(maxEnd, 1); maxEnd = Math.max(maxEnd, 1);
maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length); maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length);
let segments = cumulFatigueMatrix[maxEnd]; let segments = cumulFatigueMatrix[maxEnd];
for (let i=0; i<12; i++) { for (let i = 0; i < 12; i++) {
if (fatigue <= segments[i]) { if (fatigue <= segments[i]) {
return fatigueMalus[i] return fatigueMalus[i]
} }
@ -588,7 +474,7 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
// Build the nice (?) html table used to manage fatigue. // Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value // max should be the endurance max value
static makeHTMLfatigueMatrix( fatigue, maxEndurance) { static makeHTMLfatigueMatrix(fatigue, maxEndurance) {
let segments = this.getSegmentsFatigue(maxEndurance); let segments = this.getSegmentsFatigue(maxEndurance);
return this.makeHTMLfatigueMatrixForSegment(fatigue, segments); return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
} }
@ -628,25 +514,24 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getLocalisation( ) static getLocalisation() {
{
// TODO: bouger dans une RollTable du compendium et chercher dans les RoolTable puis compendium pour permettre le changement? // TODO: bouger dans une RollTable du compendium et chercher dans les RoolTable puis compendium pour permettre le changement?
let result = new Roll("1d20").roll().total; let result = new Roll("1d20").roll().total;
let txt = "" let txt = ""
if ( result <= 3 ) txt = "Jambe, genou, pied, jarret"; if (result <= 3) txt = "Jambe, genou, pied, jarret";
else if ( result <= 7 ) txt = "Hanche, cuisse, fesse"; else if (result <= 7) txt = "Hanche, cuisse, fesse";
else if ( result <= 9 ) txt = "Ventre, reins"; else if (result <= 9) txt = "Ventre, reins";
else if ( result <= 12 ) txt = "Poitrine, dos"; else if (result <= 12) txt = "Poitrine, dos";
else if ( result <= 14 ) txt = "Avant-bras, main, coude"; else if (result <= 14) txt = "Avant-bras, main, coude";
else if ( result <= 18 ) txt = "Epaule, bras, omoplate"; else if (result <= 18) txt = "Epaule, bras, omoplate";
else if ( result == 19) txt = "Tête"; else if (result == 19) txt = "Tête";
else if ( result == 20) txt = "Tête (visage)"; else if (result == 20) txt = "Tête (visage)";
return { result: result, label: txt }; return { result: result, label: txt };
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static selectEncaissement( degats, mortalite ) { static selectEncaissement(degats, mortalite) {
const table = definitionsEncaissement[mortalite] === undefined ? definitionsEncaissement["mortel"] : definitionsEncaissement[mortalite]; const table = definitionsEncaissement[mortalite] === undefined ? definitionsEncaissement["mortel"] : definitionsEncaissement[mortalite];
for (let encaissement of table) { for (let encaissement of table) {
if ((encaissement.minimum === undefined || encaissement.minimum <= degats) if ((encaissement.minimum === undefined || encaissement.minimum <= degats)
@ -660,23 +545,22 @@ export class RdDUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _evaluatePerte(formula, over20) { static _evaluatePerte(formula, over20) {
console.log("_evaluatePerte", formula, over20 ) console.log("_evaluatePerte", formula, over20)
let perte = new Roll(formula, { over20:over20}) let perte = new Roll(formula, { over20: over20 })
perte.evaluate() perte.evaluate()
return perte.total return perte.total
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static currentFatigueMalus( value, max) static currentFatigueMalus(value, max) {
{
max = Math.max(1, Math.min(max, 60)); max = Math.max(1, Math.min(max, 60));
value = Math.min(max*2, Math.max(0, value)); value = Math.min(max * 2, Math.max(0, value));
let fatigueTab = fatigueMatrix[max]; let fatigueTab = fatigueMatrix[max];
let fatigueRem = value; let fatigueRem = value;
for (let idx=0; idx<fatigueTab.length; idx++) { for (let idx = 0; idx < fatigueTab.length; idx++) {
fatigueRem -= fatigueTab[idx]; fatigueRem -= fatigueTab[idx];
if ( fatigueRem <= 0) { if (fatigueRem <= 0) {
return fatigueMalus[idx]; return fatigueMalus[idx];
} }
} }
@ -684,43 +568,51 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static findCompetence(compList, compName) static async loadCompendiumNames(compendium) {
{
compName = compName.toLowerCase();
return compList.find(item => item.name.toLowerCase() == compName && (item.type =="competence" || item.type == "competencecreature"))
}
/* -------------------------------------------- */
static async getCompetenceList( compendium ) {
const pack = game.packs.get(compendium); const pack = game.packs.get(compendium);
let competences; let competences;
await pack.getIndex().then(index => competences = index); await pack.getIndex().then(index => competences = index);
return competences; return competences;
} }
static async loadCompendium(compendium, filter = item => true) {
let compendiumItems = await RdDUtility.loadCompendiumNames(compendium);
const pack = game.packs.get(compendium);
let list = [];
for (let compendiumItem of compendiumItems) {
await pack.getEntity(compendiumItem._id).then(it => {
const item = it.data;
if (filter(item)) {
list.push(item);
}
});
};
return list;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static async responseNombreAstral( data ) { static async responseNombreAstral(data) {
let actor = game.actors.get( data.id); let actor = game.actors.get(data.id);
actor.ajouteNombreAstral(data); actor.ajouteNombreAstral(data);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static performSocketMesssage( sockmsg ) static performSocketMesssage(sockmsg) {
{
console.log(">>>>> MSG RECV", sockmsg); console.log(">>>>> MSG RECV", sockmsg);
switch(sockmsg.msg) { switch (sockmsg.msg) {
case "msg_encaisser": case "msg_encaisser":
return RdDUtility._handleMsgEncaisser(sockmsg.data); return RdDUtility._handleMsgEncaisser(sockmsg.data);
case "msg_defense" : case "msg_defense":
return RdDUtility._handleMsgDefense(sockmsg.data); return RdDUtility._handleMsgDefense(sockmsg.data);
case "msg_gm_chat_message": case "msg_gm_chat_message":
return ChatUtility.handleGMChatMessage(sockmsg.data); return ChatUtility.handleGMChatMessage(sockmsg.data);
case "msg_sync_time": case "msg_sync_time":
return game.system.rdd.calendrier.syncPlayerTime( sockmsg.data ); return game.system.rdd.calendrier.syncPlayerTime(sockmsg.data);
case "msg_request_nombre_astral": case "msg_request_nombre_astral":
return game.system.rdd.calendrier.requestNombreAstral( sockmsg.data ); return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data);
case "msg_response_nombre_astral": case "msg_response_nombre_astral":
return RdDUtility.responseNombreAstral( sockmsg.data ); return RdDUtility.responseNombreAstral(sockmsg.data);
} }
} }
@ -728,7 +620,7 @@ export class RdDUtility {
static _handleMsgDefense(data) { static _handleMsgDefense(data) {
let defenderToken = canvas.tokens.get(data.defenderTokenId); let defenderToken = canvas.tokens.get(data.defenderTokenId);
if (defenderToken) { if (defenderToken) {
if ( !game.user.isGM && game.user.character == undefined) { // vérification / sanity check if (!game.user.isGM && game.user.character == undefined) { // vérification / sanity check
ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer."); ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer.");
return; return;
} }
@ -744,58 +636,58 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static rollInitiativeCompetence( combatantId, arme ) { static rollInitiativeCompetence(combatantId, arme) {
const combatant = game.combat.getCombatant(combatantId); const combatant = game.combat.getCombatant(combatantId);
const actor = combatant.actor; const actor = combatant.actor;
if ( arme.name == "Autre action") { if (arme.name == "Autre action") {
game.combat.rollInitiative(combatantId, "1d6" ); game.combat.rollInitiative(combatantId, "1d6");
} else if ( arme.name == "Draconic") { } else if (arme.name == "Draconic") {
game.combat.rollInitiative(combatantId, "1d6+200" ); game.combat.rollInitiative(combatantId, "1d6+200");
} else { } else {
let initOffset = 0; let initOffset = 0;
let caracForInit = 0; let caracForInit = 0;
let competence = RdDUtility.findCompetence( combatant.actor.data.items, arme.data.competence); let competence = RdDItemCompetence.findCompetence(combatant.actor.data.items, arme.data.competence);
if ( actor.data.type == 'creature' || actor.data.type == 'entite') { if (actor.data.type == 'creature' || actor.data.type == 'entite') {
caracForInit = competence.data.carac_value; caracForInit = competence.data.carac_value;
} else { } else {
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value; caracForInit = actor.data.data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer" ) { // Offset de principe pour les armes de jet if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
initOffset = 40; initOffset = 40;
} }
if (competence.data.categorie == "tir" ) { // Offset de principe pour les armes de jet if (competence.data.categorie == "tir") { // Offset de principe pour les armes de jet
initOffset = 80; initOffset = 80;
} }
} }
initOffset -= actor.getEtatGeneral(); // Prise en compte état général initOffset -= actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages // Cas des créatures et entités vs personnages
let rollFormula = RdDUtility.calculInitiative(competence.data.niveau, caracForInit) + "+" + initOffset; let rollFormula = RdDUtility.calculInitiative(competence.data.niveau, caracForInit) + "+" + initOffset;
game.combat.rollInitiative(combatantId, rollFormula ); game.combat.rollInitiative(combatantId, rollFormula);
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static buildListeActionsCombat( combatant ) { static buildListeActionsCombat(combatant) {
const actor = combatant.actor; // Easy access const actor = combatant.actor; // Easy access
let items = actor.data.items; let items = actor.data.items;
let actions = [] let actions = []
if ( actor.isCreature()) { if (actor.isCreature()) {
actions = actions.concat(items.filter(it => it.type =='competencecreature' && it.data.iscombat) actions = actions.concat(items.filter(it => it.type == 'competencecreature' && it.data.iscombat)
.map(competence => RdDItemCompetenceCreature.toArme(competence))); .map(competence => RdDItemCompetenceCreature.toArme(competence)));
} else { } else {
// Recupération des items 'arme' // Recupération des items 'arme'
let armes = items.filter(it => it.type =='arme') let armes = items.filter(it => it.type == 'arme')
.map(arme => duplicate(arme)) /* pas de changements aux armes d'origine */ .map(arme => duplicate(arme)) /* pas de changements aux armes d'origine */
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence'); let competences = items.filter(it => it.type == 'competence');
actions = actions.concat(this._finalizeArmeList( armes, competences, actor.data.data.carac )); actions = actions.concat(this._finalizeArmeList(armes, competences, actor.data.data.carac));
actions.push( { name: "Draconic", data: { initOnly: true, competence: "Draconic" } } ); actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
} }
actions.push( { name: "Autre action", data: { initOnly: true, competence: "Autre action" } } ); actions.push({ name: "Autre action", data: { initOnly: true, competence: "Autre action" } });
for (let index = 0; index < actions.length; index++) { for (let index = 0; index < actions.length; index++) {
actions[index].index = index; actions[index].index = index;
} }
@ -803,34 +695,35 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static displayInitiativeMenu( html, combatantId) { static displayInitiativeMenu(html, combatantId) {
const combatant = game.combat.getCombatant(combatantId); const combatant = game.combat.getCombatant(combatantId);
let armesList = this.buildListeActionsCombat( combatant ); let armesList = this.buildListeActionsCombat(combatant);
// Build the relevant submenu // Build the relevant submenu
if ( armesList ) { if (armesList) {
let menuItems = []; let menuItems = [];
for ( let arme of armesList ) { for (let arme of armesList) {
menuItems.push( { menuItems.push({
name: arme.data.competence, name: arme.data.competence,
icon: "<i class='fas fa-dice-d6'></i>", icon: "<i class='fas fa-dice-d6'></i>",
callback: target => { RdDUtility.rollInitiativeCompetence( combatantId, arme ) } } ); callback: target => { RdDUtility.rollInitiativeCompetence(combatantId, arme) }
});
} }
new ContextMenu(html, ".directory-list", menuItems ).render(); new ContextMenu(html, ".directory-list", menuItems).render();
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static pushInitiativeOptions( html, options ) { static pushInitiativeOptions(html, options) {
options.push( options.push(
{ {
name: "Sélectionner l'initiative...", name: "Sélectionner l'initiative...",
condition: true, condition: true,
icon: '<i class="far fa-question-circle"></i>', icon: '<i class="far fa-question-circle"></i>',
callback: target => { callback: target => {
RdDUtility.displayInitiativeMenu( html, target.data('combatant-id') ); RdDUtility.displayInitiativeMenu(html, target.data('combatant-id'));
} }
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -846,23 +739,22 @@ export class RdDUtility {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static async chatListeners( html ) static async chatListeners(html) {
{
RdDCombat.registerChatCallbacks(html); RdDCombat.registerChatCallbacks(html);
// Gestion spécifique message passeurs // Gestion spécifique message passeurs
html.on("click", '.tmr-passeur-coord a', event => { html.on("click", '.tmr-passeur-coord a', event => {
let coord = event.currentTarget.attributes['data-tmr-coord'].value; let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId ); let actor = game.actors.get(actorId);
actor.tmrApp.forceDemiRevePosition(coord); actor.tmrApp.forceDemiRevePosition(coord);
}); });
// Gestion spécifique des sorts en réserve multiples (ie têtes) // Gestion spécifique des sorts en réserve multiples (ie têtes)
html.on("click", '#sort-reserve', event => { html.on("click", '#sort-reserve', event => {
let coord = event.currentTarget.attributes['data-tmr-coord'].value; let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let sortId = event.currentTarget.attributes['data-sort-id'].value; let sortId = event.currentTarget.attributes['data-sort-id'].value;
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId ); let actor = game.actors.get(actorId);
actor.tmrApp.lancerSortEnReserve(coord, sortId); actor.tmrApp.lancerSortEnReserve(coord, sortId);
}); });
// Gestion du bouton payer // Gestion du bouton payer
@ -870,28 +762,29 @@ export class RdDUtility {
let sumdenier = event.currentTarget.attributes['data-somme-denier'].value; let sumdenier = event.currentTarget.attributes['data-somme-denier'].value;
let jsondata = event.currentTarget.attributes['data-jsondata'] let jsondata = event.currentTarget.attributes['data-jsondata']
let objData let objData
if ( jsondata ) { if (jsondata) {
objData = JSON.parse(jsondata.value) objData = JSON.parse(jsondata.value)
} }
if (game.user.character ) { if (game.user.character) {
game.user.character.payerDenier(sumdenier, objData); game.user.character.payerDenier(sumdenier, objData);
} else { } else {
let msgPayer = "Vous devez avoir un acteur relié pour effectuer le paiement"; let msgPayer = "Vous devez avoir un acteur relié pour effectuer le paiement";
ChatMessage.create( { content: msgPayer, whisper: [game.user] } ); ChatMessage.create({ content: msgPayer, whisper: [game.user] });
} }
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static createMonnaie( name, valeur_deniers, img = "", enc = 0.01) { static createMonnaie(name, valeur_deniers, img = "", enc = 0.01) {
let piece = { name: name, type: 'monnaie', img: img, _id: randomID(16), let piece = {
data: { name: name, type: 'monnaie', img: img, _id: randomID(16),
quantite: 0, data: {
valeur_deniers: valeur_deniers, quantite: 0,
encombrement: enc, valeur_deniers: valeur_deniers,
description: "" encombrement: enc,
} description: ""
} }
}
return piece; return piece;
} }
@ -900,9 +793,9 @@ export class RdDUtility {
som1 = (som1) ? som1.toLowerCase() : "0d"; som1 = (som1) ? som1.toLowerCase() : "0d";
som2 = (som2) ? som2.toLowerCase() : "0d"; som2 = (som2) ? som2.toLowerCase() : "0d";
let regExp = /(\d+)(\w+)/g; let regExp = /(\d+)(\w+)/g;
let p1 = regExp.exec( som1); let p1 = regExp.exec(som1);
regExp = /(\d+)(\w+)/g; regExp = /(\d+)(\w+)/g;
let p2 = regExp.exec( som2); let p2 = regExp.exec(som2);
let sumd = 0; let sumd = 0;
let sums = 0; let sums = 0;
if (p1[2] == 'd') sumd += Number(p1[1]); if (p1[2] == 'd') sumd += Number(p1[1]);
@ -910,10 +803,10 @@ export class RdDUtility {
if (p2[2] == 'd') sumd += Number(p2[1]); if (p2[2] == 'd') sumd += Number(p2[1]);
if (p2[2] == 's') sums += Number(p2[1]); if (p2[2] == 's') sums += Number(p2[1]);
let sumtotald = sumd + (sums*100); let sumtotald = sumd + (sums * 100);
let msgPayer = "La somme de "+sums+" Sols et "+sumd+" Deniers est à payer, cliquer sur le lien ci-dessous si besoin.<br>"; let msgPayer = "La somme de " + sums + " Sols et " + sumd + " Deniers est à payer, cliquer sur le lien ci-dessous si besoin.<br>";
msgPayer += "<a id='payer-button' class='chat-card-button' data-somme-denier='"+sumtotald+"'>Payer</a>" msgPayer += "<a id='payer-button' class='chat-card-button' data-somme-denier='" + sumtotald + "'>Payer</a>"
ChatMessage.create( { content: msgPayer } ); ChatMessage.create({ content: msgPayer });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

File diff suppressed because one or more lines are too long

View File

@ -191,8 +191,8 @@
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer" src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.editCaracComp}}unlocked.svg{{else}}locked.svg{{/if}}" alt="blocker/débloquer"
>{{#if data.editCaracComp}}Vérouiller{{else}}Dévérouiller{{/if}}</a></span> >{{#if data.editCaracComp}}Vérouiller{{else}}Dévérouiller{{/if}}</a></span>
<span><a id="show-hide-competences"><img class="small-button-container" <span><a id="show-hide-competences"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.montrerCompetencesNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout" src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
>{{#if data.montrerCompetencesNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span> >{{#if data.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
<span><a id="show-hide-archetype"><img class="small-button-container" <span><a id="show-hide-archetype"><img class="small-button-container"
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.montrerArchetype}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer l'archétype" src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.montrerArchetype}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer l'archétype"
>{{#if data.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span> >{{#if data.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span>
@ -204,7 +204,7 @@
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.generale as |comp key|}} {{#each data.competenceByCategory.generale as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -227,7 +227,7 @@
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.particuliere as |comp key|}} {{#each data.competenceByCategory.particuliere as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -249,7 +249,7 @@
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.specialisee as |comp key|}} {{#each data.competenceByCategory.specialisee as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -270,11 +270,11 @@
<div class="flex-group-left flexcol competence-column"> <div class="flex-group-left flexcol competence-column">
<header class="competence-header flexrow"> <header class="competence-header flexrow">
<span class="competence-title">Compétences De Mêlée</span> <span class="competence-title">Compétences de Mêlée</span>
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.melee as |comp key|}} {{#each data.competenceByCategory.melee as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -293,11 +293,11 @@
</ul> </ul>
<header class="competence-header flexrow"> <header class="competence-header flexrow">
<span class="competence-title">Compétences De Tir</span> <span class="competence-title">Compétences de Tir</span>
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.tir as |comp key|}} {{#each data.competenceByCategory.tir as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -316,11 +316,11 @@
</ul> </ul>
<header class="competence-header flexrow"> <header class="competence-header flexrow">
<span class="competence-title">Compétences De Lancer</span> <span class="competence-title">Compétences de Lancer</span>
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.lancer as |comp key|}} {{#each data.competenceByCategory.lancer as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -343,7 +343,7 @@
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.connaissance as |comp key|}} {{#each data.competenceByCategory.connaissance as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>
@ -366,7 +366,7 @@
</header> </header>
<ul class="item-list alterne-list"> <ul class="item-list alterne-list">
{{#each data.competenceByCategory.draconic as |comp key|}} {{#each data.competenceByCategory.draconic as |comp key|}}
{{#if data.afficherCompetence}} {{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}"> <li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/> <img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span> <span class="competence-label"><a>{{comp.name}}</a></span>

View File

@ -1,17 +0,0 @@
<option value="Dague">Dague</option>
<option value="Epée à 1 main">Epée à 1 main</option>
<option value="Epée à 2 mains">Epée à 2 mains</option>
<option value="Hache à 1 main">Hache à 1 main</option>
<option value="Hache à 2 mains">Hache à 2 mains</option>
<option value="Masse à 1 main">Masse à 1 main</option>
<option value="Masse à 2 mains">Masse à 2 mains</option>
<option value="Fléau">Fléau</option>
<option value="Lance">Lance</option>
<option value="Arme d'hast">Arme d'hast</option>
<option value="Bouclier">Bouclier</option>
<option value="Arbalète">Arbalète</option>
<option value="Arc">Arc</option>
<option value="Fronde">Fronde</option>
<option value="Dague de jet">Dague de jet</option>
<option value="Javelot">Javelot</option>
<option value="Fouet">Fouet</option>

View File

@ -1,8 +0,0 @@
<option value="generale">Générale</option>
<option value="particuliere">Particulières</option>
<option value="specialisee">Spécialisées</option>
<option value="connaissance">Connaissances</option>
<option value="tir">Tir</option>
<option value="lancer">Lancer</option>
<option value="melee">Mêlée</option>
<option value="draconic">Draconic</option>

View File

@ -0,0 +1,3 @@
{{#each @root.categorieCompetences as |categorie key|}}
<option value="{{@key}}">{{categorie.label}}</option>
{{/each}}

View File

@ -0,0 +1,3 @@
{{#each @root.competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option>
{{/each}}

View File

@ -11,9 +11,9 @@
<div class="form-group"> <div class="form-group">
<label for="categorie">Compétence associée</label> <label for="categorie">Compétence associée</label>
<select name="data.competence" id="competence" data-dtype="String"> <select name="data.competence" id="competence" data-dtype="String">
{{#select item.data.competence}} {{#select item.data.competence}}
{{>"systems/foundryvtt-reve-de-dragon/templates/arme-competence.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -28,7 +28,7 @@
<label>Catégorie parade </label> <label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String"> <select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#select data.categorie_parade}} {{#select data.categorie_parade}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>

View File

@ -17,9 +17,9 @@
<div class="form-group"> <div class="form-group">
<label for="categorie">Catégorie </label> <label for="categorie">Catégorie </label>
<select name="data.categorie" id="categorie" data-dtype="String"> <select name="data.categorie" id="categorie" data-dtype="String">
{{#select item.data.categorie}} {{#select item.data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">

View File

@ -32,7 +32,7 @@
<label>Catégorie parade </label> <label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String"> <select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#select data.categorie_parade}} {{#select data.categorie_parade}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie_parade.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-parade.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>

View File

@ -37,7 +37,7 @@
<label>Catégorie</label> <label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String"> <select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}} {{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>

View File

@ -42,7 +42,7 @@
<label>Catégorie</label> <label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String"> <select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}} {{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>

View File

@ -16,7 +16,7 @@
<label for="xp">Compétence</label> <label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String"> <select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}} {{#select item.data.competence}}
{{#each competenceList as |competence key|}} {{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option> <option value="{{competence.name}}">{{competence.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}

View File

@ -12,7 +12,7 @@
<label for="xp">Compétence</label> <label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String"> <select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}} {{#select item.data.competence}}
{{#each competenceList as |competence key|}} {{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option> <option value="{{competence.name}}">{{competence.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}

View File

@ -32,7 +32,7 @@
<label>Catégorie</label> <label>Catégorie</label>
<select name="data.categorie" id="categorie" data-dtype="String"> <select name="data.categorie" id="categorie" data-dtype="String">
{{#select data.categorie}} {{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>

View File

@ -22,7 +22,7 @@
<label for="xp">Compétence</label> <label for="xp">Compétence</label>
<select name="data.competence" id="competenceselect" data-dtype="String"> <select name="data.competence" id="competenceselect" data-dtype="String">
{{#select item.data.competence}} {{#select item.data.competence}}
{{#each competenceList as |competence key|}} {{#each competences as |competence key|}}
<option value="{{competence.name}}">{{competence.name}}</option> <option value="{{competence.name}}">{{competence.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}