2021-05-18 19:51:12 +02:00
|
|
|
import { defaultItemImg } from "./item.js";
|
2021-05-10 19:17:31 +02:00
|
|
|
import { Misc } from "./misc.js";
|
2021-05-11 21:45:43 +02:00
|
|
|
import { RdDDice } from "./rdd-dice.js";
|
2021-05-11 21:21:33 +02:00
|
|
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
2021-05-18 19:51:12 +02:00
|
|
|
import { TMRType, TMRUtility } from "./tmr-utility.js";
|
2021-05-10 19:17:31 +02:00
|
|
|
|
2021-05-11 21:21:33 +02:00
|
|
|
const tableSignesIndicatifs = [
|
|
|
|
{ rarete: "Très facile", difficulte: 0, xp: 6, nbCases: 14 },
|
|
|
|
{ rarete: "Facile", difficulte: -2, xp: 10, nbCases: 10 },
|
|
|
|
{ rarete: "Moyen", difficulte: -3, xp: 15, nbCases: 7 },
|
|
|
|
{ rarete: "Difficile", difficulte: -5, xp: 20, nbCases: 4 },
|
|
|
|
{ rarete: "Ardu", difficulte: -8, xp: 30, nbCases: 1 }
|
|
|
|
|
|
|
|
]
|
2021-05-18 19:51:12 +02:00
|
|
|
|
2022-06-12 08:17:59 +02:00
|
|
|
const DIFFICULTE_LECTURE_SIGNE_MANQUE = +11;
|
|
|
|
|
2021-05-10 19:17:31 +02:00
|
|
|
export class RdDItemSigneDraconique {
|
|
|
|
|
|
|
|
static prepareSigneDraconiqueMeditation(meditation, rolled) {
|
2022-06-12 09:46:58 +02:00
|
|
|
meditation = meditation
|
2022-06-12 08:17:59 +02:00
|
|
|
return {
|
|
|
|
name: "de la " + meditation.name,
|
|
|
|
type: "signedraconique",
|
|
|
|
img: meditation.img,
|
|
|
|
data: {
|
|
|
|
typesTMR: [TMRUtility.typeTmrName(meditation.data.tmr)],
|
|
|
|
difficulte: rolled.isSuccess ? RdDItemSigneDraconique.getDiffSigneMeditation(rolled.code) : DIFFICULTE_LECTURE_SIGNE_MANQUE,
|
|
|
|
ephemere: true,
|
|
|
|
duree: "1 round",
|
|
|
|
valeur: rolled.isSuccess ? { "norm": 3, "sign": 5, "part": 10 } : { "norm": 0, "sign": 0, "part": 0 }
|
|
|
|
}
|
|
|
|
};
|
2021-05-10 19:17:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static getDiffSigneMeditation(code) {
|
|
|
|
switch (code) {
|
|
|
|
case "norm": return -7;
|
|
|
|
case "sign": return -3;
|
|
|
|
case "part": return 0;
|
|
|
|
}
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
static getXpSortSigneDraconique(code, signe) {
|
2022-06-12 09:46:58 +02:00
|
|
|
return Misc.toInt(signe.system.valeur[code] ?? 0);
|
2021-05-10 19:17:31 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 00:52:25 +02:00
|
|
|
static calculValeursXpSort(qualite, valeur, avant) {
|
|
|
|
switch (qualite) {
|
|
|
|
case "norm":
|
|
|
|
return {
|
|
|
|
norm: valeur,
|
|
|
|
sign: Math.max(valeur, avant.sign),
|
|
|
|
part: Math.max(valeur, avant.part)
|
|
|
|
}
|
|
|
|
case "sign":
|
|
|
|
return {
|
|
|
|
norm: Math.min(valeur, avant.norm),
|
|
|
|
sign: valeur,
|
|
|
|
part: Math.max(valeur, avant.part)
|
|
|
|
}
|
|
|
|
case "part":
|
|
|
|
return {
|
|
|
|
norm: Math.min(valeur, avant.norm),
|
|
|
|
sign: Math.min(valeur, avant.sign),
|
|
|
|
part: valeur
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 19:51:12 +02:00
|
|
|
static async randomSigneDraconique(options = { ephemere: undefined }) {
|
2021-05-11 21:45:43 +02:00
|
|
|
let modele = await RdDDice.rollOneOf(tableSignesIndicatifs);
|
2021-05-11 21:21:33 +02:00
|
|
|
return {
|
|
|
|
name: await RdDItemSigneDraconique.randomSigneDescription(),
|
|
|
|
type: "signedraconique",
|
2021-05-18 19:51:12 +02:00
|
|
|
img: defaultItemImg.signedraconique,
|
2021-05-11 21:21:33 +02:00
|
|
|
data: {
|
|
|
|
typesTMR: await RdDItemSigneDraconique.randomTmrs(modele.nbCases),
|
2021-05-18 19:51:12 +02:00
|
|
|
ephemere: options?.ephemere == undefined ? RdDDice.rollTotal("1d2") == 2 : options.ephemere,
|
2021-05-11 21:21:33 +02:00
|
|
|
duree: "1 round",
|
|
|
|
difficulte: modele.difficulte,
|
|
|
|
valeur: { norm: modele.xp, sign: modele.xp, part: Math.floor(modele.xp * 1.5) },
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static async randomTmrs(nbTmr = undefined) {
|
2021-05-18 19:51:12 +02:00
|
|
|
let tmrs = Object.values(TMRType)
|
|
|
|
.map(value => TMRUtility.typeTmrName(value.name));
|
2021-05-11 21:45:43 +02:00
|
|
|
let keep = nbTmr ?? (await RdDDice.rollTotal("1d" + TMRType.length) + 1);
|
2021-05-11 21:21:33 +02:00
|
|
|
for (let i = tmrs.length; i > keep; i--) {
|
2021-05-11 21:45:43 +02:00
|
|
|
tmrs.splice(await RdDDice.rollTotal("1d" + i), 1);
|
2021-05-11 21:21:33 +02:00
|
|
|
}
|
|
|
|
return tmrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static async randomSigneDescription() {
|
|
|
|
return await RdDRollTables.drawTextFromRollTable("Signes draconiques", false);
|
|
|
|
}
|
|
|
|
|
2021-05-10 19:17:31 +02:00
|
|
|
}
|