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 */ /* Manage chat commands */
processChatCommand(commandLine, content, msg) { processChatCommand(commandLine, content = '', msg = {}) {
// Setup new message's visibility // Setup new message's visibility
let rollMode = game.settings.get("core", "rollMode"); let rollMode = game.settings.get("core", "rollMode");
if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperRecipients("GM"); if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperRecipients("GM");

View File

@ -1,6 +1,7 @@
import { RollDataAjustements } from "./rolldata-ajustements.js"; import { RollDataAjustements } from "./rolldata-ajustements.js";
import { RdDUtility } from "./rdd-utility.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 { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js"; import { RdDTMRRencontreDialog } from "./rdd-tmr-rencontre-dialog.js";
import { TMRRencontres } from "./tmr-rencontres.js"; import { TMRRencontres } from "./tmr-rencontres.js";
@ -14,8 +15,8 @@ import { Misc } from "./misc.js";
import { HtmlUtility } from "./html-utility.js"; import { HtmlUtility } from "./html-utility.js";
import { ReglesOptionelles } from "./regles-optionelles.js"; import { ReglesOptionelles } from "./regles-optionelles.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDTMRDialog extends Dialog { export class RdDTMRDialog extends Dialog {
static async create(html, actor, tmrData) { static async create(html, actor, tmrData) {
@ -163,21 +164,21 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
async moveFromKey(move) { async moveFromKey(move) {
let pos = TMRUtility.convertToCellPos(this._getActorCoord()); let oddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
if (move == 'top') pos.y -= 1; if (move == 'top') oddq.row -= 1;
if (move == 'bottom') pos.y += 1; if (move == 'bottom') oddq.row += 1;
if (move.includes('left')) pos.x -= 1; if (move.includes('left')) oddq.col -= 1;
if (move.includes('right')) pos.x += 1; if (move.includes('right')) oddq.col += 1;
if (pos.x % 2 == 1) { if (oddq.col % 2 == 1) {
if (move == 'top-left') pos.y -= 1; if (move == 'top-left') oddq.row -= 1;
if (move == 'top-right') pos.y -= 1; if (move == 'top-right') oddq.row -= 1;
} else { } else {
if (move == 'bottom-left') pos.y += 1; if (move == 'bottom-left') oddq.row += 1;
if (move == 'bottom-right') pos.y += 1; if (move == 'bottom-right') oddq.row += 1;
} }
let targetCoord = TMRUtility.convertToTMRCoord(pos); let targetCoord = TMRUtility.oddqToCoordTMR(oddq);
await this._deplacerDemiReve(targetCoord, 'normal'); await this._deplacerDemiReve(targetCoord, 'normal');
this.checkQuitterTMR(); 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.graphics = []; // Keep track of rectangles to delete it
this.currentRencontre.locList = duplicate(locList); // And track of allowed location this.currentRencontre.locList = duplicate(listCoordTMR); // And track of allowed location
for (let loc of locList) { for (let coordTMR of listCoordTMR) {
let rect = this._getCaseRectangleCoord(loc); let rect = this._getCaseRectangleCoord(coordTMR);
var rectDraw = new PIXI.Graphics(); var rectDraw = new PIXI.Graphics();
rectDraw.beginFill(0xFFFF00, 0.3); rectDraw.beginFill(0xFFFF00, 0.3);
// set the line style to have a width of 5 and set the color to red // 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; return;
} }
let origEvent = event.data.originalEvent; let clickOddq = RdDTMRDialog._computeEventOddq(event.data.originalEvent);
let tmrObject = this; await this._onClickTMRPos(clickOddq); // Vérifier l'état des compteurs reve/fatigue/vie
let eventPos = RdDTMRDialog._computeEventPos(origEvent);
await tmrObject._onClickTMRPos(eventPos); // Vérifier l'état des compteurs reve/fatigue/vie
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _onClickTMRPos(eventPos) { async _onClickTMRPos(clickOddq) {
let currentPos = TMRUtility.convertToCellPos(this._getActorCoord()); let currentOddq = TMRUtility.coordTMRToOddq(this._getActorCoord());
console.log("deplacerDemiReve >>>>", currentPos, eventPos); console.log("deplacerDemiReve >>>>", currentOddq, clickOddq);
let targetCoord = TMRUtility.convertToTMRCoord(eventPos); let targetCoord = TMRUtility.oddqToCoordTMR(clickOddq);
let currentCoord = TMRUtility.convertToTMRCoord(currentPos); let currentCoord = TMRUtility.oddqToCoordTMR(currentOddq);
// Validation de la case de destination (gestion du cas des rencontres qui peuvent téléporter) // 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 // Si le deplacement est valide
if (deplacementType == 'normal' || deplacementType == 'saut') { if (deplacementType == 'normal' || deplacementType == 'saut') {
@ -895,9 +893,9 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_calculDeplacement(targetCoord, currentCoord, currentPos, eventPos) { _calculDeplacement(targetCoord, currentCoord, fromOddq, toOddq) {
let isInArea = this.rencontreState == 'aucune' const isInArea = this.rencontreState == 'aucune'
? this.isTerreAttache(targetCoord) || this.isConnaissanceFleuve(currentCoord, targetCoord) || !RdDTMRDialog._horsDePortee(currentPos, eventPos) ? (this.isTerreAttache(targetCoord) || this.isConnaissanceFleuve(currentCoord, targetCoord) || TMRUtility.distanceOddq(fromOddq, toOddq) <= 1)
: this.currentRencontre?.locList.find(coord => coord == targetCoord) ?? false : this.currentRencontre?.locList.find(coord => coord == targetCoord) ?? false
if (isInArea) { if (isInArea) {
switch (this.rencontreState) { switch (this.rencontreState) {
@ -1000,35 +998,26 @@ export class RdDTMRDialog extends Dialog {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _computeEventPos(origEvent) { static _computeEventOddq(origEvent) {
let canvasRect = origEvent.target.getBoundingClientRect(); let canvasRect = origEvent.target.getBoundingClientRect();
let x = origEvent.clientX - canvasRect.left; let x = origEvent.clientX - canvasRect.left;
let y = origEvent.clientY - canvasRect.top; let y = origEvent.clientY - canvasRect.top;
let cellx = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12] let col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]
y -= (cellx % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; y -= (col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
let celly = Math.floor(y / tmrConstants.cellh); // [From 0 -> 14] let row = Math.floor(y / tmrConstants.cellh); // [From 0 -> 14]
return { x: cellx, y: celly }; 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 */ /** Retourne les coordonnées x, h, w, h du rectangle d'une case donnée */
_getCaseRectangleCoord(coord) { _getCaseRectangleCoord(coord) {
return this.pixiTMR.getCaseRectangle(TMRUtility.convertToCellPos(coord)); return this.pixiTMR.getCaseRectangle(TMRUtility.coordTMRToOddq(coord));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_setTokenPosition(token) { _setTokenPosition(token) {
if (!this.cacheTMR) { 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); 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 { Misc } from "./misc.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { RdDDice } from "./rdd-dice.js"; import { RdDDice } from "./rdd-dice.js";
import { tmrConstants } from "./tmr-constants.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
const TMRMapping = { const TMRMapping = {
@ -232,61 +233,14 @@ const caseSpecificModes = ["attache", "trounoir", "debordement", "reserve_extens
/* -------------------------------------------- */ /* -------------------------------------------- */
const tmrRandomMovePatten = const tmrRandomMovePatten =
[{ name: 'top', x: 0, y: -1 }, [{ name: 'top', col: 0, row: -1 },
{ name: 'topright', x: 1, y: -1 }, { name: 'topright', col: 1, row: -1 },
{ name: 'botright', x: 1, y: 1 }, { name: 'botright', col: 1, row: 1 },
{ name: 'bot', x: 0, y: 1 }, { name: 'bot', col: 0, row: 1 },
{ name: 'botleft', x: -1, y: 1 }, { name: 'botleft', col: -1, row: 1 },
{ name: 'topleft', x: -1, y: -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) { for (let coord in TMRMapping) {
const tmr = TMRMapping[coord]; const tmr = TMRMapping[coord];
tmr.coord = coord; tmr.coord = coord;
tmr.oddq = TMRUtility.coordTMRToOddq(coord);
tmr.genre = TMRType[tmr.type].genre; tmr.genre = TMRType[tmr.type].genre;
} }
let tmrByType = Misc.classify(Object.values(TMRMapping)); 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) { static verifyTMRCoord(coord) {
let TMRregexp = new RegExp(/([A-M])(\d+)/g); let TMRregexp = new RegExp(/([A-M])(\d+)/g);
@ -321,13 +270,6 @@ export class TMRUtility {
return false; 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) { static getTMR(coord) {
return TMRMapping[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++) { for (let i = 0; i < nTime; i++) {
let currentPos = TMRUtility.convertToCellPos(coord); let currentOddq = TMRUtility.coordTMRToOddq(coordTMR);
currentPos.x = currentPos.x + direction.x; currentOddq.col = currentOddq.col + direction.col;
currentPos.y = currentPos.y + direction.y; currentOddq.row = currentOddq.row + direction.row;
if (this._checkTMRCoord(currentPos.x, currentPos.y)) { // Sortie de carte ! Ré-insertion aléatoire if (this.isOddqInTMR(currentOddq)) { // Sortie de carte ! Ré-insertion aléatoire
coord = TMRUtility.getTMR(TMRUtility.convertToTMRCoord(currentPos)); coord = TMRUtility.getTMR(TMRUtility.oddqToCoordTMR(currentOddq));
} else { } else {
coord = await actor.reinsertionAleatoire('Sortie de carte'); coord = await actor.reinsertionAleatoire('Sortie de carte');
} }
@ -437,22 +380,6 @@ export class TMRUtility {
return await RdDDice.rollOneOf(TMRUtility.filterTMR(filter)) 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) { static getSortsReserve(reserveList, coord) {
// TODO : Gérer les têtes spéciales réserve! // TODO : Gérer les têtes spéciales réserve!
@ -470,16 +397,15 @@ export class TMRUtility {
* *
*/ */
static getTMRPortee(coord, portee) { static getTMRPortee(coord, portee) {
let centerPos = this.convertToCellPos(coord); let centerOddq = this.coordTMRToOddq(coord);
let posPic = this.computeRealPictureCoordinates(centerPos, tmrConstants);
let caseList = []; let caseList = [];
for (let dx = -portee; dx <= portee; dx++) { // Loop thru lines for (let dcol = -portee; dcol <= portee; dcol++) { // rows
for (let dy = -portee; dy <= portee; dy++) { // Loop thru lines for (let drow = -portee; drow <= portee; drow++) { // columns
const currentPos = { x: centerPos.x + dx, y: centerPos.y + dy }; const currentOddq = { col: centerOddq.col + dcol, row: centerOddq.row + drow };
if (this._checkTMRCoord(currentPos.x, currentPos.y)) { // Coordinate is valie if (this.isOddqInTMR(currentOddq)) {
let dist = this.distancePosTMR(centerPos, currentPos); let dist = this.distanceOddq(centerOddq, currentOddq);
if (dist <= portee) { 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) { // https://www.redblobgames.com/grids/hexagons/#distances
let pos1 = this.convertToCellPos(coord1); // TMR Letter-row correspond to "odd-q" grid (letter => col, numeric => row )
let pos2 = this.convertToCellPos(coord2);
return this.distancePosTMR(pos1, pos2); /* -------------------------------------------- */
static coordTMRToOddq(coordTMR) {
let col = coordTMR.charCodeAt(0) - 65;
let row = coordTMR.substr(1) - 1;
return { col: col, row: row }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static distancePosTMR(pos1, pos2) { static oddqToCoordTMR(oddq) {
const dx = pos2.x - pos1.x; let letterX = String.fromCharCode(65 + (oddq.col));
const dy = pos2.y - pos1.y; return letterX + (oddq.row + 1)
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 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 { Grammar } from "../grammar.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDDice } from "../rdd-dice.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"; import { Draconique } from "./draconique.js";
export class Conquete extends Draconique { export class Conquete extends Draconique {

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class Debordement extends Draconique { 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"; import { Draconique } from "./draconique.js";
export class DemiReve extends Draconique { export class DemiReve extends Draconique {

View File

@ -1,7 +1,8 @@
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDDice } from "../rdd-dice.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"; import { Draconique } from "./draconique.js";
export class Desorientation extends Draconique { export class Desorientation extends Draconique {

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class FermetureCites extends Draconique { export class FermetureCites extends Draconique {

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.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"; import { Draconique } from "./draconique.js";
export class Pelerinage extends Draconique { export class Pelerinage extends Draconique {

View File

@ -1,6 +1,7 @@
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { RdDDice } from "../rdd-dice.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"; import { Draconique } from "./draconique.js";
export class Periple extends Draconique { 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({ const tooltipStyle = new PIXI.TextStyle({
fontFamily: 'CaslonAntique', fontFamily: 'CaslonAntique',
@ -130,18 +130,18 @@ export class PixiTMR {
} }
} }
setPosition( sprite, pos) { setPosition( sprite, oddq) {
let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
let dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x; let dx = (sprite.decallage == undefined) ? 0 : sprite.decallage.x;
let dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y; let dy = (sprite.decallage == undefined) ? 0 : sprite.decallage.y;
sprite.x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) + dx; sprite.x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) + dx;
sprite.y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) + dy + decallagePairImpair; sprite.y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) + dy + decallagePairImpair;
} }
getCaseRectangle(pos) { getCaseRectangle(oddq) {
let decallagePairImpair = (pos.x % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y; let decallagePairImpair = (oddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
let x = tmrConstants.gridx + (pos.x * tmrConstants.cellw) - (tmrConstants.cellw / 2); let x = tmrConstants.gridx + (oddq.col * tmrConstants.cellw) - (tmrConstants.cellw / 2);
let y = tmrConstants.gridy + (pos.y * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair; let y = tmrConstants.gridy + (oddq.row * tmrConstants.cellh) - (tmrConstants.cellh / 2) + decallagePairImpair;
return { x: x, y: y, w: tmrConstants.cellw, h: tmrConstants.cellh }; return { x: x, y: y, w: tmrConstants.cellw, h: tmrConstants.cellh };
} }

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class PontImpraticable extends Draconique { export class PontImpraticable extends Draconique {

View File

@ -1,6 +1,7 @@
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { Grammar } from "../grammar.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"; import { Draconique } from "./draconique.js";
export class PresentCites extends Draconique { export class PresentCites extends Draconique {

View File

@ -1,5 +1,5 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class QueteEaux extends Draconique { 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"; import { Draconique } from "./draconique.js";
export class Rencontre extends Draconique { export class Rencontre extends Draconique {

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class ReserveExtensible extends Draconique { 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"; import { Draconique } from "./draconique.js";
export class SortReserve extends Draconique { export class SortReserve extends Draconique {

View File

@ -1,5 +1,5 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class TerreAttache extends Draconique { export class TerreAttache extends Draconique {

View File

@ -1,5 +1,6 @@
import { Grammar } from "../grammar.js"; 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"; import { Draconique } from "./draconique.js";
export class TrouNoir extends Draconique { export class TrouNoir extends Draconique {

View File

@ -2,7 +2,8 @@ import { ChatUtility } from "../chat-utility.js";
import { Grammar } from "../grammar.js"; import { Grammar } from "../grammar.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDRollTables } from "../rdd-rolltables.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"; import { Draconique } from "./draconique.js";
export class UrgenceDraconique extends Draconique { export class UrgenceDraconique extends Draconique {
@ -29,7 +30,7 @@ export class UrgenceDraconique extends Draconique {
} }
else { else {
const demiReve = actor.getDemiReve(); 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]); const tmr = TMRUtility.getTMR(coordSortsReserve[0]);
await this.createCaseTmr(actor, 'Urgence draconique: ' + tmr.label, tmr, queue.id); await this.createCaseTmr(actor, 'Urgence draconique: ' + tmr.label, tmr, queue.id);
} }