2021-02-05 01:38:40 +01:00
|
|
|
|
import { Misc } from "./misc.js";
|
2021-05-04 12:22:19 +02:00
|
|
|
|
import { Grammar } from "./grammar.js";
|
2021-05-11 21:45:43 +02:00
|
|
|
|
import { RdDDice } from "./rdd-dice.js";
|
2020-11-16 04:31:53 +01:00
|
|
|
|
|
2020-07-17 22:04:35 +02:00
|
|
|
|
/* -------------------------------------------- */
|
2021-02-06 21:53:25 +01:00
|
|
|
|
const TMRMapping = {
|
|
|
|
|
A1: { type: "cite", label: "Cité Vide" },
|
|
|
|
|
B1: { type: "plaines", label: "Plaines d’Assorh" },
|
|
|
|
|
C1: { type: "necropole", label: "Nécropole de Kroak" },
|
|
|
|
|
D1: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
E1: { type: "monts", label: "Monts de Kanaï" },
|
|
|
|
|
F1: { type: "cite", label: "Cité Glauque" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
G1: { type: "desolation", label: "Désolation de Jamais" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
H1: { type: "lac", label: "Lac d’Anticalme" },
|
|
|
|
|
I1: { type: "plaines", label: "Plaines Grises" },
|
|
|
|
|
J1: { type: "monts", label: "Monts Fainéants" },
|
|
|
|
|
K1: { type: "cite", label: "Cité d’Onkause" },
|
|
|
|
|
L1: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
M1: { type: "cite", label: "Cité Jalouse" },
|
|
|
|
|
|
|
|
|
|
A2: { type: "desert", label: "Désert de Mieux" },
|
|
|
|
|
B2: { type: "collines", label: "Collines de Dawell" },
|
|
|
|
|
C2: { type: "marais", label: "Marais Glignants" },
|
|
|
|
|
D2: { type: "cite", label: "Cité de Frost" },
|
|
|
|
|
E2: { type: "plaines", label: "Plaines de Fiask" },
|
|
|
|
|
F2: { type: "lac", label: "Lac de Misère" },
|
|
|
|
|
G2: { type: "marais", label: "Marais Nuisants" },
|
|
|
|
|
H2: { type: "collines", label: "Collines de Parta" },
|
|
|
|
|
I2: { type: "foret", label: "Forêt Fade" },
|
|
|
|
|
J2: { type: "desert", label: "Désert de Poly" },
|
|
|
|
|
K2: { type: "foret", label: "Forêt Tamée" },
|
|
|
|
|
L2: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
M2: { type: "necropole", label: "Nécropole de Logos" },
|
|
|
|
|
|
|
|
|
|
A3: { type: "desolation", label: "Désolation de Demain" },
|
|
|
|
|
B3: { type: "plaines", label: "Plaines de Rubéga" },
|
|
|
|
|
C3: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
D3: { type: "gouffre", label: "Gouffre d’Oki" },
|
|
|
|
|
E3: { type: "foret", label: "Forêt d’Estoubh" },
|
|
|
|
|
F3: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
G3: { type: "gouffre", label: "Gouffre de Sun" },
|
|
|
|
|
H3: { type: "foret", label: "Forêt de Ganna" },
|
|
|
|
|
I3: { type: "monts", label: "Monts Grinçants" },
|
|
|
|
|
J3: { type: "cite", label: "Cité Venin" },
|
|
|
|
|
K3: { type: "plaines", label: "Plaines de Dois" },
|
|
|
|
|
L3: { type: "lac", label: "Lac Laineux" },
|
|
|
|
|
M3: { type: "monts", label: "Monts de Vdah" },
|
|
|
|
|
|
|
|
|
|
A4: { type: "foret", label: "Forêt de Falconax" },
|
|
|
|
|
B4: { type: "monts", label: "Monts Crâneurs" },
|
|
|
|
|
C4: { type: "pont", label: "Pont de Giolii" },
|
|
|
|
|
D4: { type: "lac", label: "Lac de Foam" },
|
|
|
|
|
E4: { type: "plaines", label: "Plaines d’Orti" },
|
|
|
|
|
F4: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
G4: { type: "sanctuaire", label: "Sanctuaire Blanc" },
|
|
|
|
|
H4: { type: "plaines", label: "Plaines de Psark" },
|
|
|
|
|
I4: { type: "plaines", label: "Plaines de Xiax" },
|
|
|
|
|
J4: { type: "collines", label: "Collines d’Encre" },
|
|
|
|
|
K4: { type: "pont", label: "Pont de Fah" },
|
|
|
|
|
L4: { type: "sanctuaire", label: "Sanctuaire Mauve" },
|
|
|
|
|
M4: { type: "gouffre", label: "Gouffre Grisant" },
|
|
|
|
|
|
|
|
|
|
A5: { type: "plaines", label: "Plaines de Trilkh" },
|
|
|
|
|
B5: { type: "collines", label: "Collines de Tanegy" },
|
|
|
|
|
C5: { type: "marais", label: "Marais Flouants" },
|
|
|
|
|
D5: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
E5: { type: "monts", label: "Monts Brûlants" },
|
|
|
|
|
F5: { type: "cite", label: "Cité de Panople" },
|
|
|
|
|
G5: { type: "pont", label: "Pont d’Ik" },
|
|
|
|
|
H5: { type: "desert", label: "Désert de Krane" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
I5: { type: "desolation", label: "Désolation de Toujours" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
J5: { type: "marais", label: "Marais de Jab" },
|
|
|
|
|
K5: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
L5: { type: "collines", label: "Collines Suaves" },
|
|
|
|
|
M5: { type: "cite", label: "Cité Rimarde" },
|
|
|
|
|
|
|
|
|
|
A6: { type: "necropole", label: "Nécropole de Zniak" },
|
|
|
|
|
B6: { type: "foret", label: "Forêt de Bust" },
|
|
|
|
|
C6: { type: "cite", label: "Cité Pavois" },
|
|
|
|
|
D6: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
E6: { type: "sanctuaire", label: "Sanctuaire de Plaine" },
|
|
|
|
|
F6: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
G6: { type: "marais", label: "Marais Glutants" },
|
|
|
|
|
H6: { type: "monts", label: "Monts Gurdes" },
|
|
|
|
|
I6: { type: "necropole", label: "Nécropole de Xotar" },
|
|
|
|
|
J6: { type: "lac", label: "Lac d’Iaupe" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
K6: { type: "desolation", label: "Désolation de Poor" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
L6: { type: "foret", label: "Forêt Gueuse" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
M6: { type: "desolation", label: "Désolation de Presque" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
|
|
|
|
|
A7: { type: "plaines", label: "Plaines de l’Arc" },
|
|
|
|
|
B7: { type: "marais", label: "Marais Bluants" },
|
|
|
|
|
C7: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
2021-02-12 01:44:27 +01:00
|
|
|
|
D7: { type: "plaines", label: "Plaines d’Affa" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
E7: { type: "foret", label: "Forêt de Glusks" },
|
|
|
|
|
F7: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
G7: { type: "cite", label: "Cité de Terwa" },
|
|
|
|
|
H7: { type: "gouffre", label: "Gouffre de Kapfa" },
|
|
|
|
|
I7: { type: "plaines", label: "Plaines de Troo" },
|
|
|
|
|
J7: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
K7: { type: "cite", label: "Cité de Kolix" },
|
|
|
|
|
L7: { type: "gouffre", label: "Gouffre d’Episophe" },
|
|
|
|
|
M7: { type: "desert", label: "Désert de Lave" },
|
|
|
|
|
|
|
|
|
|
A8: { type: "gouffre", label: "Gouffre de Shok" },
|
|
|
|
|
B8: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
C8: { type: "foret", label: "Forêt Turmide" },
|
|
|
|
|
D8: { type: "cite", label: "Cité d’Olak" },
|
|
|
|
|
E8: { type: "plaines", label: "Plaines d’Iolise" },
|
|
|
|
|
F8: { type: "lac", label: "Lac des Chats" },
|
|
|
|
|
G8: { type: "plaines", label: "Plaines Sans Joie" },
|
|
|
|
|
H8: { type: "foret", label: "Forêt d’Ourf" },
|
|
|
|
|
I8: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
J8: { type: "monts", label: "Monts Barask" },
|
|
|
|
|
K8: { type: "desert", label: "Désert de Fumée" },
|
|
|
|
|
L8: { type: "monts", label: "Monts Tavelés" },
|
|
|
|
|
M8: { type: "plaines", label: "Plaines Lavées" },
|
|
|
|
|
|
|
|
|
|
A9: { type: "collines", label: "Collines de Korrex" },
|
|
|
|
|
B9: { type: "lac", label: "Lac de Lucre" },
|
|
|
|
|
C9: { type: "monts", label: "Monts Tuméfiés" },
|
|
|
|
|
D9: { type: "pont", label: "Pont d’Orx" },
|
|
|
|
|
E9: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
F9: { type: "plaines", label: "Plaines de Foe" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
G9: { type: "desolation", label: "Désolation de Sel" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
H9: { type: "collines", label: "Collines de Noirseul" },
|
|
|
|
|
I9: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
J9: { type: "marais", label: "Marais Gronchants" },
|
|
|
|
|
K9: { type: "sanctuaire", label: "Sanctuaire Noir" },
|
|
|
|
|
L9: { type: "collines", label: "Collines Cornues" },
|
|
|
|
|
M9: { type: "necropole", label: "Nécropole de Zonar" },
|
|
|
|
|
|
|
|
|
|
A10: { type: "sanctuaire", label: "Sanctuaire d’Olis" },
|
|
|
|
|
B10: { type: "monts", label: "Monts Salés" },
|
|
|
|
|
C10: { type: "marais", label: "Marais de Dom" },
|
|
|
|
|
D10: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
E10: { type: "gouffre", label: "Gouffre de Junk" },
|
|
|
|
|
F10: { type: "marais", label: "Marais Zultants" },
|
|
|
|
|
G10: { type: "cite", label: "Cité de Sergal" },
|
|
|
|
|
H10: { type: "plaines", label: "Plaines Noires" },
|
|
|
|
|
I10: { type: "lac", label: "Lac Wanito" },
|
|
|
|
|
J10: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
K10: { type: "plaines", label: "Plaines Jaunes" },
|
|
|
|
|
L10: { type: "desert", label: "Désert de Nicrop" },
|
|
|
|
|
M10: { type: "foret", label: "Forêt de Jajou" },
|
|
|
|
|
|
2022-06-12 08:17:59 +02:00
|
|
|
|
A11: { type: "desolation", label: "Désolation d’Hier" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
B11: { type: "cite", label: "Cité de Brilz" },
|
|
|
|
|
C11: { type: "pont", label: "Pont de Roï" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
D11: { type: "desolation", label: "Désolation de Partout" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
E11: { type: "lac", label: "Lac de Glinster" },
|
|
|
|
|
F11: { type: "cite", label: "Cité de Noape" },
|
|
|
|
|
G11: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
H11: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
I11: { type: "pont", label: "Pont de Yalm" },
|
|
|
|
|
J11: { type: "plaines", label: "Plaines de Miltiar" },
|
|
|
|
|
K11: { type: "cite", label: "Cité Tonnerre" },
|
|
|
|
|
L11: { type: "collines", label: "Collines de Kol" },
|
|
|
|
|
M11: { type: "cite", label: "Cité Crapaud" },
|
|
|
|
|
|
|
|
|
|
A12: { type: "plaines", label: "Plaines Sages" },
|
|
|
|
|
B12: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
C12: { type: "lac", label: "Lac de Fricassa" },
|
|
|
|
|
D12: { type: "collines", label: "Collines d’Huaï" },
|
|
|
|
|
E12: { type: "monts", label: "Monts Ajourés" },
|
2023-10-22 00:15:13 +02:00
|
|
|
|
F12: { type: "necropole", label: "Nécropole de Throat" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
G12: { type: "plaines", label: "Plaines de Lufmil" },
|
|
|
|
|
H12: { type: "collines", label: "Collines de Tooth" },
|
|
|
|
|
I12: { type: "gouffre", label: "Gouffre Abimeux" },
|
|
|
|
|
J12: { type: "cite", label: "Cité Folle" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
K12: { type: "desolation", label: "Désolation d’Amour" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
L12: { type: "plaines", label: "Plaines Venteuses" },
|
|
|
|
|
M12: { type: "collines", label: "Collines Révulsantes" },
|
|
|
|
|
|
|
|
|
|
A13: { type: "fleuve", label: "Fleuve de l'Oubli" },
|
|
|
|
|
B13: { type: "gouffre", label: "Gouffre des Litiges" },
|
|
|
|
|
C13: { type: "desert", label: "Désert de Neige" },
|
|
|
|
|
D13: { type: "cite", label: "Cité Sordide" },
|
|
|
|
|
E13: { type: "plaines", label: "Plaines de Xnez" },
|
|
|
|
|
F13: { type: "foret", label: "Forêt des Cris" },
|
|
|
|
|
G13: { type: "plaines", label: "Plaines Calcaires" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
H13: { type: "desolation", label: "Désolation de Rien" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
I13: { type: "monts", label: "Monts Bigleux" },
|
|
|
|
|
J13: { type: "gouffre", label: "Gouffre de Gromph" },
|
|
|
|
|
K13: { type: "foret", label: "Forêt de Kluth" },
|
|
|
|
|
L13: { type: "monts", label: "Monts Dormants" },
|
|
|
|
|
M13: { type: "plaines", label: "Plaines d’Anjou" },
|
|
|
|
|
|
|
|
|
|
A14: { type: "collines", label: "Collines de Stolis" },
|
|
|
|
|
B14: { type: "necropole", label: "Nécropole de Gorlo" },
|
|
|
|
|
C14: { type: "foret", label: "Forêt de Bissam" },
|
|
|
|
|
D14: { type: "sanctuaire", label: "Sanctuaire Plat" },
|
|
|
|
|
E14: { type: "monts", label: "Monts de Quath" },
|
|
|
|
|
F14: { type: "plaines", label: "Plaines Brisées" },
|
|
|
|
|
G14: { type: "desert", label: "Désert de Sek" },
|
|
|
|
|
H14: { type: "plaines", label: "Plaines Blanches" },
|
|
|
|
|
I14: { type: "cite", label: "Cité Destituée" },
|
|
|
|
|
J14: { type: "desert", label: "Désert de Sank" },
|
|
|
|
|
K14: { type: "necropole", label: "Nécropole d’Antinéar" },
|
|
|
|
|
L14: { type: "plaines", label: "Plaines de Jislith" },
|
2022-06-12 08:17:59 +02:00
|
|
|
|
M14: { type: "desolation", label: "Désolation d’Après" },
|
2023-10-20 22:18:37 +02:00
|
|
|
|
|
2021-02-06 21:53:25 +01:00
|
|
|
|
A15: { type: "cite", label: "Cité de Mielh" },
|
|
|
|
|
C15: { type: "plaines", label: "Plaines de Toué" },
|
|
|
|
|
E15: { type: "foret", label: "Forêt des Furies" },
|
|
|
|
|
G15: { type: "plaines", label: "Plaines des Soupirs" },
|
|
|
|
|
I15: { type: "monts", label: "Monts des Dragées" },
|
|
|
|
|
K15: { type: "collines", label: "Collines Pourpres" },
|
|
|
|
|
M15: { type: "cite", label: "Cité de Klana" }
|
|
|
|
|
}
|
2020-07-21 23:51:24 +02:00
|
|
|
|
|
2021-02-06 21:53:25 +01:00
|
|
|
|
export const TMRType = {
|
|
|
|
|
cite: { name: "cité", genre: "f" },
|
2021-02-28 01:56:17 +01:00
|
|
|
|
sanctuaire: { name: "sanctuaire", genre: 'm' },
|
|
|
|
|
plaines: { name: "plaines", genre: "fp" },
|
2021-02-06 21:53:25 +01:00
|
|
|
|
pont: { name: "pont", genre: "m" },
|
|
|
|
|
collines: { name: "collines", genre: "p" },
|
|
|
|
|
foret: { name: "forêt", genre: "f" },
|
|
|
|
|
monts: { name: "monts", genre: "p" },
|
|
|
|
|
desert: { name: "désert", genre: "m" },
|
|
|
|
|
fleuve: { name: "fleuve", genre: "m" },
|
|
|
|
|
lac: { name: "lac", genre: "m" },
|
|
|
|
|
marais: { name: "marais", genre: "m" },
|
|
|
|
|
gouffre: { name: "gouffre", genre: "m" },
|
|
|
|
|
necropole: { name: "nécropole", genre: "f" },
|
|
|
|
|
desolation: { name: "désolation", genre: "f" }
|
2021-01-29 15:13:59 +01:00
|
|
|
|
}
|
2020-07-17 22:04:35 +02:00
|
|
|
|
|
2020-11-21 14:30:00 +01:00
|
|
|
|
/* -------------------------------------------- */
|
2023-11-15 22:11:44 +01:00
|
|
|
|
const TMR_MOVE = {
|
|
|
|
|
"top": { even: { row: -1, col: 0 }, odd: { row: -1, col: 0 }, },
|
|
|
|
|
"topleft": { even: { row: -1, col: -1 }, odd: { row: 0, col: -1 }, },
|
|
|
|
|
"topright": { even: { row: -1, col: 1 }, odd: { row: 0, col: 1 }, },
|
|
|
|
|
"bottomleft": { even: { row: 0, col: -1 }, odd: { row: 1, col: -1 }, },
|
|
|
|
|
"bottomright": { even: { row: 0, col: 1 }, odd: { row: 1, col: 1 }, },
|
|
|
|
|
"bottom": { even: { row: 1, col: 0 }, odd: { row: 1, col: 0 }, },
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-15 22:14:00 +01:00
|
|
|
|
/* --------------------------------------------
|
|
|
|
|
* Pour comprendre les conversions entre coordonnées
|
|
|
|
|
* - "TMR" A1, ... M15
|
|
|
|
|
* - oddq: {col, row}
|
|
|
|
|
* - axial: { q, r )
|
|
|
|
|
*
|
|
|
|
|
* Un site intéressant: https://www.redblobgames.com/grids/hexagons/#distances
|
|
|
|
|
*
|
|
|
|
|
* Pour être concis, le code TMR lettre(colonne)-ligne correspond à une grille hexagonale en coordonnées "odd-q"
|
|
|
|
|
* (lettre => col, ligne => row).
|
|
|
|
|
*
|
|
|
|
|
* Pour les calculs de distance, les coordonnées axiales sont beaucoup plus pratiques.
|
|
|
|
|
*/
|
2021-02-06 21:53:25 +01:00
|
|
|
|
export class TMRUtility {
|
2021-01-29 15:13:59 +01:00
|
|
|
|
static init() {
|
|
|
|
|
for (let coord in TMRMapping) {
|
2021-02-12 01:11:03 +01:00
|
|
|
|
const tmr = TMRMapping[coord];
|
|
|
|
|
tmr.coord = coord;
|
2021-12-12 17:36:22 +01:00
|
|
|
|
tmr.oddq = TMRUtility.coordTMRToOddq(coord);
|
2021-02-12 01:11:03 +01:00
|
|
|
|
tmr.genre = TMRType[tmr.type].genre;
|
2021-01-29 15:13:59 +01:00
|
|
|
|
}
|
2021-02-05 01:38:40 +01:00
|
|
|
|
let tmrByType = Misc.classify(Object.values(TMRMapping));
|
|
|
|
|
for (const [type, list] of Object.entries(tmrByType)) {
|
|
|
|
|
TMRType[type].list = list;
|
|
|
|
|
}
|
2021-01-29 15:13:59 +01:00
|
|
|
|
}
|
2020-12-04 20:52:04 +01:00
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2021-02-06 21:53:25 +01:00
|
|
|
|
static verifyTMRCoord(coord) {
|
2023-03-30 01:31:41 +02:00
|
|
|
|
return Grammar.equalsInsensitive(coord, 'Fleuve') || TMRUtility.getTMR(coord);
|
2021-02-06 21:53:25 +01:00
|
|
|
|
}
|
2020-12-04 20:52:04 +01:00
|
|
|
|
|
2020-07-17 22:04:35 +02:00
|
|
|
|
/* -------------------------------------------- */
|
2021-02-12 01:11:03 +01:00
|
|
|
|
static getTMR(coord) {
|
2023-03-30 01:31:41 +02:00
|
|
|
|
return coord == 'Fleuve' ? TMRMapping['D1'] : TMRMapping[coord];
|
2020-07-17 22:04:35 +02:00
|
|
|
|
}
|
2021-02-12 01:11:03 +01:00
|
|
|
|
|
|
|
|
|
static getTMRLabel(coord) {
|
2023-03-30 01:31:41 +02:00
|
|
|
|
return TMRUtility.getTMR(coord)?.label ?? (coord + ": case inconnue");
|
2021-02-28 01:56:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-28 00:48:39 +02:00
|
|
|
|
static getTMRType(coord) {
|
2023-03-30 01:31:41 +02:00
|
|
|
|
const tmr = TMRUtility.getTMR(coord);
|
2021-05-11 21:21:33 +02:00
|
|
|
|
return Misc.upperFirst(TMRType[tmr.type].name);
|
2021-04-28 00:48:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-28 01:56:17 +01:00
|
|
|
|
static getTMRDescr(coord) {
|
2023-03-30 01:31:41 +02:00
|
|
|
|
const tmr = TMRUtility.getTMR(coord);
|
2021-04-28 00:48:39 +02:00
|
|
|
|
return Grammar.articleDetermine(tmr.type) + ' ' + tmr.label;
|
2021-02-12 01:11:03 +01:00
|
|
|
|
}
|
2023-10-20 22:18:37 +02:00
|
|
|
|
|
|
|
|
|
static findTMRLike(type, options = { inclusMauvaise: true }) {
|
2022-11-17 01:22:45 +01:00
|
|
|
|
const choix = [...Object.values(TMRType)]
|
2023-10-20 22:18:37 +02:00
|
|
|
|
if (options.inclusMauvaise) {
|
|
|
|
|
choix.push({ name: 'Mauvaise' });
|
2022-11-17 01:22:45 +01:00
|
|
|
|
}
|
|
|
|
|
const selection = Misc.findAllLike(type, choix).map(it => it.name);
|
|
|
|
|
if (selection.length == 0) {
|
|
|
|
|
ui.notifications.warn(`Un type de TMR doit être indiqué, '${type}' n'est pas trouvé dans ${choix}`);
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
if (selection.length > 1) {
|
|
|
|
|
ui.notifications.warn(`Plusieurs types de TMR pourraient correspondre à '${type}': ${selection}`);
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
return selection[0];
|
|
|
|
|
}
|
2021-02-12 01:11:03 +01:00
|
|
|
|
|
2021-11-26 23:29:06 +01:00
|
|
|
|
static typeTmrName(type) {
|
2021-05-18 19:51:12 +02:00
|
|
|
|
return Misc.upperFirst(TMRType[Grammar.toLowerCaseNoAccent(type)].name);
|
|
|
|
|
}
|
2022-11-17 01:18:06 +01:00
|
|
|
|
|
2022-09-24 00:31:51 +02:00
|
|
|
|
static buildSelectionTypesTMR(typesTMR) {
|
2023-10-20 22:18:37 +02:00
|
|
|
|
typesTMR = typesTMR ?? [];
|
2021-05-11 00:52:25 +02:00
|
|
|
|
return Object.values(TMRType).map(value => Misc.upperFirst(value.name))
|
|
|
|
|
.sort()
|
|
|
|
|
.map(name => { return { name: name, selected: typesTMR.includes(name) } });
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 00:31:51 +02:00
|
|
|
|
static buildListTypesTMRSelection(selectionTMRs) {
|
|
|
|
|
return selectionTMRs.filter(it => it.selected).map(it => it.name).join(" ");
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 02:48:27 +01:00
|
|
|
|
static isCaseHumide(tmr) {
|
|
|
|
|
return tmr.type == 'fleuve' || tmr.type == 'lac' || tmr.type == 'marais';
|
|
|
|
|
}
|
2021-02-06 21:53:25 +01:00
|
|
|
|
|
2020-11-20 16:45:20 +01:00
|
|
|
|
/* -------------------------------------------- */
|
2023-11-15 22:11:44 +01:00
|
|
|
|
static deplacement(coordOrig, moveName) {
|
|
|
|
|
const tmrMove = TMR_MOVE[moveName];
|
|
|
|
|
if (! tmrMove) {
|
|
|
|
|
ui.notifications.error(`Le déplacement dans les TMR '${moveName}' est inconnu`)
|
|
|
|
|
return coordOrig
|
|
|
|
|
}
|
|
|
|
|
const fromOddq = TMRUtility.coordTMRToOddq(coordOrig);
|
|
|
|
|
const move = TMRUtility.getOddqMove(tmrMove, fromOddq);
|
|
|
|
|
const toOddq = TMRUtility.addOddq(fromOddq, move);
|
|
|
|
|
return TMRUtility.oddqToCoordTMR(toOddq);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getOddqMove(tmrMove, oddq) {
|
|
|
|
|
return oddq.col % 2 == 1 ? tmrMove.odd : tmrMove.even;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static async getDirectionPattern(oddq) {
|
|
|
|
|
const tmrMove = await RdDDice.rollOneOf(Object.values(TMR_MOVE));
|
|
|
|
|
return TMRUtility.getOddqMove(tmrMove, oddq);
|
2020-11-21 14:30:00 +01:00
|
|
|
|
}
|
2021-01-29 15:13:59 +01:00
|
|
|
|
|
2021-04-25 10:08:40 +02:00
|
|
|
|
/* -------------------------------------------- */
|
2021-05-11 21:45:43 +02:00
|
|
|
|
static async deplaceTMRAleatoire(actor, coord) {
|
2023-11-15 22:11:44 +01:00
|
|
|
|
const oddq = TMRUtility.coordTMRToOddq(coord);
|
|
|
|
|
const direction = await TMRUtility.getDirectionPattern(oddq);
|
|
|
|
|
const currentOddq = TMRUtility.addOddq(oddq, direction)
|
2023-11-15 22:14:00 +01:00
|
|
|
|
if (TMRUtility.isOddqInTMR(currentOddq)) { // Sortie de carte ! Ré-insertion aléatoire
|
2022-11-07 00:04:43 +01:00
|
|
|
|
return TMRUtility.getTMR(TMRUtility.oddqToCoordTMR(currentOddq));
|
|
|
|
|
} else {
|
|
|
|
|
return await actor.reinsertionAleatoire('Sortie de carte');
|
2020-11-21 18:16:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-17 16:30:03 +01:00
|
|
|
|
/* -------------------------------------------- */
|
2021-01-29 15:13:59 +01:00
|
|
|
|
static getListTMR(terrain) {
|
2021-02-05 01:38:40 +01:00
|
|
|
|
return TMRType[terrain].list;
|
2020-11-16 04:31:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 02:48:27 +01:00
|
|
|
|
static filterTMR(filter) {
|
|
|
|
|
return Object.values(TMRMapping).filter(filter);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-07 00:04:43 +01:00
|
|
|
|
static getCasesType(type) {
|
|
|
|
|
return TMRUtility.filterTMR(it => it.type == type).map(it => it.coord);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-26 23:29:06 +01:00
|
|
|
|
static findTMR(search) {
|
2022-11-17 01:57:36 +01:00
|
|
|
|
return TMRUtility.filterTMR(it => Grammar.includesLowerCaseNoAccent(it.label, search) || it.coord == search);
|
2021-11-26 23:29:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-11 02:48:27 +01:00
|
|
|
|
static filterTMRCoord(filter) {
|
|
|
|
|
return TMRUtility.filterTMR(filter).map(it => it.coord);
|
2020-07-17 22:04:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-11 21:45:43 +02:00
|
|
|
|
static async getTMRAleatoire(filter = it => true) {
|
|
|
|
|
return await RdDDice.rollOneOf(TMRUtility.filterTMR(filter))
|
2020-09-13 23:08:52 +02:00
|
|
|
|
}
|
2020-11-18 23:49:05 +01:00
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
/** Returns a list of case inside a given distance
|
|
|
|
|
*
|
|
|
|
|
*/
|
2021-02-12 01:11:03 +01:00
|
|
|
|
static getTMRPortee(coord, portee) {
|
2023-11-15 22:14:00 +01:00
|
|
|
|
let centerOddq = TMRUtility.coordTMRToOddq(coord);
|
2020-11-18 23:49:05 +01:00
|
|
|
|
let caseList = [];
|
2021-12-12 17:36:22 +01:00
|
|
|
|
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 };
|
2023-11-15 22:14:00 +01:00
|
|
|
|
if (TMRUtility.isOddqInTMR(currentOddq)) {
|
|
|
|
|
let dist = TMRUtility.distanceOddq(centerOddq, currentOddq);
|
2021-02-28 01:56:17 +01:00
|
|
|
|
if (dist <= portee) {
|
2023-11-15 22:14:00 +01:00
|
|
|
|
caseList.push(TMRUtility.oddqToCoordTMR(currentOddq)); // Inside the area
|
2020-11-18 23:49:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return caseList;
|
|
|
|
|
}
|
2021-02-28 01:56:17 +01:00
|
|
|
|
|
2021-12-12 17:36:22 +01:00
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static coordTMRToOddq(coordTMR) {
|
|
|
|
|
let col = coordTMR.charCodeAt(0) - 65;
|
|
|
|
|
let row = coordTMR.substr(1) - 1;
|
|
|
|
|
return { col: col, row: row }
|
2021-02-28 01:56:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-25 10:08:40 +02:00
|
|
|
|
/* -------------------------------------------- */
|
2021-12-12 17:36:22 +01:00
|
|
|
|
static oddqToCoordTMR(oddq) {
|
|
|
|
|
let letterX = String.fromCharCode(65 + (oddq.col));
|
|
|
|
|
return letterX + (oddq.row + 1)
|
2021-02-28 01:56:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-12 17:36:22 +01:00
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static isOddqInTMR(oddq) {
|
|
|
|
|
const col = oddq.col;
|
|
|
|
|
const row = oddq.row;
|
|
|
|
|
return (
|
|
|
|
|
col >= 0 && col < 13 &&
|
|
|
|
|
row >= 0 &&
|
|
|
|
|
(row + col % 2 <= 14)
|
2023-10-20 22:18:37 +02:00
|
|
|
|
);
|
2021-12-12 17:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static distanceCoordTMR(coord1, coord2) {
|
2023-11-15 22:14:00 +01:00
|
|
|
|
let oddq1 = TMRUtility.coordTMRToOddq(coord1);
|
|
|
|
|
let oddq2 = TMRUtility.coordTMRToOddq(coord2);
|
|
|
|
|
return TMRUtility.distanceOddq(oddq1, oddq2);
|
2021-12-12 17:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
static distanceOddq(oddq1, oddq2) {
|
|
|
|
|
const axial1 = TMRUtility.oddqToAxial(oddq1);
|
|
|
|
|
const axial2 = TMRUtility.oddqToAxial(oddq2);
|
|
|
|
|
return TMRUtility.distanceAxial(axial1, axial2);
|
2023-11-15 22:11:44 +01:00
|
|
|
|
}
|
2021-12-12 17:36:22 +01:00
|
|
|
|
|
2023-11-15 22:11:44 +01:00
|
|
|
|
static addOddq(move, oddq) {
|
|
|
|
|
return {
|
|
|
|
|
row: oddq.row + move.row,
|
|
|
|
|
col: oddq.col + move.col
|
|
|
|
|
}
|
2021-12-12 17:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 {
|
2023-10-20 22:18:37 +02:00
|
|
|
|
q: a.q - b.q,
|
2021-12-12 17:36:22 +01:00
|
|
|
|
r: a.r - b.r
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-07-17 22:04:35 +02:00
|
|
|
|
|
2021-12-12 17:36:22 +01:00
|
|
|
|
}
|