diff --git a/module/rdd-combat.js b/module/rdd-combat.js index bf201da2..268ede40 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -688,10 +688,22 @@ export class RdDCombat { } /* -------------------------------------------- */ - verifierDistance( competence, arme) { - if ( competence.system.categorie == "tir" ) { - // TODO - ONGOING - + verifierDistance( rollData ) { + if ( rollData.competence.system.categorie == "tir" || + rollData.competence.system.categorie == "lancer" ) { + const defenderToken = canvas.tokens.get(this.defenderTokenId) + let dist = canvas.grid.measureDistances([{ ray: new Ray(_token.center, defenderToken.center) }], { gridSpaces: false }) + dist = Number(dist).toPrecision(5) + //let ray = new Ray( {x: _token.x, y: _token.y}, {x: defenderToken.x, y:defenderToken.y} ) + let msgPortee = "portée est courte (0)" + if (dist > rollData.arme.system.portee_courte && dist <= rollData.arme.system.portee_moyenne) { + msgPortee = "portée est moyenne (-3)" + } else if (dist > rollData.arme.system.portee_moyenne && dist <= rollData.arme.system.portee_extreme) { + msgPortee = "portée est extrême (-5)" + } else if ( dist > rollData.arme.system.portee_extreme) { + msgPortee = "cible est inateignable" + } + ChatMessage.create( { content: `Indication MJ : La cible est à une distance indicative de : ${dist} mètres. Pour l'arme ${rollData.arme.name}, la ${msgPortee}.`, whisper: ChatMessage.getWhisperRecipients("GM") } ) } } @@ -717,7 +729,7 @@ export class RdDCombat { if (arme) { this.attacker.verifierForceMin(arme); } - this.verifierDistance(competence, arme) + this.verifierDistance(rollData) const dialog = await RdDRoll.create(this.attacker, rollData, { diff --git a/system.json b/system.json index 52c3f0c3..17b93db6 100644 --- a/system.json +++ b/system.json @@ -34,7 +34,7 @@ ], "url": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/", "license": "LICENSE.txt", - "version": "10.0.24", + "version": "10.0.25", "compatibility": { "minimum": "10", "verified": "10.286" @@ -333,7 +333,7 @@ ], "socket": true, "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.24.zip", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.0.25.zip", "gridDistance": 1, "gridUnits": "m", "primaryTokenAttribute": "sante.vie",