diff --git a/module/actor.js b/module/actor.js index cea4509d..4b918d10 100644 --- a/module/actor.js +++ b/module/actor.js @@ -62,10 +62,10 @@ export class RdDActor extends Actor { compendiumName = "foundryvtt-reve-de-dragon.competences-entites"; } if ( compendiumName ) { - data.items = RdDUtility.loadCompendium(compendiumName); + data.items = await RdDUtility.loadCompendium(compendiumName); } // Ajout monnaie - if (data.type == "personnage") { + if (data.type == "personnage" && data.items) { await RdDActor.ajouterMonnaie(data.items); } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index af8dee23..3d930c7d 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -28,6 +28,39 @@ const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, + 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; +const taille2derivee = { 1: { poids: "moins de 1kg", plusdom:-5, sconst: 0.5, sust: 0.1 }, + 2: { poids: "1-5", plusdom:-4, sconst: 0.5, sust: 0.3 }, + 3: { poids: "6-10", plusdom:-3, sconst: 1, sust: 0.5 }, + 4: { poids: "11-20", plusdom:-3, sconst: 1, sust: 1 }, + 5: { poids: "21-30", plusdom:-2, sconst: 1, sust: 1 }, + 6: { poids: "31-40", plusdom:-1, sconst: 2, sust: 2 }, + 7: { poids: "41-50", plusdom:-1, sconst: 2, sust: 2 }, + 8: { poids: "51-60", plusdom:0, sconst: 2, sust: 2 }, + 9: { poids: "61-65", plusdom:0, sconst: 3, sust: 2 }, + 10: { poids: "66-70", plusdom:0, sconst: 3, sust: 3 }, + 11: { poids: "71-75", plusdom:0, sconst: 3, sust: 3 }, + 12: { poids: "76-80", plusdom:+1, sconst: 4, sust: 3 }, + 13: { poids: "81-90", plusdom:+1, sconst: 4, sust: 3 }, + 14: { poids: "91-100", plusdom:+2, sconst: 4, sust: 4 }, + 15: { poids: "101-110", plusdom:+2, sconst: 5, sust: 4 }, + 16: { poids: "111-120", plusdom:+3, sconst: 5, sust: 4 }, + 17: { poids: "121-131", plusdom:+3, sconst: 5, sust: 5 }, + 18: { poids: "131-141", plusdom:+4, sconst: 6, sust: 5 }, + 19: { poids: "141-150", plusdom:+4, sconst: 6, sust: 5 }, + 20: { poids: "151-160", plusdom:+4, sconst: 6, sust: 6 }, + 21: { poids: "161-180", plusdom:+5, sconst: 7, sust: 6 }, + 22: { poids: "181-200", plusdom:+5, sconst: 7, sust: 7 }, + 23: { poids: "201-300", plusdom:+6, sconst: 7, sust: 8 }, + 24: { poids: "301-400", plusdom:+6, sconst: 8, sust: 9 }, + 25: { poids: "401-500", plusdom:+7, sconst: 8, sust: 10 }, + 26: { poids: "501-600", plusdom:+7, sconst: 8, sust: 11 }, + 27: { poids: "601-700", plusdom:+8, sconst: 9, sust: 12 }, + 28: { poids: "701-800", plusdom:+8, sconst: 9, sust: 13 }, + 29: { poids: "801-900", plusdom:+9, sconst: 9, sust: 14 }, + 30: { poids: "901-1000", plusdom:+9, sconst: 10, sust: 15 }, + 31: { poids: "1001-1500", plusdom:+10, sconst: 10, sust: 16 }, + 32: { poids: "1501-2000", plusdom:+11, sconst: 10, sust: 17 } + } /* -------------------------------------------- */ function _buildAllSegmentsFatigue(max) { @@ -422,15 +455,14 @@ export class RdDUtility { 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); + bonusDomKey = Math.min( Math.max(bonusDomKey, 0), 32); // Clamp de securite - // TODO: gérer table des bonus dommages (et autres) des créatures - data.attributs.plusdom.value = 2 - if (bonusDomKey < 8) - data.attributs.plusdom.value = -1; - else if (bonusDomKey < 12) - data.attributs.plusdom.value = 0; - else if (bonusDomKey < 14) - data.attributs.plusdom.value = 1; + let tailleData = taille2derivee[bonusDomKey]; + data.attributs.plusdom.value = tailleData.plusdom; + + tailleData = taille2derivee[Number(data.carac.taille.value)]; + data.attributs.sconst.value = tailleData.sconst; + data.attributs.sust.value = tailleData.sust; 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); @@ -445,24 +477,8 @@ export class RdDUtility { 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) - data.attributs.sconst.value = 2; - else if (data.carac.constitution.value < 12) - data.attributs.sconst.value = 3; - else if (data.carac.constitution.value < 15) - data.attributs.sconst.value = 4; - - data.attributs.sust.value = 4; // Max ! - if (data.carac.taille.value < 10) - data.attributs.sust.value = 2; - else if (data.carac.taille.value < 14) - data.attributs.sust.value = 3; - //Compteurs - //data.compteurs.reve.value = data.carac.reve.value; data.reve.reve.max = data.carac.reve.value; - //data.compteurs.chance.value = data.carac.chance.value; data.compteurs.chance.max = data.carac.chance.value; } @@ -589,6 +605,7 @@ export class RdDUtility { return competences; } + /* -------------------------------------------- */ static async loadCompendium(compendium, filter = item => true) { let compendiumItems = await RdDUtility.loadCompendiumNames(compendium); diff --git a/packs/equipement.db b/packs/equipement.db index fac07b1a..7b74ed5f 100644 --- a/packs/equipement.db +++ b/packs/equipement.db @@ -200,4 +200,3 @@ {"_id":"zQWlnUsd8bPySujd","name":"Aiguille à coudre","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.01,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/aiguille.webp","effects":[]} {"_id":"zYI8mDiysWtmsSyy","name":"Carquois","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"conteneur","data":{"description":"","capacite":2,"encombrement":0.1,"equipe":false,"qualite":0,"cout":0.5},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/carquois.webp","effects":[]} {"_id":"zlDa1vwmls6Uf4pt","name":"Bourse de cuir","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"conteneur","data":{"description":"","capacite":0.5,"encombrement":0.01,"equipe":false,"qualite":0,"contenu":[],"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/bourse.webp","effects":[]} -{"_id":"zQWlnUsd8bPySujd","name":"Aiguille à coudre","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.01,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/aiguille.webp","effects":[]}