From ca1a93f9d7af082064e18c62eb8ba927b5453623 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 20 Sep 2020 19:17:31 +0200 Subject: [PATCH] Fix creature competence --- module/actor-creature-sheet.js | 2 +- module/actor.js | 33 ++++++++++++++++++++---- packs/competences-creatures.db | 40 ++++++++++++++--------------- system.json | 4 +-- template.json | 2 +- templates/actor-creature-sheet.html | 2 +- 6 files changed, 53 insertions(+), 30 deletions(-) diff --git a/module/actor-creature-sheet.js b/module/actor-creature-sheet.js index 93cbdb97..fee69960 100644 --- a/module/actor-creature-sheet.js +++ b/module/actor-creature-sheet.js @@ -114,7 +114,7 @@ export class RdDActorCreatureSheet extends ActorSheet { // On competence change html.find('.creature-carac').change((event) => { let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCreatureCompetence( compName, "carac-value", parseInt(event.target.value) ); + this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) ); } ); html.find('.creature-niveau').change((event) => { let compName = event.currentTarget.attributes.compname.value; diff --git a/module/actor.js b/module/actor.js index c60bc20e..522f2fb2 100644 --- a/module/actor.js +++ b/module/actor.js @@ -307,14 +307,16 @@ export class RdDActor extends Actor { async updateCreatureCompetence( compName, fieldName, compValue ) { let comp = RdDUtility.findCompetence( this.data.items, compName); + console.log( comp ); if ( comp ) { const update = {_id: comp._id } if (fieldName == "niveau") - update['data.niveau']= compValue; + update['data.niveau'] = compValue; else if (fieldName == "dommages") - update['data.dommages']= compValue; + update['data.dommages'] = compValue; else - update['data.cacac-value']= compValue; + update['data.carac_value'] = compValue; + console.log(update); const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity } } @@ -719,10 +721,31 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - rollCreatureCompetence( compName ) + async rollCreatureCompetence( compName, armeItem=undefined, attackerRoll=undefined ) { let compItem = RdDUtility.findCompetence( this.data.items, compName); - //TODO !!!! + if ( compItem.data.iscombat ) { + armeItem = { name: compName, data: { dommages: compItem.data.dommages} }; + } + compItem.data.defaut_carac = compName; // Fake default competence + console.log("V:", compItem.data.carac_value, compItem) + let rollData = { + "competence": compItem, + "arme": armeItem, + "carac": { compName: { label: compName, value: compItem.data.carac_value } }, + "bonusmalusTable": CONFIG.RDD.bonusmalus, + "etat": this.data.data.compteurs.etat.value, + "bmValue": (attackerRoll) ? attackerRoll.bmValue : 0, + "attackerRoll": attackerRoll, + "finalLevel": 0 + } + + let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', rollData); + if (armeItem) { + new RdDRollDialog("arme", html, rollData, this ).render(true); + } else { + new RdDRollDialog("competence", html, rollData, this ).render(true); + } } /* -------------------------------------------- */ diff --git a/packs/competences-creatures.db b/packs/competences-creatures.db index 963eb01f..9d2d4013 100644 --- a/packs/competences-creatures.db +++ b/packs/competences-creatures.db @@ -1,20 +1,20 @@ -{"name":"Escalade","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_escalade.png","_id":"4GmpkphbsmQjvVVK"} -{"name":"Morsure","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-morsure.png","_id":"6DK46pyO0hzEuuUg"} -{"name":"Griffes et Crocs","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-griffes.png","_id":"BjqRrGtHtTzuNpZB"} -{"name":"Esquive","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"dommages":0,"iscombat":false,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_esquive.png","_id":"CYpxxf1uTa78NWR9"} -{"name":"Crête","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"dommages":0,"iscombat":true,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-crete.png","_id":"JTuBQCPdumw3DfxH"} -{"name":"Vol","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"dommages":0,"iscombat":false,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-vol.png","_id":"Kt7WlB5Ui97X211z"} -{"name":"Cornes","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-corne.png","_id":"LWQHz5ymNBzh6ZEr"} -{"name":"Bras-bouches","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-brasbouche.png","_id":"NctG7suzvGE7ZZzj"} -{"name":"Pierre Tenue","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pierretenue.png","_id":"OzHBowOMADRwcVXR"} -{"name":"Pinces","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pinces.png","_id":"RAnasKnoA3OQgwfv"} -{"name":"Mandibules","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-mandibules.png","_id":"XgfRxSj8Ty1d3JFM"} -{"name":"Pierre Lancée","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pierrelancee.png","_id":"efl1HdDSKpBfImQ1"} -{"name":"Tronçonneuse","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-tronconneuse.png","_id":"h9ASt4vrvEgxfj7j"} -{"name":"Vigilance","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_vigilance.png","_id":"lzEdMrKXbOYrWG5S"} -{"name":"Serres","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-serres.png","_id":"ndNshntOYb1JFNqi"} -{"name":"Bec","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-beak.png","_id":"os88Rsp7mBkahqmh"} -{"name":"Dague","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_dague.png","_id":"qilRzXpVaGceNmQp"} -{"name":"Pickpocket","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_pickpocket.png","_id":"sUdXhpuVVOAlcVpo"} -{"name":"Course","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_course.png","_id":"shsUV8UpU18c0RJK"} -{"name":"Discrétion","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac-value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_discretion.png","_id":"yDHZfK4RmwQW4YaW"} +{"name":"Escalade","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_escalade.png","_id":"4GmpkphbsmQjvVVK"} +{"name":"Morsure","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-morsure.png","_id":"6DK46pyO0hzEuuUg"} +{"name":"Griffes et Crocs","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-griffes.png","_id":"BjqRrGtHtTzuNpZB"} +{"name":"Esquive","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"dommages":0,"iscombat":false,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_esquive.png","_id":"CYpxxf1uTa78NWR9"} +{"name":"Crête","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"dommages":0,"iscombat":true,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-crete.png","_id":"JTuBQCPdumw3DfxH"} +{"name":"Vol","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"dommages":0,"iscombat":false,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-vol.png","_id":"Kt7WlB5Ui97X211z"} +{"name":"Cornes","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-corne.png","_id":"LWQHz5ymNBzh6ZEr"} +{"name":"Bras-bouches","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-brasbouche.png","_id":"NctG7suzvGE7ZZzj"} +{"name":"Pierre Tenue","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pierretenue.png","_id":"OzHBowOMADRwcVXR"} +{"name":"Pinces","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pinces.png","_id":"RAnasKnoA3OQgwfv"} +{"name":"Mandibules","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-mandibules.png","_id":"XgfRxSj8Ty1d3JFM"} +{"name":"Pierre Lancée","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-pierrelancee.png","_id":"efl1HdDSKpBfImQ1"} +{"name":"Tronçonneuse","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-tronconneuse.png","_id":"h9ASt4vrvEgxfj7j"} +{"name":"Vigilance","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_vigilance.png","_id":"lzEdMrKXbOYrWG5S"} +{"name":"Serres","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-serres.png","_id":"ndNshntOYb1JFNqi"} +{"name":"Bec","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/compcreature-beak.png","_id":"os88Rsp7mBkahqmh"} +{"name":"Dague","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":true,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_dague.png","_id":"qilRzXpVaGceNmQp"} +{"name":"Pickpocket","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_pickpocket.png","_id":"sUdXhpuVVOAlcVpo"} +{"name":"Course","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_course.png","_id":"shsUV8UpU18c0RJK"} +{"name":"Discrétion","permission":{"default":0,"Q4cUvqxCxMoTJXDL":3},"type":"competencecreature","data":{"niveau":0,"carac_value":0,"iscombat":false,"dommages":0,"description":"

Morsure de la créature

"},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/competence_discretion.png","_id":"yDHZfK4RmwQW4YaW"} diff --git a/system.json b/system.json index c3564f28..d3d91d6d 100644 --- a/system.json +++ b/system.json @@ -2,10 +2,10 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "0.9.7", + "version": "0.9.8", "minimumCoreVersion": "0.6.0", "compatibleCoreVersion": "0.6.6", - "templateVersion": 33, + "templateVersion": 34, "author": "LeRatierBretonnien", "esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ], "styles": ["styles/simple.css"], diff --git a/template.json b/template.json index c022273f..c2509b89 100644 --- a/template.json +++ b/template.json @@ -524,7 +524,7 @@ }, "competencecreature": { "niveau": 0, - "carac-value": 0, + "carac_value": 0, "iscombat": false, "dommages": 0, "description": "Compétence : ..." diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 51dbbfee..a74e1e3f 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -98,7 +98,7 @@
  • {{comp.name}} - +