Ajout arme morsure au chafouin

retravail sur les competences;

- standardiser les noms de fichiers de templates
- méthodes classify pour construire une multimap par type
- méthodes pour charger les entrées du compendium
- méthodes spécifiques au compétences déplacées
This commit is contained in:
Vincent Vandemeulebrouck 2021-01-08 22:23:50 +01:00
parent 4dbab303f3
commit a338bb144e
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 { RdDItem } from "./item.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
export class RdDActorSheet extends ActorSheet {
/** @override */
static get defaultOptions() {
static get defaultOptions() {
RdDUtility.initAfficheContenu();
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html",
width: 640,
//height: 720,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}],
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}],
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editCaracComp: false,
montrerCompetencesNiveauBase: false,
showCompNiveauBase: false,
montrerArchetype: false
});
}
@ -32,79 +33,67 @@ export class RdDActorSheet extends ActorSheet {
let data = super.getData();
if ( data.actor.type == 'creature' || data.actor.type == 'humanoide') return data; // Shortcut
data.data.editCaracComp = this.options.editCaracComp;
data.data.montrerCompetencesNiveauBase = this.options.montrerCompetencesNiveauBase;
data.data.editCaracComp = this.options.editCaracComp;
data.data.showCompNiveauBase = this.options.showCompNiveauBase;
data.data.montrerArchetype = this.options.montrerArchetype;
let compCategorieNiveau = RdDUtility.getLevelCategory(); // recup catégorie
data.itemsByType = RdDItem.buildItemsClassification(data.items);
// Competence per category
data.competenceByCategory = {};
let competenceXPTotal = 0;
if (data.itemsByType.competence) {
for (const item of data.itemsByType.competence) {
this.actor.checkCompetenceXP( item.name ); // Petite vérification experience
//console.log("Push...", item, item.data.categorie);
let list = data.competenceByCategory[item.data.categorie];
if (!list) {
list = [];
data.competenceByCategory[item.data.categorie] = list;
}
if (!RdDUtility.isTronc( item.name ) ) // Ignorer les compétences 'troncs' à ce stade
competenceXPTotal += RdDUtility.computeCompetenceXPCost(item);
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.competenceByCategory = RdDItem.classify(
data.itemsByType.competence,
item => item.data.categorie,
item => {
this.actor.checkCompetenceXP(item.name); // Petite vérification experience
item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie)));
// Ignorer les compétences 'troncs' à ce stade
competenceXPTotal += RdDItemCompetence.isTronc(item.name) ? 0 : RdDItemCompetence.computeCompetenceXPCost(item);
return item;
});
competenceXPTotal += RdDItemCompetence.computeCompetenceTroncXP(data.itemsByType.competence);
data.data.competenceXPTotal = competenceXPTotal;
//console.log("XP competence : ", competenceXPTotal);
// Compute current carac sum
let sum = 0;
for (let caracName in data.data.carac) {
let carac = data.data.carac[caracName];
if (!carac.derivee) {
sum += parseInt(carac.value);
let currentCarac = data.data.carac[caracName];
if (!currentCarac.derivee) {
sum += parseInt(currentCarac.value);
}
}
data.data.caracSum = sum;
// 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) {
arme.data.niveau = 0; // Per default, TODO to be fixed
for ( const melee of data.competenceByCategory.melee ) {
if (melee.name == arme.data.competence )
for (const melee of data.competenceByCategory.melee) {
if (melee.name == arme.data.competence)
arme.data.niveau = melee.data.niveau
}
for ( const tir of data.competenceByCategory.tir ) {
if (tir.name == arme.data.competence )
for (const tir of data.competenceByCategory.tir) {
if (tir.name == arme.data.competence)
arme.data.niveau = tir.data.niveau
}
for ( const lancer of data.competenceByCategory.lancer ) {
if (lancer.name == arme.data.competence )
for (const lancer of data.competenceByCategory.lancer) {
if (lancer.name == arme.data.competence)
arme.data.niveau = lancer.data.niveau
}
}
// To avoid armour and so on...
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 = duplicate(RdDUtility.checkNull(data.itemsByType['arme']));
data.data.combat = RdDUtility._finalizeArmeList(data.data.combat, data.itemsByType.competence, data.data.carac);
if (data.competenceByCategory && data.competenceByCategory.melee) {
//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")
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") {
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.
data.data.fatigue = {
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>"
}
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>"
}
RdDUtility.filterItemsPerTypeForSheet(data );
data.data.sortReserve = data.data.reve.reserve.list;
RdDUtility.filterItemsPerTypeForSheet(data);
data.data.sortReserve = data.data.reve.reserve.list;
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!" : "";
return data;
}
/* -------------------------------------------- */
async _onDrop(event) {
await RdDUtility.processItemDropEvent(this, event);
@ -187,41 +175,41 @@ export class RdDActorSheet extends ActorSheet {
}
/* -------------------------------------------- */
async createEmptyTache( ) {
await this.actor.createOwnedItem( { name: 'Nouvelle tache', type: 'tache'}, { renderSheet: true } );
async createEmptyTache() {
await this.actor.createOwnedItem({ name: 'Nouvelle tache', type: 'tache' }, { renderSheet: true });
}
/* -------------------------------------------- */
async creerObjet( ) {
async creerObjet() {
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 options = '<span class="competence-label">Selectionnez le type d\'équipement</span><select id="creer-equipement">';
for( let typeName of itemType) {
options += '<option value="'+typeName+'">'+typeName+'</option>'
for (let typeName of itemType) {
options += '<option value="' + typeName + '">' + typeName + '</option>'
}
options += '</select>';
let d = new Dialog( {
title: "Créer un équipement",
content: options,
buttons: {
one: {
let d = new Dialog({
title: "Créer un équipement",
content: options,
buttons: {
one: {
icon: '<i class="fas fa-check"></i>',
label: "Créer l'objet",
callback: () => this.creerObjet()
}
}
});
}
});
d.render(true);
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
activateListeners(html) {
super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
@ -239,7 +227,7 @@ export class RdDActorSheet extends ActorSheet {
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.confirmerSuppression( li );
this.confirmerSuppression(li);
});
html.find('#encaisser-direct').click(ev => {
@ -263,25 +251,25 @@ export class RdDActorSheet extends ActorSheet {
// Blessure control
html.find('.blessure-control').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let btype = li.data("blessure-type");
let index = li.data('blessure-index');
const li = $(ev.currentTarget).parents(".item");
let btype = li.data("blessure-type");
let index = li.data('blessure-index');
let active = $(ev.currentTarget).data('blessure-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
html.find('.blessures-soins').change(ev => {
const li = $(ev.currentTarget).parents(".item");
let btype = li.data('blessure-type');
let index = li.data('blessure-index');
let psoins = li.find('input[name=premiers_soins]').val();
const li = $(ev.currentTarget).parents(".item");
let btype = li.data('blessure-type');
let index = li.data('blessure-index');
let psoins = li.find('input[name=premiers_soins]').val();
let pcomplets = li.find('input[name=soins_complets]').val();
let jours = li.find('input[name=jours]').val();
let loc = li.find('input[name=localisation]').val();
let jours = li.find('input[name=jours]').val();
let loc = li.find('input[name=localisation]').val();
//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
@ -294,11 +282,11 @@ export class RdDActorSheet extends ActorSheet {
// Roll Carac
html.find('.carac-label a').click((event) => {
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac( caracName.toLowerCase() );
this.actor.rollCarac(caracName.toLowerCase());
});
html.find('#chance-actuelle').click((event) => {
this.actor.rollCarac( 'chance-actuelle' );
this.actor.rollCarac('chance-actuelle');
});
html.find('#chance-appel').click((event) => {
@ -312,22 +300,22 @@ export class RdDActorSheet extends ActorSheet {
// Roll Skill
html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text;
this.actor.rollCompetence( compName);
this.actor.rollCompetence(compName);
});
html.find('.tache-label a').click((event) => {
const li = $(event.currentTarget).parents(".item");
let tacheId = li.data('item-id');
this.actor.rollTache( tacheId );
const li = $(event.currentTarget).parents(".item");
let tacheId = li.data('item-id');
this.actor.rollTache(tacheId);
});
html.find('.meditation-label a').click((event) => {
const li = $(event.currentTarget).parents(".item");
let meditationId = li.data('item-id');
this.actor.rollMeditation( meditationId );
const li = $(event.currentTarget).parents(".item");
let meditationId = li.data('item-id');
this.actor.rollMeditation(meditationId);
});
// Points de reve actuel
html.find('.ptreve-actuel a').click((event) => {
this.actor.rollCarac( 'reve-actuel' );
this.actor.rollCarac('reve-actuel');
});
// Roll Weapon1
@ -338,28 +326,28 @@ export class RdDActorSheet extends ActorSheet {
});
// Initiative pour l'arme
html.find('.arme-initiative a').click((event) => {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id );
if ( combatant ) {
let combatant = game.combat.data.combatants.find(c => c.actor.data._id == this.actor.data._id);
if (combatant) {
let armeName = event.currentTarget.attributes['data-arme-name'].value;
let arme = this.armesList.find( a => a.name == armeName);
RdDUtility.rollInitiativeCompetence( combatant._id, arme);
let arme = this.armesList.find(a => a.name == armeName);
RdDUtility.rollInitiativeCompetence(combatant._id, arme);
} else {
ui.notifications.info("Impossible de lancer l'initiative sans être dans un combat.");
}
});
// Display TMR, visuualisation
html.find('#visu-tmr').click((event) => {
this.actor.displayTMR( "visu");
this.actor.displayTMR("visu");
});
// Display TMR, normal
html.find('#monte-tmr').click((event) => {
this.actor.displayTMR( "normal" );
this.actor.displayTMR("normal");
});
// Display TMR, fast
html.find('#monte-tmr-rapide').click((event) => {
this.actor.displayTMR( "rapide" );
this.actor.displayTMR("rapide");
});
html.find('#dormir-une-heure').click((event) => {
@ -391,7 +379,7 @@ export class RdDActorSheet extends ActorSheet {
// Display info about queue
html.find('.conteneur-name a').click((event) => {
let myID = event.currentTarget.attributes['data-item-id'].value;
RdDUtility.toggleAfficheContenu( myID );
RdDUtility.toggleAfficheContenu(myID);
this.render(true);
});
@ -400,29 +388,29 @@ export class RdDActorSheet extends ActorSheet {
html.find('.carac-value').change((event) => {
let caracName = event.currentTarget.name.replace(".value", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName);
this.actor.updateCarac( caracName, parseInt(event.target.value) );
} );
this.actor.updateCarac(caracName, parseInt(event.target.value));
});
html.find('.carac-xp').change((event) => {
let caracName = event.currentTarget.name.replace(".xp", "").replace("data.carac.", "");
//console.log("Value changed :", event, caracName);
this.actor.updateCaracXP( caracName, parseInt(event.target.value) );
} );
this.actor.updateCaracXP(caracName, parseInt(event.target.value));
});
// On competence change
html.find('.competence-value').change((event) => {
let compName = event.currentTarget.attributes.compname.value;
//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
html.find('.competence-xp').change((event) => {
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
html.find('.competence-archetype').change((event) => {
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
@ -431,7 +419,7 @@ export class RdDActorSheet extends ActorSheet {
this.render(true);
});
html.find('#show-hide-competences').click((event) => {
this.options.montrerCompetencesNiveauBase = !this.options.montrerCompetencesNiveauBase;
this.options.showCompNiveauBase = !this.options.showCompNiveauBase;
this.render(true);
});
html.find('#show-hide-archetype').click((event) => {
@ -442,30 +430,30 @@ export class RdDActorSheet extends ActorSheet {
// On pts de reve change
html.find('.pointsreve-value').change((event) => {
let reveValue = event.currentTarget.value;
let reve = duplicate( this.actor.data.data.reve.reve );
let reve = duplicate(this.actor.data.data.reve.reve);
reve.value = reveValue;
this.actor.update( { "data.reve.reve": reve } );
} );
this.actor.update({ "data.reve.reve": reve });
});
// On seuil de reve change
html.find('.seuil-reve-value').change((event) => {
console.log("seuil-reve-value", event.currentTarget)
this.actor.setPointsDeSeuil(event.currentTarget.value);
} );
});
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
html.find('.compteur-edit').change((event) => {
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) => {
this.actor.setEthylisme(parseInt(event.target.value) );
} );
this.actor.setEthylisme(parseInt(event.target.value));
});
html.find('#stress-test').click((event) => {
this.actor.stressTest();
this.render(true);
@ -494,12 +482,12 @@ export class RdDActorSheet extends ActorSheet {
html.find('.monnaie-plus').click((event) => {
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);
});
html.find('.monnaie-moins').click((event) => {
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);
});
@ -541,7 +529,7 @@ export class RdDActorSheet extends ActorSheet {
/* -------------------------------------------- */
/** @override */
setPosition(options={}) {
setPosition(options = {}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
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 (data.items) {
let actor = super.create(data, options);
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 = "";
if (data.type == "personnage") {
compendiumName = "foundryvtt-reve-de-dragon.competences";
@ -61,16 +61,7 @@ export class RdDActor extends Actor {
} else if (data.type == "entite") {
compendiumName = "foundryvtt-reve-de-dragon.competences-entites";
}
let competences = [];
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);
}
data.items = RdDUtility.loadCompendium(compendiumName);
// Ajout monnaie
if (data.type == "personnage" ) {
await RdDActor.ajouterMonnaie( data.items );
@ -207,12 +198,12 @@ export class RdDActor extends Actor {
return this.data.data.compteurs?.surenc?.value ?? 0;
}
/* -------------------------------------------- */
getCompetenceList() {
loadCompendiumNames() {
return this.data.items.filter( (item) => item.type == 'competence');
}
/* -------------------------------------------- */
getCompetence(compName) {
return RdDUtility.findCompetence(this.data.items, compName);
return RdDItemCompetence.findCompetence(this.data.items, compName);
}
/* -------------------------------------------- */
getTache( id ) {
@ -1413,9 +1404,9 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
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) {
let xpNeeded = RdDUtility.getCompetenceNextXp( competence.data.niveau );
let xpNeeded = RdDItemCompetence.getCompetenceNextXp( competence.data.niveau );
if ( competence.data.xp >= xpNeeded ) {
competence.data.xp -= xpNeeded;
competence.data.niveau += 1;
@ -1937,7 +1928,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async ajouteNombreAstral( data ) {
// 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"];
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 {
/* -------------------------------------------- */
static isCompetenceMelee(name) {
return name.toLowerCase().match(/(epée|épée|hache|fleau|fléau|masse|lance|hast|dague|bouclier)/);
static isCompetenceArme(competence) {
switch (competence.data.categorie) {
case 'melee':
return competence.name.toLowerCase() != 'esquive';
case 'tir':
case 'lancer':
return true;
}
return false;
}
/* -------------------------------------------- */
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) {
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/);
return competence?.name.toLowerCase().match(/(natation|acrobatie)/);
}
/* -------------------------------------------- */
static setRollDataCreature(rollData) {
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
rollData.competence = duplicate(rollData.competence);
@ -19,4 +39,65 @@ export class RdDItemCompetence extends Item {
rollData.competence.data.categorie = "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 { RdDItem } from "./item-rdd.js";
import { RdDAlchimie } from "./rdd-alchimie.js";
import { RdDItemCompetence } from "./item-competence.js";
/**
* Extend the basic ItemSheet with some very simple modifications
@ -47,10 +48,13 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
let data = super.getData();
data.categorieCompetences = RdDUtility.getCategorieCompetences();
if ( data.item.type == 'tache' || data.item.type == 'livre' || data.item.type == 'meditation') {
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' ) {
RdDAlchimie.processManipulation(data.item, this.actor && this.actor._id );
@ -101,8 +105,7 @@ export class RdDItemSheet extends ItemSheet {
async _onClickSelectCategorie(event) {
event.preventDefault();
const category = event.currentTarget.value;
let level = CONFIG.RDD.level_category[category];
let level = RdDUtility.getLevelCategory(event.currentTarget.value);
this.object.data.data.base = level;
$("#base").val( level );
}

View File

@ -3,16 +3,26 @@
export class RdDItem {
/* -------------------------------------------- */
static buildItemsClassification( items ) {
let itemsByType = {};
static buildItemsClassification(items) {
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) {
let list = itemsByType[item.type];
const classification = classifier(item);
let list = itemsBy[classification];
if (!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 { RdDCalendrier } from "./rdd-calendrier.js";
import { RdDUtility } from "./rdd-utility.js";
@ -15,7 +16,7 @@ export class RdDAstrologieJoueur extends Dialog {
dates: game.system.rdd.calendrier.getJoursSuivants( 10 ),
etat: actor.getEtatGeneral(),
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);
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 { RdDCombat } from "./rdd-combat.js";
import { ChatUtility } from "./chat-utility.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -65,7 +66,7 @@ const _patch_initiative = () => {
}
}
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);
}
}
@ -190,7 +191,6 @@ Hooks.once("init", async function() {
CONFIG.Actor.entityClass = RdDActor;
CONFIG.RDD = {
resolutionTable : RdDResolutionTable.resolutionTable,
level_category : RdDUtility.getLevelCategory(),
carac_array : RdDUtility.getCaracArray(),
ajustementsConditions : RdDUtility.getAjustementsConditions(),
difficultesLibres : RdDUtility.getDifficultesLibres()

View File

@ -6,46 +6,26 @@ import { RdDCombat } from "./rdd-combat.js";
import { RdDRollResolutionTable } from "./rdd-roll-resolution-table.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
import { RdDItemArme } from "./item-arme.js";
import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
const level_category = {
"generale": "-4",
"particuliere": "-8",
"specialisee": "-11",
"connaissance": "-11",
"draconic": "-11",
"melee": "-6",
"tir": "-8",
"lancer": "-8"
}
/* -------------------------------------------- */
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]
const categorieCompetences = {
"generale": { level: "-4", label: "Générales" },
"particuliere": { level: "-8", label: "Particulières" },
"specialisee": { level: "-11", label: "Spécialisées" },
"connaissance": { level: "-11", label: "Connaissances" },
"draconic": { level: "-11", label: "Draconics" },
"melee": { level: "-6", label: "Mêlée" },
"tir": { level: "-8", label: "Tir" },
"lancer": { level: "-8", label: "Lancer" }
}
/* -------------------------------------------- */
// 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 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 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_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 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 carac_xp_par_valeur = [6, 6, 7, 7, 8, 8, 9, 9, 10, 20, 30, 40, 50, 60, 70];
const XP_CARAC_OFFSET = 7;
@ -54,12 +34,12 @@ function _buildAllSegmentsFatigue(max) {
const cycle = [5, 2, 4, 1, 3, 0];
let fatigue = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
for (let i = 0; i <= max; i++) {
const ligneFatigue= duplicate(fatigue[i]);
const ligneFatigue = duplicate(fatigue[i]);
const caseIncrementee = cycle[i % 6];
ligneFatigue[caseIncrementee]++;
ligneFatigue[caseIncrementee + 6]++;
ligneFatigue.fatigueMax = 2 * (i + 1);
fatigue[i + 1] = ligneFatigue ;
fatigue[i + 1] = ligneFatigue;
}
return fatigue;
@ -68,8 +48,7 @@ function _buildAllSegmentsFatigue(max) {
/* -------------------------------------------- */
function _cumulSegmentsFatigue(matrix) {
let cumulMatrix = [];
for (let line of matrix)
{
for (let line of matrix) {
let cumul = duplicate(line);
for (let i = 1; i < 12; i++) {
@ -84,33 +63,37 @@ function _cumulSegmentsFatigue(matrix) {
const fatigueMatrix = _buildAllSegmentsFatigue(60);
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 fatigueLineSize = [ 3, 6, 7, 8, 9, 10, 11, 12];
const fatigueLineMalus = [ 0, -1, -2, -3, -4, -5, -6, -7 ];
const fatigueMarche = { "aise": { "4":1, "6":2, "8":3, "10":4, "12":6 },
"malaise": { "4":2, "6":3, "8":4, "10":6 },
"difficile": { "4":3, "6":4, "8":6 },
"tresdifficile": { "4":4, "6":6 } }
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 fatigueLineMalus = [0, -1, -2, -3, -4, -5, -6, -7];
const fatigueMarche = {
"aise": { "4": 1, "6": 2, "8": 3, "10": 4, "12": 6 },
"malaise": { "4": 2, "6": 3, "8": 4, "10": 6 },
"difficile": { "4": 3, "6": 4, "8": 6 },
"tresdifficile": { "4": 4, "6": 6 }
}
/* -------------------------------------------- */
/* Static tables for commands /table */
const table2func = { "rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open },
"queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue},
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
"tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR},
"tete" : { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete},
"souffle": { descr: "souffle: Tire un Souffle de Dragon", func: RdDRollTables.getSouffle},
"tarot" : { descr: "tarot: Tire une carte de Tarot Dracnique", func: RdDRollTables.getTarot} };
/* Static tables for commands /table */
const table2func = {
"rdd": { descr: "rdd: Ouvre la table de résolution", func: RdDRollResolutionTable.open },
"queues": { descr: "queues: Tire une queue de Dragon", func: RdDRollTables.getQueue },
"ombre": { descr: "ombre: Tire une Ombre de Dragon", func: RdDRollTables.getOmbre },
"tetehr": { descr: "tetehr: Tire une Tête de Dragon pour Hauts Revants", fund: RdDRollTables.getTeteHR },
"tete": { descr: "tete: Tire une Tête de Dragon", func: RdDRollTables.getTete },
"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 = [
{ type: "legere", facteur: 2 },
{ type: "grave", facteur : 4 },
{ type: "critique", facteur : 6 }
{ type: "grave", facteur: 4 },
{ 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 = {
@ -138,9 +121,9 @@ const definitionsEncaissement = {
};
/* -------------------------------------------- */
export class RdDUtility {
export class RdDUtility {
/* -------------------------------------------- */
static async preloadHandlebarsTemplates( ) {
static async preloadHandlebarsTemplates() {
const templatePaths = [
//Character Sheets
'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-monnaie-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-base.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_parade.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-categorie-competence.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/arme-competence.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/niveau-ethylisme.html',
@ -234,46 +217,46 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static getNomEthylisme( niveauEthylisme ) {
static getNomEthylisme(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
if ( !this.afficheContenu )
static initAfficheContenu(actorId) { // persistent handling of conteneur show/hide
if (!this.afficheContenu)
this.afficheContenu = {};
}
/* -------------------------------------------- */
static toggleAfficheContenu( conteneurId) {
static toggleAfficheContenu(conteneurId) {
this.afficheContenu[conteneurId] = !this.afficheContenu[conteneurId];
}
/* -------------------------------------------- */
static getAfficheContenu( conteneurId) {
static getAfficheContenu(conteneurId) {
return this.afficheContenu[conteneurId];
}
/* -------------------------------------------- */
static filterItemsPerTypeForSheet( data ) {
data.data.materiel = this.checkNull(data.itemsByType['objet']);
data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']);
data.data.armes = this.checkNull(data.itemsByType['arme']);
data.data.armures = this.checkNull(data.itemsByType['armure']);
data.data.livres = this.checkNull(data.itemsByType['livre']);
data.data.potions = this.checkNull(data.itemsByType['potion']);
static filterItemsPerTypeForSheet(data) {
data.data.materiel = this.checkNull(data.itemsByType['objet']);
data.data.conteneurs = this.checkNull(data.itemsByType['conteneur']);
data.data.armes = this.checkNull(data.itemsByType['arme']);
data.data.armures = this.checkNull(data.itemsByType['armure']);
data.data.livres = this.checkNull(data.itemsByType['livre']);
data.data.potions = this.checkNull(data.itemsByType['potion']);
data.data.ingredients = this.checkNull(data.itemsByType['ingredient']);
data.data.munitions = this.checkNull(data.itemsByType['munition']);
data.data.herbes = this.checkNull(data.itemsByType['herbe']);
data.data.sorts = this.checkNull(data.itemsByType['sort']);
data.data.queues = this.checkNull(data.itemsByType['queue']);
data.data.souffles = this.checkNull(data.itemsByType['souffle']);
data.data.ombres = this.checkNull(data.itemsByType['ombre']);
data.data.tetes = this.checkNull(data.itemsByType['tete']);
data.data.taches = this.checkNull(data.itemsByType['tache']);
data.data.monnaie = this.checkNull(data.itemsByType['monnaie']);
data.data.munitions = this.checkNull(data.itemsByType['munition']);
data.data.herbes = this.checkNull(data.itemsByType['herbe']);
data.data.sorts = this.checkNull(data.itemsByType['sort']);
data.data.queues = this.checkNull(data.itemsByType['queue']);
data.data.souffles = this.checkNull(data.itemsByType['souffle']);
data.data.ombres = this.checkNull(data.itemsByType['ombre']);
data.data.tetes = this.checkNull(data.itemsByType['tete']);
data.data.taches = this.checkNull(data.itemsByType['tache']);
data.data.monnaie = this.checkNull(data.itemsByType['monnaie']);
data.data.meditations = this.checkNull(data.itemsByType['meditation']);
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);
}
/* -------------------------------------------- */
@ -302,19 +285,19 @@ export class RdDUtility {
//conteneur.data.encTotal = ; Deja calculé
if (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.data.encombrement) objet.data.encombrement = 0; // Auto-fix
objet.estContenu = true; // Permet de filtrer ce qifui est porté dans le template
actorSheet.objetVersConteneur[id] = conteneur._id;
conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite)?objet.data.quantite:1));
conteneur.subItems.push( objet );
conteneur.data.encTotal += Number(objet.data.encombrement) * Number(((objet.data.quantite) ? objet.data.quantite : 1));
conteneur.subItems.push(objet);
}
}
}
}
// 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;
//console.log(newConteneurs);
}
@ -323,20 +306,20 @@ export class RdDUtility {
/** Construit la structure récursive des conteneurs, avec imbrication potentielle
*
*/
static buildConteneur( objet, niveau ) {
static buildConteneur(objet, niveau) {
if (!niveau) niveau = 1;
objet.niveau = niveau;
//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') {
//console.log("ITEM DISPLAYED", this.getAfficheContenu(objet._id) );
if ( this.getAfficheContenu(objet._id) ) {
str = str + "<ul class='item-list alterne-list item-display-show list-item-margin"+niveau+"'>";
if (this.getAfficheContenu(objet._id)) {
str = str + "<ul class='item-list alterne-list item-display-show list-item-margin" + niveau + "'>";
} 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) {
str = str + this.buildConteneur(subItem, niveau+1);
str = str + this.buildConteneur(subItem, niveau + 1);
}
str = str + "</ul>";
}
@ -344,146 +327,51 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static buildResolutionTable( ) {
let tableRes = []
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 getCategorieCompetences() {
return categorieCompetences;
}
/* -------------------------------------------- */
static getLevelCategory( )
{
return level_category;
static getLevelCategory(category) {
return categorieCompetences[category].level;
}
static getLabelCategory( )
{
return label_category;
static getLabelCategory(category) {
return categorieCompetences[category].label;
}
static getCaracArray()
{
static getCaracArray() {
return carac_array;
}
static getDifficultesLibres()
{
static getDifficultesLibres() {
return difficultesLibres;
}
static getAjustementsConditions()
{
static getAjustementsConditions() {
return ajustementsConditions;
}
static getAjustementsEncaissement()
{
static getAjustementsEncaissement() {
return ajustementsEncaissement;
}
static getDefinitionsBlessures() {
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];
}
/* -------------------------------------------- */
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 */
static _finalizeArmeList( armes, competenceList, carac ) {
static _finalizeArmeList(armes, competences, carac) {
// Gestion des armes 1/2 mains
let armesEquipe = [];
for (const arme of armes) {
if (arme.data.equipe) {
armesEquipe.push( arme );
let comp = competenceList.find(c => c.name == arme.data.competence);
armesEquipe.push(arme);
let comp = competences.find(c => c.name == arme.data.competence);
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
if (arme.data.unemain && !arme.data.deuxmains ) {
if (arme.data.unemain && !arme.data.deuxmains) {
arme.data.mainInfo = "(1m)";
} else if ( !arme.data.unemain && arme.data.deuxmains ) {
} else if (!arme.data.unemain && arme.data.deuxmains) {
arme.data.mainInfo = "(2m)";
} else if (arme.data.unemain && arme.data.deuxmains) {
arme.data.mainInfo = "(1m)";
@ -491,35 +379,34 @@ export class RdDUtility {
arme2main.data.mainInfo = "(2m)";
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 !
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.initiative = RdDUtility.calculInitiative(arme2main.data.niveau, carac[comp.data.defaut_carac].value);
armesEquipe.push(arme2main);
}
}
}
return armesEquipe.sort((a, b) => {
return armesEquipe.sort((a, b) => {
const nameA = a.name + (a.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;
} );
});
}
/* -------------------------------------------- */
static calculInitiative(niveau, caracValue) {
let base = niveau + Math.floor(caracValue/2);
let base = niveau + Math.floor(caracValue / 2);
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.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
data.attributs.plusdom.value = 2
@ -531,30 +418,30 @@ export class RdDUtility {
data.attributs.plusdom.value = 1;
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.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.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.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.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.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.attributs.sconst.value = 5; // Max !
if ( data.carac.constitution.value < 9 )
if (data.carac.constitution.value < 9)
data.attributs.sconst.value = 2;
else if (data.carac.constitution.value < 12 )
else if (data.carac.constitution.value < 12)
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.sust.value = 4; // Max !
if ( data.carac.taille.value < 10 )
if (data.carac.taille.value < 10)
data.attributs.sust.value = 2;
else if (data.carac.taille.value < 14 )
else if (data.carac.taille.value < 14)
data.attributs.sust.value = 3;
//Compteurs
@ -572,12 +459,11 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static calculMalusFatigue(fatigue, maxEnd)
{
static calculMalusFatigue(fatigue, maxEnd) {
maxEnd = Math.max(maxEnd, 1);
maxEnd = Math.min(maxEnd, cumulFatigueMatrix.length);
let segments = cumulFatigueMatrix[maxEnd];
for (let i=0; i<12; i++) {
for (let i = 0; i < 12; i++) {
if (fatigue <= segments[i]) {
return fatigueMalus[i]
}
@ -587,7 +473,7 @@ export class RdDUtility {
/* -------------------------------------------- */
// Build the nice (?) html table used to manage fatigue.
// max should be the endurance max value
static makeHTMLfatigueMatrix( fatigue, maxEndurance) {
static makeHTMLfatigueMatrix(fatigue, maxEndurance) {
let segments = this.getSegmentsFatigue(maxEndurance);
return this.makeHTMLfatigueMatrixForSegment(fatigue, segments);
}
@ -627,25 +513,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?
let result = new Roll("1d20").roll().total;
let txt = ""
if ( result <= 3 ) txt = "Jambe, genou, pied, jarret";
else if ( result <= 7 ) txt = "Hanche, cuisse, fesse";
else if ( result <= 9 ) txt = "Ventre, reins";
else if ( result <= 12 ) txt = "Poitrine, dos";
else if ( result <= 14 ) txt = "Avant-bras, main, coude";
else if ( result <= 18 ) txt = "Epaule, bras, omoplate";
else if ( result == 19) txt = "Tête";
else if ( result == 20) txt = "Tête (visage)";
if (result <= 3) txt = "Jambe, genou, pied, jarret";
else if (result <= 7) txt = "Hanche, cuisse, fesse";
else if (result <= 9) txt = "Ventre, reins";
else if (result <= 12) txt = "Poitrine, dos";
else if (result <= 14) txt = "Avant-bras, main, coude";
else if (result <= 18) txt = "Epaule, bras, omoplate";
else if (result == 19) txt = "Tête";
else if (result == 20) txt = "Tête (visage)";
return { result: result, label: txt };
}
/* -------------------------------------------- */
static selectEncaissement( degats, mortalite ) {
static selectEncaissement(degats, mortalite) {
const table = definitionsEncaissement[mortalite] === undefined ? definitionsEncaissement["mortel"] : definitionsEncaissement[mortalite];
for (let encaissement of table) {
if ((encaissement.minimum === undefined || encaissement.minimum <= degats)
@ -659,23 +544,22 @@ export class RdDUtility {
/* -------------------------------------------- */
static _evaluatePerte(formula, over20) {
console.log("_evaluatePerte", formula, over20 )
let perte = new Roll(formula, { over20:over20})
console.log("_evaluatePerte", formula, over20)
let perte = new Roll(formula, { over20: over20 })
perte.evaluate()
return perte.total
}
/* -------------------------------------------- */
static currentFatigueMalus( value, max)
{
static currentFatigueMalus(value, max) {
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 fatigueRem = value;
for (let idx=0; idx<fatigueTab.length; idx++) {
for (let idx = 0; idx < fatigueTab.length; idx++) {
fatigueRem -= fatigueTab[idx];
if ( fatigueRem <= 0) {
if (fatigueRem <= 0) {
return fatigueMalus[idx];
}
}
@ -683,43 +567,51 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static findCompetence(compList, compName)
{
compName = compName.toLowerCase();
return compList.find(item => item.name.toLowerCase() == compName && (item.type =="competence" || item.type == "competencecreature"))
}
/* -------------------------------------------- */
static async getCompetenceList( compendium ) {
static async loadCompendiumNames(compendium) {
const pack = game.packs.get(compendium);
let competences;
await pack.getIndex().then(index => competences = index);
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 ) {
let actor = game.actors.get( data.id);
static async responseNombreAstral(data) {
let actor = game.actors.get(data.id);
actor.ajouteNombreAstral(data);
}
/* -------------------------------------------- */
static performSocketMesssage( sockmsg )
{
static performSocketMesssage(sockmsg) {
console.log(">>>>> MSG RECV", sockmsg);
switch(sockmsg.msg) {
case "msg_encaisser":
switch (sockmsg.msg) {
case "msg_encaisser":
return RdDUtility._handleMsgEncaisser(sockmsg.data);
case "msg_defense" :
case "msg_defense":
return RdDUtility._handleMsgDefense(sockmsg.data);
case "msg_gm_chat_message":
return ChatUtility.handleGMChatMessage(sockmsg.data);
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":
return game.system.rdd.calendrier.requestNombreAstral( sockmsg.data );
return game.system.rdd.calendrier.requestNombreAstral(sockmsg.data);
case "msg_response_nombre_astral":
return RdDUtility.responseNombreAstral( sockmsg.data );
return RdDUtility.responseNombreAstral(sockmsg.data);
}
}
@ -727,7 +619,7 @@ export class RdDUtility {
static _handleMsgDefense(data) {
let defenderToken = canvas.tokens.get(data.defenderTokenId);
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.");
return;
}
@ -743,58 +635,58 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static rollInitiativeCompetence( combatantId, arme ) {
static rollInitiativeCompetence(combatantId, arme) {
const combatant = game.combat.getCombatant(combatantId);
const actor = combatant.actor;
if ( arme.name == "Autre action") {
game.combat.rollInitiative(combatantId, "1d6" );
} else if ( arme.name == "Draconic") {
game.combat.rollInitiative(combatantId, "1d6+200" );
if (arme.name == "Autre action") {
game.combat.rollInitiative(combatantId, "1d6");
} else if (arme.name == "Draconic") {
game.combat.rollInitiative(combatantId, "1d6+200");
} else {
let initOffset = 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;
} else {
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer" ) { // Offset de principe pour les armes de jet
initOffset = 40;
}
if (competence.data.categorie == "tir" ) { // Offset de principe pour les armes de jet
initOffset = 80;
}
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
initOffset = 40;
}
if (competence.data.categorie == "tir") { // Offset de principe pour les armes de jet
initOffset = 80;
}
}
initOffset -= actor.getEtatGeneral(); // Prise en compte état général
// Cas des créatures et entités vs personnages
let rollFormula = RdDUtility.calculInitiative(competence.data.niveau, caracForInit) + "+" + initOffset;
game.combat.rollInitiative(combatantId, rollFormula );
// Cas des créatures et entités vs personnages
let rollFormula = RdDUtility.calculInitiative(competence.data.niveau, caracForInit) + "+" + initOffset;
game.combat.rollInitiative(combatantId, rollFormula);
}
}
/* -------------------------------------------- */
static buildListeActionsCombat( combatant ) {
static buildListeActionsCombat(combatant) {
const actor = combatant.actor; // Easy access
let items = actor.data.items;
let actions = []
if ( actor.isCreature()) {
actions = actions.concat(items.filter(it => it.type =='competencecreature' && it.data.iscombat)
if (actor.isCreature()) {
actions = actions.concat(items.filter(it => it.type == 'competencecreature' && it.data.iscombat)
.map(competence => RdDItemCompetenceCreature.toArme(competence)));
} else {
// 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 */
.concat(RdDItemArme.mainsNues());
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++) {
actions[index].index = index;
}
@ -802,34 +694,35 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static displayInitiativeMenu( html, combatantId) {
static displayInitiativeMenu(html, combatantId) {
const combatant = game.combat.getCombatant(combatantId);
let armesList = this.buildListeActionsCombat( combatant );
let armesList = this.buildListeActionsCombat(combatant);
// Build the relevant submenu
if ( armesList ) {
if (armesList) {
let menuItems = [];
for ( let arme of armesList ) {
menuItems.push( {
for (let arme of armesList) {
menuItems.push({
name: arme.data.competence,
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(
{
name: "Sélectionner l'initiative...",
condition: true,
icon: '<i class="far fa-question-circle"></i>',
callback: target => {
RdDUtility.displayInitiativeMenu( html, target.data('combatant-id') );
RdDUtility.displayInitiativeMenu(html, target.data('combatant-id'));
}
});
});
}
/* -------------------------------------------- */
@ -845,23 +738,22 @@ export class RdDUtility {
}
/* -------------------------------------------- */
static async chatListeners( html )
{
static async chatListeners(html) {
RdDCombat.registerChatCallbacks(html);
// Gestion spécifique message passeurs
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 actor = game.actors.get( actorId );
let actor = game.actors.get(actorId);
actor.tmrApp.forceDemiRevePosition(coord);
});
// Gestion spécifique des sorts en réserve multiples (ie têtes)
html.on("click", '#sort-reserve', event => {
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let sortId = event.currentTarget.attributes['data-sort-id'].value;
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
let sortId = event.currentTarget.attributes['data-sort-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);
});
// Gestion du bouton payer
@ -869,28 +761,29 @@ export class RdDUtility {
let sumdenier = event.currentTarget.attributes['data-somme-denier'].value;
let jsondata = event.currentTarget.attributes['data-jsondata']
let objData
if ( jsondata ) {
if (jsondata) {
objData = JSON.parse(jsondata.value)
}
if (game.user.character ) {
if (game.user.character) {
game.user.character.payerDenier(sumdenier, objData);
} else {
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) {
let piece = { name: name, type: 'monnaie', img: img, _id: randomID(16),
data: {
quantite: 0,
valeur_deniers: valeur_deniers,
encombrement: enc,
description: ""
}
}
static createMonnaie(name, valeur_deniers, img = "", enc = 0.01) {
let piece = {
name: name, type: 'monnaie', img: img, _id: randomID(16),
data: {
quantite: 0,
valeur_deniers: valeur_deniers,
encombrement: enc,
description: ""
}
}
return piece;
}
@ -899,9 +792,9 @@ export class RdDUtility {
som1 = (som1) ? som1.toLowerCase() : "0d";
som2 = (som2) ? som2.toLowerCase() : "0d";
let regExp = /(\d+)(\w+)/g;
let p1 = regExp.exec( som1);
let p1 = regExp.exec(som1);
regExp = /(\d+)(\w+)/g;
let p2 = regExp.exec( som2);
let p2 = regExp.exec(som2);
let sumd = 0;
let sums = 0;
if (p1[2] == 'd') sumd += Number(p1[1]);
@ -909,10 +802,10 @@ export class RdDUtility {
if (p2[2] == 'd') sumd += Number(p2[1]);
if (p2[2] == 's') sums += Number(p2[1]);
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>";
msgPayer += "<a id='payer-button' class='chat-card-button' data-somme-denier='"+sumtotald+"'>Payer</a>"
ChatMessage.create( { content: msgPayer } );
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>";
msgPayer += "<a id='payer-button' class='chat-card-button' data-somme-denier='" + sumtotald + "'>Payer</a>"
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"
>{{#if data.editCaracComp}}Vérouiller{{else}}Dévérouiller{{/if}}</a></span>
<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"
>{{#if data.montrerCompetencesNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
src="systems/foundryvtt-reve-de-dragon/icons/{{#if data.showCompNiveauBase}}no-filter.svg{{else}}filter.svg{{/if}}" alt="filter/montrer tout"
>{{#if data.showCompNiveauBase}}Montrer tout{{else}}Filtrer{{/if}}</a></span>
<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"
>{{#if data.montrerArchetype}}Masquer l'archétype{{else}}Voir l'archétype{{/if}}</a></span>
@ -204,7 +204,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.generale as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -227,7 +227,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.particuliere as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -249,7 +249,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.specialisee as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -270,11 +270,11 @@
<div class="flex-group-left flexcol competence-column">
<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>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.melee as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -293,11 +293,11 @@
</ul>
<header class="competence-header flexrow">
<span class="competence-title">Compétences De Tir</span>
<span class="competence-title">Compétences de Tir</span>
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.tir as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -316,11 +316,11 @@
</ul>
<header class="competence-header flexrow">
<span class="competence-title">Compétences De Lancer</span>
<span class="competence-title">Compétences de Lancer</span>
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.lancer as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -343,7 +343,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.connaissance as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<span class="competence-label"><a>{{comp.name}}</a></span>
@ -366,7 +366,7 @@
</header>
<ul class="item-list alterne-list">
{{#each data.competenceByCategory.draconic as |comp key|}}
{{#if data.afficherCompetence}}
{{#if data.showCompetence}}
<li class="item flexrow list-item" data-item-id="{{comp._id}}">
<img class="sheet-competence-img" src="{{comp.img}}"/>
<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">
<label for="categorie">Compétence associée</label>
<select name="data.competence" id="competence" data-dtype="String">
{{#select item.data.competence}}
{{>"systems/foundryvtt-reve-de-dragon/templates/arme-competence.html"}}
{{/select}}
{{#select item.data.competence}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}}
{{/select}}
</select>
</div>
<div class="form-group">
@ -28,7 +28,7 @@
<label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#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>
</div>

View File

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

View File

@ -32,7 +32,7 @@
<label>Catégorie parade </label>
<select name="data.categorie_parade" id="categorie_parade" data-dtype="String">
{{#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>
</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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