Fix calculs coordonnées et distances

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.
This commit is contained in:
Vincent Vandemeulebrouck 2021-12-12 17:36:22 +01:00
parent ed4eafacfe
commit 38d0ba2734
21 changed files with 228 additions and 184 deletions

View File

@ -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");

View File

@ -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);
}
}

47
module/tmr-constants.js Normal file
View File

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

View File

@ -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
// }
// }
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 };
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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);
}