diff --git a/RdD.geany b/RdD.geany index 201ff14f..1b76476a 100644 --- a/RdD.geany +++ b/RdD.geany @@ -27,19 +27,18 @@ long_line_behaviour=1 long_line_column=72 [files] -current_page=1 -FILE_NAME_0=8132;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 -FILE_NAME_1=0;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 -FILE_NAME_2=10137;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 -FILE_NAME_3=1756;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-roll-dialog.js;0;2 -FILE_NAME_4=2092;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 +current_page=2 +FILE_NAME_0=4448;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 +FILE_NAME_1=5464;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 +FILE_NAME_2=1630;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 +FILE_NAME_3=2579;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-roll-dialog.js;0;2 +FILE_NAME_4=10119;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 FILE_NAME_5=0;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fdialog-competence.html;0;2 -FILE_NAME_6=17162;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 +FILE_NAME_6=14208;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 FILE_NAME_7=543;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-main.js;0;2 FILE_NAME_8=1639;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-competence-sheet.html;0;2 -FILE_NAME_9=752;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-arme-sheet.html;0;2 -FILE_NAME_10=401;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fsystem.json;0;2 -FILE_NAME_11=10349;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 +FILE_NAME_9=1796;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Fitem-arme-sheet.html;0;2 +FILE_NAME_10=10349;CSS;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fstyles%2Fsimple.css;0;2 [VTE] last_dir=/home/sigmar diff --git a/module/actor-sheet.js b/module/actor-sheet.js index dad45e5a..2740fcfd 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -94,7 +94,7 @@ export class RdDActorSheet extends ActorSheet { /** @override */ activateListeners(html) { super.activateListeners(html); - + // Everything below here is only needed if the sheet is editable if (!this.options.editable) return; diff --git a/module/actor.js b/module/actor.js index 8018e4aa..1ce3fda7 100644 --- a/module/actor.js +++ b/module/actor.js @@ -94,12 +94,39 @@ export class RdDActor extends Actor { rollData.qualite = -6; } + // Manage weapon categories when parrying (cf. page 115 ) + let need_significative = false; // Do we need to have a sgnificative ? + let need_resist = false; // Do we need to have a sgnificative ? + if ( rollData.arme && rollData.attackerRoll ) { // Manage parade depeding on weapon type, and change roll results + let attCategory = RdDUtility.getArmeCategory( rollData.attackerRoll.arme ); + let defCategory = RdDUtility.getArmeCategory( rollData.arme ); + if ( defCategory == "bouclier" ) + need_significative = true; + else if ( attCategory != defCategory ) + need_significative = true; + if ( attCategory.match("epee") && ( defCategory == "hache" || defCategory == "lance") ) + need_resist = true; + } + + // Sonne management or if need_significative is set + if ( this.data.data.sante.sonne.value || need_significative) { + if (rollData.pointsDeTache >= 2 ) { // Reussite normale dès que significative + quality = "Réussite Normale"; + rollData.pointsDeTache = 1; + rollData.qualite = 0; + } else if (rollData.pointsDeTache < 2 ) { // Not a "significative" + quality = "Echec Normal"; + rollData.pointsDeTache = 0; + rollData.qualite = -2; + } + } + // Fight management ! let defenseMsg; let encaisser = false; let specialStr = "
Points de taches : " + rollData.pointsDeTache; // Per default - if ( rollData.arme ) { // In case of fight, replace the "tache" per dommages + localization. "tache" indicates if result is OK or not - if ( rollData.attackerRoll) { + if ( rollData.arme ) { // In case of fight, replace the "tache" message per dommages + localization. "tache" indicates if result is OK or not + if ( rollData.attackerRoll) { // Defense case ! if ( rollData.pointsDeTache > 0 ) { // Réussite ! specialStr = "
Attaque parée/esquivée !"; } else { @@ -212,13 +239,14 @@ export class RdDActor extends Actor { sante.fatigue.value = sante.fatigue.value - inc // If endurance is 0 -> -1 vie - if ( data.value == 0 ) { + if ( data.value == 0 && sante.vie.value > 0) { sante.vie.value = sante.vie.value - 1; } let diffVie = sante.vie.max - sante.vie.value; if ( data.value > data.max - (diffVie*2) ) { data.value = data.max - (diffVie*2); } + if ( data.value < 0 ) data.value = 0; // Security let blessures = this.data.data.blessures; let maxEnd = Math.floor( data.max / blessures.graves.nombre); @@ -227,10 +255,12 @@ export class RdDActor extends Actor { if (lastValue - data.value > 1) this.testSiSonne(sante, data); // Peut-être sonné si 2 points d'endurance perdus d'un coup } + console.log(name, inc, data.value); let diffEndurance = sante.endurance.max - this.data.data.sante.endurance.value; if ( sante.fatigue.value < diffEndurance) // If endurance lost, then the same amount of fatigue cannot be recovered sante.fatigue.value = diffEndurance; + console.log("SANTE::::", sante); await this.update( {"data.sante": sante } ); } @@ -290,7 +320,7 @@ export class RdDActor extends Actor { "carac": this.data.data.carac, "bonusmalusTable": CONFIG.RDD.bonusmalus, "etat": this.data.data.compteurs.etat.value, - "bmValue": 0, + "bmValue": (attackerRoll) ? attackerRoll.bmValue : 0, "attackerRoll": attackerRoll, "finalLevel": 0 } @@ -344,29 +374,7 @@ export class RdDActor extends Actor { /** @override */ getRollData() { const data = super.getRollData(); - const shorthand = game.settings.get("foundryvtt-reve-de-dragon", "macroShorthand"); - // Re-map all attributes onto the base roll data - if ( !!shorthand ) { - for ( let [k, v] of Object.entries(data.attributes) ) { - if ( !(k in data) ) data[k] = v.value; - } - delete data.attributes; - } - - // Map all items data using their slugified names - data.items = this.data.items.reduce((obj, i) => { - let key = i.name.slugify({strict: true}); - let itemData = duplicate(i.data); - if ( !!shorthand ) { - for ( let [k, v] of Object.entries(itemData.attributes) ) { - if ( !(k in itemData) ) itemData[k] = v.value; - } - delete itemData["attributes"]; - } - obj[key] = itemData; - return obj; - }, {}); return data; } } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 56793ffe..16701b98 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -377,7 +377,25 @@ export class RdDUtility { } } } - + + /* -------------------------------------------- */ + static getArmeCategory( arme ) + { + let compname = arme.data.competence.toLowerCase(); + if ( compname.match("hache") ) return "hache"; + if ( compname.match("hast") ) return "hast"; + if ( compname.match("lance") ) return "lance"; + if ( compname.match("bouclier") ) return "bouclier"; + if ( compname.match("masse") ) return "masse"; + if ( compname.match("fléau") ) return "fleau"; + if ( compname.match("epée") ) { + let armename = arme.name.toLowerCase(); + if (armename == "dague" || armename.match("gnome") ) + return "epee_courte"; + } + return "epee_longue"; + } + /* -------------------------------------------- */ static isArmeMelee( compName) { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 733e9059..91af7b51 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -7,18 +7,31 @@

- Vie + / - - /{{data.sante.vie.max}} -
-
- Endurance + / - - /{{data.sante.endurance.max}} +
+ Vie + / - + /{{data.sante.vie.max}} +
+
+ Endurance + / - + /{{data.sante.endurance.max}} +
+
+ Sonné : + +
Fatigue + / - {{{data.fatigueHTML}}}
+
+
+
Blessures légères : {{data.blessures.legeres.nombre}}
+
Blessures graves : {{data.blessures.graves.nombre}}
+
Blessure critique : {{data.blessures.critiques.nombre}}
+
+
{{#each data.compteurs as |compteur key|}}