forked from public/foundryvtt-reve-de-dragon
Nouvelles TMRs
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Misc } from "./misc.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { tmrConstants } from "./tmr-constants.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const TMRMapping = {
|
||||
@ -199,7 +200,7 @@ const TMRMapping = {
|
||||
K14: { type: "necropole", label: "Nécropole d’Antinéar" },
|
||||
L14: { type: "plaines", label: "Plaines de Jislith" },
|
||||
M14: { type: "desolation", label: "Désolation d’Après" },
|
||||
|
||||
|
||||
A15: { type: "cite", label: "Cité de Mielh" },
|
||||
C15: { type: "plaines", label: "Plaines de Toué" },
|
||||
E15: { type: "foret", label: "Forêt des Furies" },
|
||||
@ -274,11 +275,11 @@ export class TMRUtility {
|
||||
const tmr = TMRUtility.getTMR(coord);
|
||||
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
|
||||
}
|
||||
|
||||
static findTMRLike(type, options = {inclusMauvaise:true}) {
|
||||
|
||||
static findTMRLike(type, options = { inclusMauvaise: true }) {
|
||||
const choix = [...Object.values(TMRType)]
|
||||
if (options.inclusMauvaise){
|
||||
choix.push({name: 'Mauvaise'});
|
||||
if (options.inclusMauvaise) {
|
||||
choix.push({ name: 'Mauvaise' });
|
||||
}
|
||||
const selection = Misc.findAllLike(type, choix).map(it => it.name);
|
||||
if (selection.length == 0) {
|
||||
@ -297,7 +298,7 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
static buildSelectionTypesTMR(typesTMR) {
|
||||
typesTMR = typesTMR?? [];
|
||||
typesTMR = typesTMR ?? [];
|
||||
return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
|
||||
.sort()
|
||||
.map(name => { return { name: name, selected: typesTMR.includes(name) } });
|
||||
@ -375,6 +376,33 @@ export class TMRUtility {
|
||||
return caseList;
|
||||
}
|
||||
|
||||
// /* -------------------------------------------- */
|
||||
static computeEventPosition(event) {
|
||||
const canvasRect = event.nativeEvent.target.getBoundingClientRect();
|
||||
return {
|
||||
x: event.nativeEvent.clientX - canvasRect.left,
|
||||
y: event.nativeEvent.clientY - canvasRect.top
|
||||
};
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeEventOddq(event) {
|
||||
var { x, y } = TMRUtility.computeEventPosition(event);
|
||||
return TMRUtility.computeOddq(x, y);
|
||||
}
|
||||
|
||||
static computeOddq(x, y) {
|
||||
const col = Math.floor(x / tmrConstants.cellw); // [From 0 -> 12]
|
||||
const decallageColonne = col % 2 == 0 ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
const row = Math.floor((y - decallageColonne) / tmrConstants.cellh); // [From 0 -> 14]
|
||||
return { col, row };
|
||||
}
|
||||
|
||||
static computeEventCoord(event) {
|
||||
const oddq = TMRUtility.computeEventOddq(event);
|
||||
return TMRUtility.oddqToCoordTMR(oddq);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// https://www.redblobgames.com/grids/hexagons/#distances
|
||||
// TMR Letter-row correspond to "odd-q" grid (letter => col, numeric => row )
|
||||
@ -400,7 +428,7 @@ export class TMRUtility {
|
||||
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;
|
||||
@ -444,7 +472,7 @@ export class TMRUtility {
|
||||
|
||||
static axial_subtract(a, b) {
|
||||
return {
|
||||
q: a.q- b.q,
|
||||
q: a.q - b.q,
|
||||
r: a.r - b.r
|
||||
};
|
||||
}
|
||||
@ -456,7 +484,7 @@ export class TMRUtility {
|
||||
// return Cube(q, r, s)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /* -------------------------------------------- */
|
||||
// static computeRealPictureCoordinates(coordOddq) {
|
||||
// let decallagePairImpair = (coordOddq.col % 2 == 0) ? tmrConstants.col1_y : tmrConstants.col2_y;
|
||||
|
Reference in New Issue
Block a user