From ed4eafacfef4267d1f5fb218f1bf4269d3bb59b0 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 12 Dec 2021 14:48:32 +0100 Subject: [PATCH 1/3] Ajout de "for" dans les labels --- templates/item-nourritureboisson-sheet.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/templates/item-nourritureboisson-sheet.html b/templates/item-nourritureboisson-sheet.html index eb759ac8..fe8dc057 100644 --- a/templates/item-nourritureboisson-sheet.html +++ b/templates/item-nourritureboisson-sheet.html @@ -9,20 +9,20 @@ {{!-- Sheet Body --}}
- +
- +
{{#if data.boisson}}
- +
- +
{{#if data.alcoolise}} @@ -33,24 +33,24 @@ {{/if}} {{/if}}
- +
- +
- +
- +
- +
From 38d0ba2734ae1d5a1754786124c280f7e6ffbef4 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 12 Dec 2021 17:36:22 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Fix=20calculs=20coordonn=C3=A9es=20et=20dis?= =?UTF-8?q?tances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Utiliser les différents repères de cases: - coordonnées TMR A5 - oddq pour les coordonnées de case (ligne, colonne) - axial (q,r) pour effectuer les calculs de distance utiliser x, y rend la distinction de positions de pixels vs position dans la grille parfois ardue. Utilisation des coordonnées axiales pour le calcul de distance. --- module/rdd-commands.js | 2 +- module/rdd-tmr-dialog.js | 85 ++++++------ module/tmr-constants.js | 47 +++++++ module/tmr-utility.js | 214 +++++++++++++++---------------- module/tmr/conquete.js | 4 +- module/tmr/debordement.js | 3 +- module/tmr/demi-reve.js | 2 +- module/tmr/desorientation.js | 3 +- module/tmr/fermeture-cites.js | 3 +- module/tmr/pelerinage.js | 3 +- module/tmr/periple.js | 3 +- module/tmr/pixi-tmr.js | 18 +-- module/tmr/pont-impraticable.js | 3 +- module/tmr/present-cites.js | 3 +- module/tmr/quete-eaux.js | 2 +- module/tmr/rencontre.js | 2 +- module/tmr/reserve-extensible.js | 3 +- module/tmr/sort-reserve.js | 2 +- module/tmr/terre-attache.js | 2 +- module/tmr/trou-noir.js | 3 +- module/tmr/urgence-draconique.js | 5 +- 21 files changed, 228 insertions(+), 184 deletions(-) create mode 100644 module/tmr-constants.js diff --git a/module/rdd-commands.js b/module/rdd-commands.js index 94543a56..8793f306 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -155,7 +155,7 @@ export class RdDCommands { /* -------------------------------------------- */ /* Manage chat commands */ - processChatCommand(commandLine, content, msg) { + processChatCommand(commandLine, content = '', msg = {}) { // Setup new message's visibility let rollMode = game.settings.get("core", "rollMode"); if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperRecipients("GM"); diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index 14cec3b6..44f07cbb 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -1,6 +1,7 @@ import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RdDUtility } from "./rdd-utility.js"; -import { TMRUtility, tmrConstants } from "./tmr-utility.js"; +import { TMRUtility } from "./tmr-utility.js"; +import { tmrConstants } from "./tmr-constants.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js"; import { TMRRencontres } from "./tmr-rencontres.js"; @@ -14,8 +15,8 @@ import { Misc } from "./misc.js"; import { HtmlUtility } from "./html-utility.js"; import { ReglesOptionelles } from "./regles-optionelles.js"; import { RdDDice } from "./rdd-dice.js"; - /* -------------------------------------------- */ + export class RdDTMRDialog extends Dialog { static async create(html, actor, tmrData) { @@ -163,21 +164,21 @@ export class RdDTMRDialog extends Dialog { /* -------------------------------------------- */ async moveFromKey(move) { - let pos = TMRUtility.convertToCellPos(this._getActorCoord()); + let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord()); - if (move == 'top') pos.y -= 1; - if (move == 'bottom') pos.y += 1; - if (move.includes('left')) pos.x -= 1; - if (move.includes('right')) pos.x += 1; - if (pos.x % 2 == 1) { - if (move == 'top-left') pos.y -= 1; - if (move == 'top-right') pos.y -= 1; + if (move == 'top') oddq.row -= 1; + if (move == 'bottom') oddq.row += 1; + if (move.includes('left')) oddq.col -= 1; + if (move.includes('right')) oddq.col += 1; + if (oddq.col % 2 == 1) { + if (move == 'top-left') oddq.row -= 1; + if (move == 'top-right') oddq.row -= 1; } else { - if (move == 'bottom-left') pos.y += 1; - if (move == 'bottom-right') pos.y += 1; + if (move == 'bottom-left') oddq.row += 1; + if (move == 'bottom-right') oddq.row += 1; } - let targetCoord = TMRUtility.convertToTMRCoord(pos); + let targetCoord = TMRUtility.oddqToCoordTMR(oddq); await this._deplacerDemiReve(targetCoord, 'normal'); this.checkQuitterTMR(); } @@ -310,11 +311,11 @@ export class RdDTMRDialog extends Dialog { } /* -------------------------------------------- */ - colorierZoneRencontre(locList) { + colorierZoneRencontre(listCoordTMR) { this.currentRencontre.graphics = []; // Keep track of rectangles to delete it - this.currentRencontre.locList = duplicate(locList); // And track of allowed location - for (let loc of locList) { - let rect = this._getCaseRectangleCoord(loc); + this.currentRencontre.locList = duplicate(listCoordTMR); // And track of allowed location + for (let coordTMR of listCoordTMR) { + let rect = this._getCaseRectangleCoord(coordTMR); var rectDraw = new PIXI.Graphics(); rectDraw.beginFill(0xFFFF00, 0.3); // set the line style to have a width of 5 and set the color to red @@ -863,24 +864,21 @@ export class RdDTMRDialog extends Dialog { return; } - let origEvent = event.data.originalEvent; - let tmrObject = this; - - let eventPos = RdDTMRDialog._computeEventPos(origEvent); - await tmrObject._onClickTMRPos(eventPos); // Vérifier l'état des compteurs reve/fatigue/vie + let clickOddq = RdDTMRDialog._computeEventOddq(event.data.originalEvent); + await this._onClickTMRPos(clickOddq); // Vérifier l'état des compteurs reve/fatigue/vie } /* -------------------------------------------- */ - async _onClickTMRPos(eventPos) { - let currentPos = TMRUtility.convertToCellPos(this._getActorCoord()); + async _onClickTMRPos(clickOddq) { + let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord()); - console.log("deplacerDemiReve >>>>", currentPos, eventPos); + console.log("deplacerDemiReve >>>>", currentOddq, clickOddq); - let targetCoord = TMRUtility.convertToTMRCoord(eventPos); - let currentCoord = TMRUtility.convertToTMRCoord(currentPos); + let targetCoord = TMRUtility.oddqToCoordTMR(clickOddq); + let currentCoord = TMRUtility.oddqToCoordTMR(currentOddq); // Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter) - let deplacementType = this._calculDeplacement(targetCoord, currentCoord, currentPos, eventPos); + let deplacementType = this._calculDeplacement(targetCoord, currentCoord, currentOddq, clickOddq); // Si le deplacement est valide if (deplacementType == 'normal' || deplacementType == 'saut') { @@ -895,9 +893,9 @@ export class RdDTMRDialog extends Dialog { } /* -------------------------------------------- */ - _calculDeplacement(targetCoord, currentCoord, currentPos, eventPos) { - let isInArea = this.rencontreState == 'aucune' - ? this.isTerreAttache(targetCoord) || this.isConnaissanceFleuve(currentCoord, targetCoord) || !RdDTMRDialog._horsDePortee(currentPos, eventPos) + _calculDeplacement(targetCoord, currentCoord, fromOddq, toOddq) { + const isInArea = this.rencontreState == 'aucune' + ? (this.isTerreAttache(targetCoord) || this.isConnaissanceFleuve(currentCoord, targetCoord) || TMRUtility.distanceOddq(fromOddq, toOddq) <= 1) : this.currentRencontre?.locList.find(coord => coord == targetCoord) ?? false if (isInArea) { switch (this.rencontreState) { @@ -1000,35 +998,26 @@ export class RdDTMRDialog extends Dialog { } /* -------------------------------------------- */ - static _computeEventPos(origEvent) { + static _computeEventOddq(origEvent) { let canvasRect = origEvent.target.getBoundingClientRect(); let x = origEvent.clientX - canvasRect.left; let y = origEvent.clientY - canvasRect.top; - let cellx = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12] - y -= (cellx % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; - let celly = Math.floor(y / tmrConstants.cellh); // [From 0 -> 14] - return { x: cellx, y: celly }; + let col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12] + y -= (col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; + let row = Math.floor(y / tmrConstants.cellh); // [From 0 -> 14] + return { col: col, row: row }; } - /* -------------------------------------------- */ - static _horsDePortee(origin, target) { - return Math.abs(target.x - origin.x) > 1 - || Math.abs(target.y - origin.y) > 1 - || (origin.y == 0 && target.y > origin.y && target.x != origin.x && origin.x % 2 == 0) - || (target.y == 0 && target.y < origin.y && target.x != origin.x && origin.x % 2 == 1); - } - - /* -------------------------------------------- */ /** Retourne les coordonnées x, h, w, h du rectangle d'une case donnée */ _getCaseRectangleCoord(coord) { - return this.pixiTMR.getCaseRectangle(TMRUtility.convertToCellPos(coord)); + return this.pixiTMR.getCaseRectangle(TMRUtility.coordTMRToOddq(coord)); } /* -------------------------------------------- */ _setTokenPosition(token) { if (!this.cacheTMR) { - this.pixiTMR.setPosition(token.sprite, TMRUtility.convertToCellPos(token.coordTMR())); + this.pixiTMR.setPosition(token.sprite, TMRUtility.coordTMRToOddq(token.coordTMR())); } } @@ -1046,5 +1035,3 @@ export class RdDTMRDialog extends Dialog { this._setTokenPosition(token); } } - - diff --git a/module/tmr-constants.js b/module/tmr-constants.js new file mode 100644 index 00000000..b5a448d3 --- /dev/null +++ b/module/tmr-constants.js @@ -0,0 +1,47 @@ + +/* -------------------------------------------- */ +export const tmrConstants = { + col1_y: 30, + col2_y: 55, + cellw: 55, + cellh: 55, + gridx: 28, + gridy: 28, + // tailles + third: 18, + half: 27.5, + twoThird: 36, + full: 55, + // decallages + center: { x: 0, y: 0 }, + top: { x: 0, y: -11.5 }, + topLeft: { x: -11.5, y: -11.5 }, + left: { x: -11.5, y: 0 }, + bottomLeft: { x: -11.5, y: 11.5 }, + bottom: { x: 0, y: 11.5 }, + bottomRight: { x: 11.5, y: 11.5 }, + right: { x: 11.5, y: 0 }, + topRight: { x: 11.5, y: -11.5 }, +} + +// couleurs +export const tmrColors = { + sort: 0xFF8800, + tetes: 0xA000FF, + souffle: 0x804040, + queues: 0xAA4040, + trounoir: 0x401060, + demireve: 0x00FFEE, + rencontre: 0xFF0000, + casehumide: 0x1050F0, +} +export const tmrTokenZIndex = { + sort: 40, + tetes: 20, + casehumide: 10, + conquete: 30, + rencontre: 50, + trounoir: 60, + demireve: 70, + tooltip: 100, +} diff --git a/module/tmr-utility.js b/module/tmr-utility.js index a54de95e..cebf8e83 100644 --- a/module/tmr-utility.js +++ b/module/tmr-utility.js @@ -2,6 +2,7 @@ import { TMRRencontres } from "./tmr-rencontres.js"; import { Misc } from "./misc.js"; import { Grammar } from "./grammar.js"; import { RdDDice } from "./rdd-dice.js"; +import { tmrConstants } from "./tmr-constants.js"; /* -------------------------------------------- */ const TMRMapping = { @@ -232,61 +233,14 @@ const caseSpecificModes = ["attache", "trounoir", "debordement", "reserve_extens /* -------------------------------------------- */ const tmrRandomMovePatten = - [{ name: 'top', x: 0, y: -1 }, - { name: 'topright', x: 1, y: -1 }, - { name: 'botright', x: 1, y: 1 }, - { name: 'bot', x: 0, y: 1 }, - { name: 'botleft', x: -1, y: 1 }, - { name: 'topleft', x: -1, y: -1 } + [{ name: 'top', col: 0, row: -1 }, + { name: 'topright', col: 1, row: -1 }, + { name: 'botright', col: 1, row: 1 }, + { name: 'bot', col: 0, row: 1 }, + { name: 'botleft', col: -1, row: 1 }, + { name: 'topleft', col: -1, row: -1 } ] -/* -------------------------------------------- */ -export const tmrConstants = { - col1_y: 30, - col2_y: 55, - cellw: 55, - cellh: 55, - gridx: 28, - gridy: 28, - // tailles - third: 18, - half: 27.5, - twoThird: 36, - full: 55, - // decallages - center: { x: 0, y: 0 }, - top: { x: 0, y: -11.5 }, - topLeft: { x: -11.5, y: -11.5 }, - left: { x: -11.5, y: 0 }, - bottomLeft: { x: -11.5, y: 11.5 }, - bottom: { x: 0, y: 11.5 }, - bottomRight: { x: 11.5, y: 11.5 }, - right: { x: 11.5, y: 0 }, - topRight: { x: 11.5, y: -11.5 }, -} - -// couleurs -export const tmrColors = { - sort: 0xFF8800, - tetes: 0xA000FF, - souffle: 0x804040, - queues: 0xAA4040, - trounoir: 0x401060, - demireve: 0x00FFEE, - rencontre: 0xFF0000, - casehumide: 0x1050F0, -} -export const tmrTokenZIndex = { - sort: 40, - tetes: 20, - casehumide: 10, - conquete: 30, - rencontre: 50, - trounoir: 60, - demireve: 70, - tooltip: 100, -} - /* -------------------------------------------- */ /* -------------------------------------------- */ @@ -295,6 +249,7 @@ export class TMRUtility { for (let coord in TMRMapping) { const tmr = TMRMapping[coord]; tmr.coord = coord; + tmr.oddq = TMRUtility.coordTMRToOddq(coord); tmr.genre = TMRType[tmr.type].genre; } let tmrByType = Misc.classify(Object.values(TMRMapping)); @@ -303,12 +258,6 @@ export class TMRUtility { } } - /* -------------------------------------------- */ - static convertToTMRCoord(pos) { - let letterX = String.fromCharCode(65 + (pos.x)); - return letterX + (pos.y + 1) - } - /* -------------------------------------------- */ static verifyTMRCoord(coord) { let TMRregexp = new RegExp(/([A-M])(\d+)/g); @@ -321,13 +270,6 @@ export class TMRUtility { return false; } - /* -------------------------------------------- */ - static convertToCellPos(coordTMR) { - let x = coordTMR.charCodeAt(0) - 65; - let y = coordTMR.substr(1) - 1; - return { x: x, y: y } - } - /* -------------------------------------------- */ static getTMR(coord) { return TMRMapping[coord]; @@ -400,13 +342,14 @@ export class TMRUtility { } /* -------------------------------------------- */ - static async deplaceTMRSelonPattern(actor, coord, direction, nTime) { + static async deplaceTMRSelonPattern(actor, coordTMR, direction, nTime) { + let coord; for (let i = 0; i < nTime; i++) { - let currentPos = TMRUtility.convertToCellPos(coord); - currentPos.x = currentPos.x + direction.x; - currentPos.y = currentPos.y + direction.y; - if (this._checkTMRCoord(currentPos.x, currentPos.y)) { // Sortie de carte ! Ré-insertion aléatoire - coord = TMRUtility.getTMR(TMRUtility.convertToTMRCoord(currentPos)); + let currentOddq = TMRUtility.coordTMRToOddq(coordTMR); + currentOddq.col = currentOddq.col + direction.col; + currentOddq.row = currentOddq.row + direction.row; + if (this.isOddqInTMR(currentOddq)) { // Sortie de carte ! Ré-insertion aléatoire + coord = TMRUtility.getTMR(TMRUtility.oddqToCoordTMR(currentOddq)); } else { coord = await actor.reinsertionAleatoire('Sortie de carte'); } @@ -437,22 +380,6 @@ export class TMRUtility { return await RdDDice.rollOneOf(TMRUtility.filterTMR(filter)) } - /* -------------------------------------------- */ - static _checkTMRCoord(x, y) { - if (x >= 0 && x < 13 && y >= 0 && y < 14) return true; - if (x >= 0 && x < 13 && x % 2 == 0 && y == 14) return true; - return false; - } - - /* -------------------------------------------- */ - static computeRealPictureCoordinates(coordXY, tmrConstants) { - let decallagePairImpair = (coordXY.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; - return { - x: tmrConstants.gridx + (coordXY.x * tmrConstants.cellw), - y: tmrConstants.gridy + (coordXY.y * tmrConstants.cellh) + decallagePairImpair - } - } - /* -------------------------------------------- */ static getSortsReserve(reserveList, coord) { // TODO : Gérer les têtes spéciales réserve! @@ -470,16 +397,15 @@ export class TMRUtility { * */ static getTMRPortee(coord, portee) { - let centerPos = this.convertToCellPos(coord); - let posPic = this.computeRealPictureCoordinates(centerPos, tmrConstants); + let centerOddq = this.coordTMRToOddq(coord); let caseList = []; - for (let dx = -portee; dx <= portee; dx++) { // Loop thru lines - for (let dy = -portee; dy <= portee; dy++) { // Loop thru lines - const currentPos = { x: centerPos.x + dx, y: centerPos.y + dy }; - if (this._checkTMRCoord(currentPos.x, currentPos.y)) { // Coordinate is valie - let dist = this.distancePosTMR(centerPos, currentPos); + for (let dcol = -portee; dcol <= portee; dcol++) { // rows + for (let drow = -portee; drow <= portee; drow++) { // columns + const currentOddq = { col: centerOddq.col + dcol, row: centerOddq.row + drow }; + if (this.isOddqInTMR(currentOddq)) { + let dist = this.distanceOddq(centerOddq, currentOddq); if (dist <= portee) { - caseList.push(this.convertToTMRCoord(currentPos)); // Inside the area + caseList.push(this.oddqToCoordTMR(currentOddq)); // Inside the area } } } @@ -488,21 +414,93 @@ export class TMRUtility { } /* -------------------------------------------- */ - static distanceTMR(coord1, coord2) { - let pos1 = this.convertToCellPos(coord1); - let pos2 = this.convertToCellPos(coord2); - return this.distancePosTMR(pos1, pos2); + // https://www.redblobgames.com/grids/hexagons/#distances + // TMR Letter-row correspond to "odd-q" grid (letter => col, numeric => row ) + + /* -------------------------------------------- */ + static coordTMRToOddq(coordTMR) { + let col = coordTMR.charCodeAt(0) - 65; + let row = coordTMR.substr(1) - 1; + return { col: col, row: row } } /* -------------------------------------------- */ - static distancePosTMR(pos1, pos2) { - const dx = pos2.x - pos1.x; - const dy = pos2.y - pos1.y; - const abs_dx = Math.abs(dx); - const abs_dy = Math.abs(dy); - const distance = Math.sign(dx) == Math.sign(dy) ? Math.max(abs_dx, abs_dy) : (abs_dx + abs_dy); - return distance; + static oddqToCoordTMR(oddq) { + let letterX = String.fromCharCode(65 + (oddq.col)); + return letterX + (oddq.row + 1) } -} + /* -------------------------------------------- */ + static isOddqInTMR(oddq) { + const col = oddq.col; + const row = oddq.row; + return ( + col >= 0 && col < 13 && + row >= 0 && + (row + col % 2 <= 14) + ); + // if (x >= 0 && x < 13 && y >= 0 && y < 14) return true; + // if (x >= 0 && x < 13 && x % 2 == 0 && y == 14) return true; + // return false; + } + + /* -------------------------------------------- */ + static distanceCoordTMR(coord1, coord2) { + let oddq1 = this.coordTMRToOddq(coord1); + let oddq2 = this.coordTMRToOddq(coord2); + return this.distanceOddq(oddq1, oddq2); + } + + /* -------------------------------------------- */ + static distanceOddq(oddq1, oddq2) { + const axial1 = TMRUtility.oddqToAxial(oddq1); + const axial2 = TMRUtility.oddqToAxial(oddq2); + return TMRUtility.distanceAxial(axial1, axial2); + + // const dx = oddq2.col - oddq1.col; + // const dy = oddq2.row - oddq1.row; + // const abs_dx = Math.abs(dx); + // const abs_dy = Math.abs(dy); + // const distance = Math.sign(dx) == Math.sign(dy) ? Math.max(abs_dx, abs_dy) : (abs_dx + abs_dy); + // return distance; + } + + static oddqToAxial(pos) { + return { + q: pos.col, + r: pos.row - (pos.col - (pos.col & 1)) / 2 + } + } + + static distanceAxial(a, b) { + const vector = TMRUtility.axial_subtract(a, b) + return (Math.abs(vector.q) + + Math.abs(vector.q + vector.r) + + Math.abs(vector.r)) / 2 + } + + static axial_subtract(a, b) { + return { + q: a.q- b.q, + r: a.r - b.r + }; + } + + // function axial_to_cube(hex): + // var q = hex.q + // var r = hex.r + // var s = -q - r + // return Cube(q, r, s) + // } + + + // /* -------------------------------------------- */ + // static computeRealPictureCoordinates(coordOddq) { + // let decallagePairImpair = (coordOddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; + // return { + // x: tmrConstants.gridx + (coordOddq.col * tmrConstants.cellw), + // y: tmrConstants.gridy + (coordOddq.row * tmrConstants.cellh) + decallagePairImpair + // } + // } +} \ No newline at end of file diff --git a/module/tmr/conquete.js b/module/tmr/conquete.js index 0773aa93..6168ad34 100644 --- a/module/tmr/conquete.js +++ b/module/tmr/conquete.js @@ -1,7 +1,9 @@ import { Grammar } from "../grammar.js"; import { Misc } from "../misc.js"; import { RdDDice } from "../rdd-dice.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; + import { Draconique } from "./draconique.js"; export class Conquete extends Draconique { diff --git a/module/tmr/debordement.js b/module/tmr/debordement.js index a9b3a998..db4efa32 100644 --- a/module/tmr/debordement.js +++ b/module/tmr/debordement.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class Debordement extends Draconique { diff --git a/module/tmr/demi-reve.js b/module/tmr/demi-reve.js index 1d05baec..0fa0e8f5 100644 --- a/module/tmr/demi-reve.js +++ b/module/tmr/demi-reve.js @@ -1,4 +1,4 @@ -import { tmrColors, tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class DemiReve extends Draconique { diff --git a/module/tmr/desorientation.js b/module/tmr/desorientation.js index e1fc7855..fe3958ea 100644 --- a/module/tmr/desorientation.js +++ b/module/tmr/desorientation.js @@ -1,7 +1,8 @@ import { Grammar } from "../grammar.js"; import { Misc } from "../misc.js"; import { RdDDice } from "../rdd-dice.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRType, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility, TMRType} from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class Desorientation extends Draconique { diff --git a/module/tmr/fermeture-cites.js b/module/tmr/fermeture-cites.js index 457d4a7b..6e949ae6 100644 --- a/module/tmr/fermeture-cites.js +++ b/module/tmr/fermeture-cites.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class FermetureCites extends Draconique { diff --git a/module/tmr/pelerinage.js b/module/tmr/pelerinage.js index a8cdea37..9917f9a2 100644 --- a/module/tmr/pelerinage.js +++ b/module/tmr/pelerinage.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class Pelerinage extends Draconique { diff --git a/module/tmr/periple.js b/module/tmr/periple.js index 9ad0d83f..326e16e4 100644 --- a/module/tmr/periple.js +++ b/module/tmr/periple.js @@ -1,6 +1,7 @@ import { Grammar } from "../grammar.js"; import { RdDDice } from "../rdd-dice.js"; -import { tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class Periple extends Draconique { diff --git a/module/tmr/pixi-tmr.js b/module/tmr/pixi-tmr.js index d28616bd..368e0e00 100644 --- a/module/tmr/pixi-tmr.js +++ b/module/tmr/pixi-tmr.js @@ -1,4 +1,4 @@ -import { tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; const tooltipStyle = new PIXI.TextStyle({ fontFamily: 'CaslonAntique', @@ -130,18 +130,18 @@ export class PixiTMR { } } - setPosition( sprite, pos) { - let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; + setPosition( sprite, oddq) { + let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; let dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x; let dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y; - sprite.x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) + dx; - sprite.y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) + dy + decallagePairImpair; + sprite.x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) + dx; + sprite.y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) + dy + decallagePairImpair; } - getCaseRectangle(pos) { - let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; - let x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) - (tmrConstants.cellw / 2); - let y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair; + getCaseRectangle(oddq) { + let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; + let x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) - (tmrConstants.cellw / 2); + let y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair; return { x: x, y: y, w: tmrConstants.cellw, h: tmrConstants.cellh }; } diff --git a/module/tmr/pont-impraticable.js b/module/tmr/pont-impraticable.js index 501dff03..7728cee1 100644 --- a/module/tmr/pont-impraticable.js +++ b/module/tmr/pont-impraticable.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class PontImpraticable extends Draconique { diff --git a/module/tmr/present-cites.js b/module/tmr/present-cites.js index 8b4c4cce..efa9f7f0 100644 --- a/module/tmr/present-cites.js +++ b/module/tmr/present-cites.js @@ -1,6 +1,7 @@ import { ChatUtility } from "../chat-utility.js"; import { Grammar } from "../grammar.js"; -import { tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class PresentCites extends Draconique { diff --git a/module/tmr/quete-eaux.js b/module/tmr/quete-eaux.js index 95f92e9c..ae5b979b 100644 --- a/module/tmr/quete-eaux.js +++ b/module/tmr/quete-eaux.js @@ -1,5 +1,5 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class QueteEaux extends Draconique { diff --git a/module/tmr/rencontre.js b/module/tmr/rencontre.js index 6ace25e5..d71f2f66 100644 --- a/module/tmr/rencontre.js +++ b/module/tmr/rencontre.js @@ -1,4 +1,4 @@ -import { tmrColors, tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class Rencontre extends Draconique { diff --git a/module/tmr/reserve-extensible.js b/module/tmr/reserve-extensible.js index 35ba770c..3279301d 100644 --- a/module/tmr/reserve-extensible.js +++ b/module/tmr/reserve-extensible.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class ReserveExtensible extends Draconique { diff --git a/module/tmr/sort-reserve.js b/module/tmr/sort-reserve.js index 30229353..1f632963 100644 --- a/module/tmr/sort-reserve.js +++ b/module/tmr/sort-reserve.js @@ -1,4 +1,4 @@ -import { tmrColors, tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class SortReserve extends Draconique { diff --git a/module/tmr/terre-attache.js b/module/tmr/terre-attache.js index c5c85ef9..6ef5cf38 100644 --- a/module/tmr/terre-attache.js +++ b/module/tmr/terre-attache.js @@ -1,5 +1,5 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class TerreAttache extends Draconique { diff --git a/module/tmr/trou-noir.js b/module/tmr/trou-noir.js index 454746be..577ad295 100644 --- a/module/tmr/trou-noir.js +++ b/module/tmr/trou-noir.js @@ -1,5 +1,6 @@ import { Grammar } from "../grammar.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class TrouNoir extends Draconique { diff --git a/module/tmr/urgence-draconique.js b/module/tmr/urgence-draconique.js index d0fb3e0b..8972ff36 100644 --- a/module/tmr/urgence-draconique.js +++ b/module/tmr/urgence-draconique.js @@ -2,7 +2,8 @@ import { ChatUtility } from "../chat-utility.js"; import { Grammar } from "../grammar.js"; import { Misc } from "../misc.js"; import { RdDRollTables } from "../rdd-rolltables.js"; -import { tmrColors, tmrConstants, tmrTokenZIndex, TMRUtility } from "../tmr-utility.js"; +import { TMRUtility } from "../tmr-utility.js"; +import { tmrConstants, tmrColors, tmrTokenZIndex } from "../tmr-constants.js"; import { Draconique } from "./draconique.js"; export class UrgenceDraconique extends Draconique { @@ -29,7 +30,7 @@ export class UrgenceDraconique extends Draconique { } else { const demiReve = actor.getDemiReve(); - coordSortsReserve.sort(Misc.ascending(t => TMRUtility.distanceTMR(t, demiReve))); + coordSortsReserve.sort(Misc.ascending(t => TMRUtility.distanceCoordTMR(t, demiReve))); const tmr = TMRUtility.getTMR(coordSortsReserve[0]); await this.createCaseTmr(actor, 'Urgence draconique: ' + tmr.label, tmr, queue.id); } From d702725bf89fd923ca4fb66f8a92b783fbc6e881 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 12 Dec 2021 17:38:45 +0100 Subject: [PATCH 3/3] Version 1.5.47 --- system.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system.json b/system.json index e8da1687..4449a566 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.5.46", + "version": "1.5.47", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.8.0", "compatibleCoreVersion": "0.8.9",