diff --git a/icons/sorts/sort_hypnos.png b/icons/sorts/sort_hypnos.png new file mode 100644 index 00000000..5f5c7f2f Binary files /dev/null and b/icons/sorts/sort_hypnos.png differ diff --git a/icons/sorts/sort_narcos.png b/icons/sorts/sort_narcos.png new file mode 100644 index 00000000..63655f60 Binary files /dev/null and b/icons/sorts/sort_narcos.png differ diff --git a/icons/sorts/sort_oniros.png b/icons/sorts/sort_oniros.png new file mode 100644 index 00000000..067ce13c Binary files /dev/null and b/icons/sorts/sort_oniros.png differ diff --git a/icons/sorts/sort_thanatos.png b/icons/sorts/sort_thanatos.png new file mode 100644 index 00000000..9ce01f79 Binary files /dev/null and b/icons/sorts/sort_thanatos.png differ diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 2bb85c07..bf904505 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -44,6 +44,7 @@ export class RdDActorSheet extends ActorSheet { } // Competence per category data.competenceByCategory = {}; + let competenceXPTotal = 0; if (data.itemsByType.competence) { for (const item of data.itemsByType.competence) { //console.log("Push...", item, item.data.categorie); @@ -52,10 +53,18 @@ export class RdDActorSheet extends ActorSheet { list = []; data.competenceByCategory[item.data.categorie] = list; } + competenceXPTotal += RdDUtility.computeCompetenceXPCost(item) list.push(item); } } - + data.data.competenceXPTotal = competenceXPTotal; + //console.log("XP competence : ", competenceXPTotal); + + // Compute current carac sum + let sum = 0; + Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } } ); + data.data.caracSum = sum; + // Force empty arme, at least for Esquive if (data.itemsByType.arme == undefined ) data.itemsByType.arme = []; for (const arme of data.itemsByType.arme) { diff --git a/module/actor.js b/module/actor.js index 98b02076..41a95f66 100644 --- a/module/actor.js +++ b/module/actor.js @@ -272,6 +272,7 @@ export class RdDActor extends Actor { data: defenseMsg } ); } else { + defenseMsg.whisper = [ game.user]; ChatMessage.create( defenseMsg ); } } @@ -294,7 +295,26 @@ export class RdDActor extends Actor { { let comp = RdDUtility.findCompetence( this.data.items, compName); if ( comp ) { - const update = {_id: comp._id, 'data.niveau': compValue }; + let troncList = RdDUtility.isTronc( compName ); + let maxNiveau = compValue; + if ( troncList ) { + let troncCompValue = (compValue > 0) ? 0 : compValue; // Clamp it to 0 + for(let troncName of troncList) { + if ( troncName != compName) { + console.log("Update competence tronc", troncName, compValue); + let comp2 = RdDUtility.findCompetence( this.data.items, troncName); + if (comp2.data.niveau > maxNiveau) maxNiveau = comp2.data.niveau; + if ( comp2.data.niveau <= 0 && comp2.data.niveau < troncCompValue ) { // Update only of below 0 + const update = {_id: comp2._id, 'data.niveau': compValue }; + const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity + } + } + } + if ( compValue < maxNiveau) { // Manage case when someone set a value below + compValue = (maxNiveau > 0) ? 0 : maxNiveau; + } + } + const update = {_id: comp._id, 'data.niveau': maxNiveau }; const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity } else { console.log("Competence not found", compName); diff --git a/module/rdd-main.js b/module/rdd-main.js index b2919e57..1ed8368a 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -23,7 +23,16 @@ Hooks.once("init", async function() { // preload handlebars templates RdDUtility.preloadHandlebarsTemplates(); - + + // Create specific settings + game.settings.register("foundryvtt-reve-de-dragon", "configuration", { + name: "configuration", + scope: "world", + config: false, + type: Object + }); + //game.settings.get("","") to retrieve it and game.settings.set("","", ) + /** * Set an initiative formula for the system * @type {String} diff --git a/module/rdd-utility.js b/module/rdd-utility.js index eadfd728..09ef92fe 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -12,6 +12,16 @@ const level_category = { "tir": "-8", "lancer": "-8" } +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 +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 bonusmalus = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; const specialResults = [ { "part": 0, "epart": 0, "etotal": 0 }, // 0 @@ -204,6 +214,18 @@ export class RdDUtility { return container.append(table); } + /* -------------------------------------------- */ + static isTronc( compName ) + { + for (let troncList of competenceTroncs) { + for (let troncName of troncList) { + if ( troncName == compName) + return troncList; + } + } + return false; + } + /* -------------------------------------------- */ static getResolutionField(caracValue, levelValue ) { @@ -215,6 +237,21 @@ export class RdDUtility { return CONFIG.RDD.resolutionTable[caracValue][levelValue+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]); + } + return xp; + } + /* -------------------------------------------- */ static computeCarac( data) { @@ -481,6 +518,7 @@ export class RdDUtility { } else if (sockmsg.msg == "msg_defense" ) { let defenderActor = game.actors.get( sockmsg.data.defenderid ); if ( (game.user.isGM && !defenderActor.isPC) || (defenderActor.isPC && game.user.character.id == defenderActor.id ) ) { + console.log("User is pushing message...", game.user.name); sockmsg.data.whisper = [ game.user ]; sockmsg.data.blind = true; sockmsg.data.rollMode = "blindroll"; diff --git a/system.json b/system.json index 1d039ba9..a24e17f4 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT", - "version": "0.8.3", + "version": "0.8.4", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.6.2", "templateVersion": 23, diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 4919f6e7..7e48578b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -77,6 +77,10 @@ {{/if}} {{/each}} +
  • + Total Caractéristiques + {{data.caracSum}} +
  • @@ -244,7 +248,14 @@ {{/each}} -
    +
    +
      +
    1. + Total XP compétences + {{data.competenceXPTotal}} +
    2. +
    +