From 3d6d00e96f8efaacc5194eac1e1b32eb89224e5e Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 5 Dec 2020 22:21:13 +0100 Subject: [PATCH] =?UTF-8?q?#53=20:=20Gestion=20des=20d=C3=A9t=C3=A9riorati?= =?UTF-8?q?ons=20et=20du=20recul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 56 +++++++++++++++++++++++++++++++- module/rdd-roll-dialog.js | 12 ++++--- packs/equipement.db | 2 +- templates/dialog-competence.html | 4 +++ 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/module/actor.js b/module/actor.js index 939df99f..ac9b004b 100644 --- a/module/actor.js +++ b/module/actor.js @@ -166,7 +166,58 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ computeDeteriorationArme( rollData ) { if ( rollData.arme && rollData.attackerRoll) { // C'est une parade + // Est-ce que l'attaque est une particulière, en force ou charge et que l'attaque n'en est pas une ? + if ( rollData.attackerRoll.rolled.isPart + && ( (rollData.attackerRoll.particuliereAttaque && rollData.attackerRoll.particuliereAttaque == 'force') || rollData.attackerRoll.isCharge) + && !rollData.rolled.isPart ) { + // Jet de résistance de l'arme de parade (p.132) + let resist = RdDResolutionTable.roll( rollData.arme.data.resistance, rollData.attackerRoll.domArmePlusDom ); + if (!resist.isSuccess) { // Perte de résistance + rollData.arme.data.resistance -= rollData.attackerRoll.domArmePlusDom; + if ( rollData.arme.data.resistance <= 0 ) { + this.deleteEmbeddedEntity("OwnedItem", rollData.arme._id); + ChatMessage.create( { content: "Votre arme s'est brisée sous le coup de la parade : " + rollData.arme.name, + user: game.user._id, + whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } ); + } else { + this.updateEmbeddedEntity("OwnedItem", {_id: rollData.arme._id, 'data.resistance': rollData.arme.data.resistance }); + ChatMessage.create( { content: "Votre arme a perdu de la résistance : " + rollData.arme.name + " - " + rollData.arme.data.resistance, + user: game.user._id, + whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } ); + } + } + // Jet de désarmement + if ( !rollData.arme.includes('Bouclier') ) { // Si l'arme de parade n'est pas un bouclier, jet de désarmement (p.132) + let desarme = RdDResolutionTable.roll( this.data.data.carac.force.value, Number(rollData.competence.data.niveau) + Number(rollData.attackerRoll.domArmePlusDom) ); + if ( !desarme.isSucess) { + ChatMessage.create( { content: "Vous êtes désarmé ! Votre arme " + rollData.arme.name + "tombe au sol à vos pieds", + user: game.user._id, + whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } ); + } + } + } + } + } + /* -------------------------------------------- */ + computeRecul( rollData ) { // Calcul du recul (p. 132) + if ( rollData.arme || encaisser ) { + if ( (rollData.attackerRoll.particuliereAttaque && rollData.attackerRoll.particuliereAttaque == 'force') || rollData.attackerRoll.isCharge) { + let reculNiveau = this.data.data.taille.value - (rollData.attackerRoll.forceValue+rollData.attackerRoll.arme.dommages); + let recul = RdDResolutionTable.roll( 10, reculNiveau ); + if (!recul.isSuccess) { + let chute = RdDResolutionTable.roll( this.data.data.carac.agilite.value, reculNiveau ); + if ( !chute.isSuccess || recul.isETotal ) { + ChatMessage( {content:"Vous subissez le recul du coup, et vous chutez au sol ! Vous ne pouvez plus attaquer ce round.", + user: game.user._id, + whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } ); + } else { + ChatMessage( {content:"Vous subissez le recul du coup, et vous reculez de quelques mètres ! Vous ne pouvez plus attaquer ce round.", + user: game.user._id, + whisper: [game.user._id, ChatMessage.getWhisperRecipients("GM") ] } ); + } + } + } } } @@ -212,7 +263,9 @@ export class RdDActor extends Actor { if (rollData.needSignificative) explications += " Significative nécessaire!"; } + this.computeRecul( rollData ); encaisser = rollData.needSignificative ? !rolled.isSign : !rolled.isSuccess; + this.computeRecul( rollData, encaisser ); } else { // This is the attack roll! if (rolled.isSuccess) { let target = this.getTarget(); @@ -226,7 +279,7 @@ export class RdDActor extends Actor { whisper: ChatMessage.getWhisperRecipients( this.name ) } ); } rollData.domArmePlusDom = this._calculBonusDommages(rollData.selectedCarac, rollData.arme, rollData.particuliereAttaque == 'force' ); - rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom; + rollData.degats = new Roll("2d10").roll().total + rollData.domArmePlusDom + ((rollData.isCharge)?2:0); // Dégats totaux rollData.loc = RdDUtility.getLocalisation(); if (target) @@ -1286,6 +1339,7 @@ export class RdDActor extends Actor { difficultesLibres: CONFIG.RDD.difficultesLibres, etat: this.data.data.compteurs.etat.value, diffConditions: 0, + forceValue :this.data.data.carac.force.value, // Utilisé pour le jet de recul diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0, attackerRoll: attackerRoll, finalLevel: 0, diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index 17a5adaf..c434c475 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -31,13 +31,13 @@ export class RdDRollDialog extends Dialog { // Select proper roll dialog template and stuff if (mode == "competence") { dialogConf.title = "Test de compétence" - dialogOptions.height = 420 + dialogOptions.height = 430 } else if (mode == "arme") { dialogConf.title = "Test de combat/arme" - dialogOptions.height = 440 + dialogOptions.height = 460 } else if (mode == "carac") { dialogConf.title = "Test de caractéristique" - dialogOptions.height = 400 + dialogOptions.height = 420 } else if (mode == "sort") { dialogConf.title = "Lancer un sort" dialogOptions.height = 460 @@ -154,6 +154,9 @@ export class RdDRollDialog extends Dialog { html.find('#coupsNonMortels').change((event) => { this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "non-mortel"; }); + html.find('#isCharge').change((event) => { + this.rollData.isCharge = event.currentTarget.checked; + }); html.find('#surencMalusApply').change((event) => { this.rollData.surencMalusApply = event.currentTarget.checked; updateRollResult(rollData); @@ -171,6 +174,7 @@ export class RdDRollDialog extends Dialog { let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0; let diffLibre = Misc.toInt(rollData.diffLibre); let malusEncNatation = (rollData.useEncForNatation) ? -rollData.encValueForNatation : 0; + let chargeBonus = (rollData.isCharge) ? 4 : 0; // gestion de la charge en mélée // Gestion malus armure let malusArmureValue = 0; @@ -190,7 +194,7 @@ export class RdDRollDialog extends Dialog { diffLibre = RdDItemSort.getDifficulte(rollData.selectedSort, diffLibre); } - return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue; + return etat + diffCompetence + diffLibre + diffConditions + malusEnc + malusEncNatation + malusArmureValue + chargeBonus; } /* -------------------------------------------- */ diff --git a/packs/equipement.db b/packs/equipement.db index bc8cd1fa..3d484275 100644 --- a/packs/equipement.db +++ b/packs/equipement.db @@ -93,8 +93,8 @@ {"_id":"Sm28dG9isppoQzPQ","name":"Bas de lin","permission":{"default":0,"jOzRscDxoXZWpGS6":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0,"equipe":false,"resistance":0,"qualite":0,"cout":0.3},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/bas_lin.webp","effects":[]} {"_id":"SrV0r5hnGdKeSIHR","name":"Cuillère de bois","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.03,"equipe":false,"resistance":0,"qualite":0,"cout":0.03},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/cuillere_bois.webp","effects":[]} {"_id":"SsnGNjTekvB50uWa","name":"Chapeau de cuir souple","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.08,"equipe":false,"resistance":0,"qualite":0,"cout":0.5},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/chapeau_cuir.webp","effects":[]} -{"_id":"TY6Ft8a6WfxD6pD9","name":"Bobineau de fil","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/bobineau.webp","effects":[]} {"_id":"T9UiLcJonuHmGNwq","name":"Sols (pièces d'argent)","permission":{"default":0,"Q2G6GTdrotKzYGUC":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.005,"equipe":false,"resistance":0,"qualite":0,"cout":1},"flags":{},"img":"icons/commodities/currency/coins-assorted-mix-silver.webp","effects":[]} +{"_id":"TY6Ft8a6WfxD6pD9","name":"Bobineau de fil","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/bobineau.webp","effects":[]} {"_id":"U6qli6TPbzj8tUdH","name":"Arme d’hast","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"arme","data":{"description":"","quantite":1,"encombrement":4,"equipe":false,"dommages":"4","force":"12","resistance":8,"competence":"Dague","cout":10,"portee_courte":0,"portee_moyenne":0,"portee_extreme":0,"rapide":false,"deuxmains":true,"unemain":false},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/armes_armures/hast.webp","effects":[]} {"_id":"UDmq6CY3NsttcHe4","name":"Peigne en corne","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.04,"equipe":false,"resistance":0,"qualite":0,"cout":0.4},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/peigne.webp","effects":[]} {"_id":"UICiMF3wBeLsqm8L","name":"Pipe en bois","permission":{"default":0,"rYShh2P1DNavdoBD":3},"type":"objet","data":{"description":"","quantite":1,"encombrement":0.04,"equipe":false,"resistance":0,"qualite":0,"cout":0.1},"flags":{},"img":"systems/foundryvtt-reve-de-dragon/icons/objets/pipe.webp","effects":[]} diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index cfdc307a..304d8bb0 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -36,6 +36,10 @@ +
+ + +
{{/if}} {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-natation.html"}}