Ajout affichage distance

This commit is contained in:
sladecraven 2022-10-06 14:07:47 +02:00
parent fd6fbba9cb
commit 5382fb5df3
2 changed files with 19 additions and 7 deletions

View File

@ -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: `<strong>Indication MJ</strong> : 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,
{

View File

@ -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",