From 62b159ef9de25198fbe8cb729532adbfabff129b Mon Sep 17 00:00:00 2001 From: sladecraven Date: Wed, 2 Dec 2020 20:52:37 +0100 Subject: [PATCH] #41 : Gestion de l'archetype des PJs --- module/actor-sheet.js | 31 +++++++++++++++++++++++++++++++ module/rdd-utility.js | 27 +++++++++++++++++++++++++-- styles/simple.css | 1 + templates/actor-sheet.html | 5 ++++- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index c612005f..a4aef1ed 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -44,6 +44,7 @@ export class RdDActorSheet extends ActorSheet { list.push(item); } } + this.competenceByCategory = duplicate(data.competenceByCategory); // Sauvegarde locale competenceXPTotal += RdDUtility.computeCompetenceTroncXP(data.itemsByType.competence); data.data.competenceXPTotal = competenceXPTotal; //console.log("XP competence : ", competenceXPTotal); @@ -156,6 +157,31 @@ export class RdDActorSheet extends ActorSheet { d.render(true); } + /* -------------------------------------------- */ + afficheResumeArchetype() { + let levelCategory = RdDUtility.getLevelCategory(); + let labelCategory = RdDUtility.getLabelCategory(); + let contentHTML = ""; + for (let compCategory in this.competenceByCategory) { + console.log(">>>>", compCategory); + contentHTML += "
" + labelCategory[compCategory] + ""; + for (let comp of this.competenceByCategory[compCategory]) { + if ( !comp.data.niveau_archetype ) comp.data.niveau_archetype = levelCategory[compCategory]; + contentHTML += "
" + comp.name + " : " + comp.data.niveau_archetype; + } + } + let dialogData = { + content: contentHTML, + buttons: { + one: { + icon: '', + label: "Fermer" + } + } + } + new Dialog( dialogData ).render(true); + } + /* -------------------------------------------- */ /** @override */ activateListeners(html) { @@ -333,6 +359,11 @@ export class RdDActorSheet extends ActorSheet { this.actor.updateCompteurValue( fieldName, parseInt(event.target.value) ); } ); + // Dialog d'archetype + html.find("#affiche-archetype").click((event) => { + this.afficheResumeArchetype() + } ); + html.find('#stress-test').click((event) => { this.actor.stressTest(); this.render(true); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 89b8711b..0d53f876 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -4,16 +4,29 @@ import { TMRUtility } from "./tmr-utility.js"; import { RdDRollTables } from "./rdd-rolltables.js"; import { ChatUtility } from "./chat-utility.js"; +/* -------------------------------------------- */ const level_category = { "generale": "-4", "particuliere": "-8", - "speciale": "-11", + "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 = { @@ -23,6 +36,7 @@ const competence_xp = { "-4" : [ 15, 30, 45, 60, 80, 100, 120] } +/* -------------------------------------------- */ // 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"]; @@ -30,7 +44,7 @@ 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]; - +/* -------------------------------------------- */ 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]]; @@ -45,6 +59,8 @@ function _buildAllSegmentsFatigue(max) { } return fatigue; } + +/* -------------------------------------------- */ function _cumulSegmentsFatigue(matrix) { let cumulMatrix = []; for (let line of matrix) @@ -59,6 +75,7 @@ function _cumulSegmentsFatigue(matrix) { return cumulMatrix; } +/* -------------------------------------------- */ const fatigueMatrix = _buildAllSegmentsFatigue(30); const cumulFatigueMatrix = _cumulSegmentsFatigue(fatigueMatrix); @@ -77,12 +94,14 @@ const table2func = { "queues": {descr: "queues : Tire une queue de Dragon", fun "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 } ] +/* -------------------------------------------- */ const definitionsEncaissement = { "mortel": [ { minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 }, @@ -310,6 +329,10 @@ export class RdDUtility { { return level_category; } + static getLabelCategory( ) + { + return label_category; + } static getCaracArray() { return carac_array; diff --git a/styles/simple.css b/styles/simple.css index b0155289..a195a6bd 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -565,6 +565,7 @@ ul, li { flex-grow: 0; } .arme-label, +.generic-label, .competence-label, .description-label { flex-grow: 2; diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 1eb170d6..9c581ba2 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -300,9 +300,12 @@