@dicelette/core 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -130,30 +130,28 @@ var NoStatisticsError = class extends Error {
130
130
  var COMMENT_REGEX = /\s+(#|\/{2}|\[|\/\*)(.*)/;
131
131
  var SIGN_REGEX = /[><=!]+/;
132
132
  var SIGN_REGEX_SPACE = /[><=!]+(\S+)/;
133
- function roll(dice) {
134
- if (!dice.includes("d"))
135
- return void 0;
136
- const compareRegex = dice.match(SIGN_REGEX_SPACE);
133
+ function getCompare(dice, compareRegex) {
134
+ dice = dice.replace(SIGN_REGEX_SPACE, "");
137
135
  let compare;
138
- if (compareRegex) {
139
- dice = dice.replace(SIGN_REGEX_SPACE, "");
140
- const calc = compareRegex[1];
141
- const sign = calc.match(/[+-\/\*\^]/)?.[0];
142
- const compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];
143
- if (sign) {
144
- const toCalc = calc.replace(SIGN_REGEX, "").replace(/\s/g, "").replace(/;(.*)/, "");
145
- const total = (0, import_mathjs.evaluate)(toCalc);
146
- dice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);
147
- compare = {
148
- sign: compareSign,
149
- value: total
150
- };
151
- } else
152
- compare = {
153
- sign: compareSign,
154
- value: Number.parseInt(calc, 10)
155
- };
156
- }
136
+ const calc = compareRegex[1];
137
+ const sign = calc.match(/[+-\/\*\^]/)?.[0];
138
+ const compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];
139
+ if (sign) {
140
+ const toCalc = calc.replace(SIGN_REGEX, "").replace(/\s/g, "").replace(/;(.*)/, "");
141
+ const total = (0, import_mathjs.evaluate)(toCalc);
142
+ dice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);
143
+ compare = {
144
+ sign: compareSign,
145
+ value: total
146
+ };
147
+ } else
148
+ compare = {
149
+ sign: compareSign,
150
+ value: Number.parseInt(calc, 10)
151
+ };
152
+ return { dice, compare };
153
+ }
154
+ function getModifier(dice) {
157
155
  const modifier = dice.matchAll(/(\+|\-|%|\/|\^|\*|\*{2})(\d+)/gi);
158
156
  let modificator;
159
157
  for (const mod of modifier) {
@@ -173,8 +171,21 @@ function roll(dice) {
173
171
  };
174
172
  }
175
173
  }
174
+ return modificator;
175
+ }
176
+ function roll(dice) {
177
+ if (!dice.includes("d"))
178
+ return void 0;
179
+ const compareRegex = dice.match(SIGN_REGEX_SPACE);
180
+ let compare;
176
181
  if (dice.includes(";") && dice.includes("\xB5"))
177
182
  return multipleFunction(dice);
183
+ if (compareRegex) {
184
+ const compareResult = getCompare(dice, compareRegex);
185
+ dice = compareResult.dice;
186
+ compare = compareResult.compare;
187
+ }
188
+ const modificator = getModifier(dice);
178
189
  if (dice.match(/\d+?#(.*)/)) {
179
190
  const diceArray = dice.split("#");
180
191
  const numberOfDice = Number.parseInt(diceArray[0], 10);
@@ -221,6 +232,24 @@ function calculator(sign, value, total) {
221
232
  sign = "**";
222
233
  return (0, import_mathjs.evaluate)(`${total} ${sign} ${value}`);
223
234
  }
235
+ function inverseSign(sign) {
236
+ switch (sign) {
237
+ case "<":
238
+ return ">";
239
+ case ">":
240
+ return "<";
241
+ case "<=":
242
+ return ">=";
243
+ case ">=":
244
+ return "<=";
245
+ case "=":
246
+ return "!=";
247
+ case "==":
248
+ return "!=";
249
+ case "!=":
250
+ return "==";
251
+ }
252
+ }
224
253
  function multipleFunction(dice) {
225
254
  const results = [];
226
255
  const split = dice.split(";");
@@ -233,21 +262,45 @@ function multipleFunction(dice) {
233
262
  if (!total)
234
263
  return diceResult;
235
264
  for (let element of split.slice(1)) {
265
+ if (!element.includes("\xB5")) {
266
+ const result = roll(element);
267
+ if (!result)
268
+ continue;
269
+ results.push(result.result);
270
+ continue;
271
+ }
236
272
  const commentMatch = element.match(COMMENT_REGEX);
237
273
  element = element.replace(COMMENT_REGEX, "");
238
274
  const comment = commentMatch ? commentMatch[2] : void 0;
239
275
  if (comment)
240
276
  comments += ` ${comment}`;
241
- const toRoll = element.replace("\xB5", `${diceResult.total}`);
242
- const formule = element.replace("\xB5", `[${diceResult.total}]`);
243
- const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
244
- const resultat = (0, import_mathjs.evaluate)(toRoll);
245
- results.push(`\u2713 ${diceAll}: ${formule} = ${resultat}`);
277
+ let toRoll = element.replace("\xB5", `${diceResult.total}`);
278
+ let resultat;
279
+ const compareRegex = toRoll.match(SIGN_REGEX_SPACE);
280
+ if (compareRegex) {
281
+ const compareResult = getCompare(toRoll, compareRegex);
282
+ resultat = compareResult.compare.value;
283
+ toRoll = compareResult.dice;
284
+ const toCompare = `${toRoll}${compareResult.compare?.sign}${compareResult.compare?.value}`;
285
+ const res = (0, import_mathjs.evaluate)(toCompare);
286
+ if (typeof res === "boolean") {
287
+ const formule = element.replace("\xB5", `[${diceResult.total}]`);
288
+ const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
289
+ const validSign = res ? "\u2713" : "\u2715";
290
+ const invertedSign = res ? compareResult.compare.sign : inverseSign(compareResult.compare.sign);
291
+ results.push(`${validSign} ${diceAll}: ${formule} = ${(0, import_mathjs.evaluate)(toRoll)}${invertedSign}${compareResult.compare?.value}`);
292
+ }
293
+ } else {
294
+ resultat = (0, import_mathjs.evaluate)(toRoll);
295
+ const formule = element.replace("\xB5", `[${diceResult.total}]`);
296
+ const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
297
+ results.push(`\u25C8 ${diceAll}: ${formule} = ${resultat}`);
298
+ }
246
299
  total += resultat;
247
300
  }
248
301
  return {
249
302
  dice: split[0],
250
- result: results.join("\n"),
303
+ result: results.join(";"),
251
304
  comment: comments,
252
305
  compare: diceResult.compare,
253
306
  modifier: diceResult.modifier,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/dice.ts","../src/errors.ts","../src/utils.ts","../src/verify_template.ts"],"sourcesContent":["export * from \"./dice\";\nexport * from \"./interface\";\nexport * from \"./utils\";\nexport * from \"./verify_template\";\nexport * from \"./errors\";\n","/* eslint-disable no-useless-escape */\nimport { DiceRoller } from \"@dice-roller/rpg-dice-roller\";\nimport { evaluate } from \"mathjs\";\n\nimport type { Compare, Modifier, Resultat, Sign } from \".\";\nimport { DiceTypeError } from \"./errors\";\n\nexport const COMMENT_REGEX = /\\s+(#|\\/{2}|\\[|\\/\\*)(.*)/;\nconst SIGN_REGEX = /[><=!]+/;\nconst SIGN_REGEX_SPACE = /[><=!]+(\\S+)/;\n\n/**\n * Parse the string provided and turn it as a readable dice for dice parser\n * @param dice {string}\n */\nexport function roll(dice: string): Resultat | undefined {\n\t//parse dice string\n\tif (!dice.includes(\"d\")) return undefined;\n\tconst compareRegex = dice.match(SIGN_REGEX_SPACE);\n\tlet compare: Compare | undefined;\n\tif (compareRegex) {\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = dice.replace(SIGN_REGEX_SPACE, \"\");\n\t\tconst calc = compareRegex[1];\n\t\tconst sign = calc.match(/[+-\\/\\*\\^]/)?.[0];\n\t\tconst compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];\n\t\tif (sign) {\n\t\t\tconst toCalc = calc.replace(SIGN_REGEX, \"\").replace(/\\s/g, \"\").replace(/;(.*)/, \"\");\n\t\t\tconst total = evaluate(toCalc);\n\t\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\t\tdice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);\n\t\t\tcompare = {\n\t\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\t\tvalue: total,\n\t\t\t};\n\t\t} else\n\t\t\tcompare = {\n\t\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\t\tvalue: Number.parseInt(calc, 10),\n\t\t\t};\n\t}\n\tconst modifier = dice.matchAll(/(\\+|\\-|%|\\/|\\^|\\*|\\*{2})(\\d+)/gi);\n\tlet modificator: Modifier | undefined;\n\tfor (const mod of modifier) {\n\t\t//calculate the modifier if multiple\n\t\tif (modificator) {\n\t\t\tconst sign = modificator.sign;\n\t\t\tlet value = modificator.value;\n\t\t\tif (sign) value = calculator(sign, value, Number.parseInt(mod[2], 10));\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t} else {\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue: Number.parseInt(mod[2], 10),\n\t\t\t};\n\t\t}\n\t}\n\tif (dice.includes(\";\") && dice.includes(\"µ\")) return multipleFunction(dice);\n\n\tif (dice.match(/\\d+?#(.*)/)) {\n\t\tconst diceArray = dice.split(\"#\");\n\t\tconst numberOfDice = Number.parseInt(diceArray[0], 10);\n\t\tconst diceToRoll = diceArray[1].replace(COMMENT_REGEX, \"\");\n\t\tconst commentsMatch = diceArray[1].match(COMMENT_REGEX);\n\t\tconst comments = commentsMatch ? commentsMatch[2] : undefined;\n\t\tconst roller = new DiceRoller();\n\t\t//remove comments if any\n\t\tfor (let i = 0; i < numberOfDice; i++) {\n\t\t\ttry {\n\t\t\t\troller.roll(diceToRoll);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new DiceTypeError(diceToRoll, \"roll\", error);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tdice: diceToRoll,\n\t\t\tresult: roller.output,\n\t\t\tcomment: comments,\n\t\t\tcompare: compare ? compare : undefined,\n\t\t\tmodifier: modificator,\n\t\t\ttotal: roller.total,\n\t\t};\n\t}\n\tconst roller = new DiceRoller();\n\tconst diceWithoutComment = dice.replace(COMMENT_REGEX, \"\");\n\ttry {\n\t\troller.roll(diceWithoutComment);\n\t} catch (error) {\n\t\tthrow new DiceTypeError(diceWithoutComment, \"roll\", error);\n\t}\n\tconst commentMatch = dice.match(COMMENT_REGEX);\n\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\treturn {\n\t\tdice,\n\t\tresult: roller.output,\n\t\tcomment,\n\t\tcompare: compare ? compare : undefined,\n\t\tmodifier: modificator,\n\t\ttotal: roller.total,\n\t};\n}\n/**\n * Evaluate a formula and replace \"^\" by \"**\" if any\n * @param {Sign} sign\n * @param {number} value\n * @param {number} total\n * @returns\n */\nexport function calculator(sign: Sign, value: number, total: number): number {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tif (sign === \"^\") sign = \"**\";\n\treturn evaluate(`${total} ${sign} ${value}`);\n}\n\nexport function multipleFunction(dice: string): Resultat | undefined {\n\tconst results = [];\n\tconst split = dice.split(\";\");\n\tconst diceResult = roll(split[0]);\n\tif (!diceResult || !diceResult.total) return undefined;\n\tresults.push(`${diceResult.result}`);\n\tlet total = diceResult.total;\n\tlet comments = diceResult.comment ?? \"\";\n\tif (!total) return diceResult;\n\tfor (let element of split.slice(1)) {\n\t\t//remove comments & keep it\n\t\tconst commentMatch = element.match(COMMENT_REGEX);\n\t\telement = element.replace(COMMENT_REGEX, \"\");\n\t\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\t\tif (comment) comments += ` ${comment}`;\n\t\tconst toRoll = element.replace(\"µ\", `${diceResult.total}`);\n\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\tconst resultat = evaluate(toRoll);\n\t\tresults.push(`✓ ${diceAll}: ${formule} = ${resultat}`);\n\t\ttotal += resultat;\n\t}\n\n\treturn {\n\t\t\tdice: split[0],\n\t\t\tresult: results.join(\"\\n\"),\n\t\t\tcomment: comments,\n\t\t\tcompare: diceResult.compare,\n\t\t\tmodifier: diceResult.modifier,\n\t\t\ttotal\n\t\t}\n\t\n}\n","export class DiceTypeError extends Error {\n\tpublic readonly dice: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(dice: string, cause?: string, method?: unknown) {\n\t\tsuper(dice);\n\t\tthis.name = \"Invalid_Dice_Type\";\n\t\tthis.dice = dice;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class FormulaError extends Error {\n\tpublic readonly formula: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(formula: string, cause?: string, method?: unknown) {\n\t\tsuper(formula);\n\t\tthis.name = \"Invalid_Formula\";\n\t\tthis.formula = formula;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class MaxGreater extends Error {\n\tpublic readonly name: string;\n\tpublic readonly value: number;\n\tpublic readonly max: number;\n\n\tconstructor(value: number, max: number) {\n\t\tsuper(value.toString());\n\t\tthis.name = \"Max_Greater\";\n\t\tthis.value = value;\n\t\tthis.max = max;\n\t}\n}\n\nexport class EmptyObjectError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Empty_Object\";\n\t}\n}\n\nexport class TooManyDice extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Dice\";\n\t}\n}\n\nexport class TooManyStats extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Stats\";\n\t}\n}\n\nexport class NoStatisticsError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"No_Statistics\";\n\t}\n}\n","import { evaluate } from \"mathjs\";\nimport removeAccents from \"remove-accents\";\nimport { FormulaError } from \"./errors\";\n\n/**\n * Escape regex string\n * @param string {string}\n */\nexport function escapeRegex(string: string) {\n\treturn string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Replace the stat name by their value using stat and after evaluate any formula using `replaceFormulaInDice`\n * @param originalDice {dice}\n * @param stats {[name: string]: number}\n */\nexport function generateStatsDice(\n\toriginalDice: string,\n\tstats?: { [name: string]: number }\n) {\n\tlet dice = originalDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\t//damage field support adding statistic, like : 1d6 + strength\n\t\t//check if the value contains a statistic & calculate if it's okay\n\t\t//the dice will be converted before roll\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (dice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = dice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\treturn replaceFormulaInDice(dice);\n}\n\n/**\n * Replace the {{}} in the dice string and evaluate the interior if any\n * @param dice {string}\n */\nexport function replaceFormulaInDice(dice: string) {\n\tconst formula = /(?<formula>\\{{2}(.+?)\\}{2})/gim;\n\tconst formulaMatch = formula.exec(dice);\n\tif (formulaMatch?.groups?.formula) {\n\t\tconst formula = formulaMatch.groups.formula.replaceAll(\"{{\", \"\").replaceAll(\"}}\", \"\");\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\treturn cleanedDice(dice.replace(formulaMatch.groups.formula, result.toString()));\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(formulaMatch.groups.formula, \"replaceFormulaInDice\", error);\n\t\t}\n\t}\n\treturn cleanedDice(dice);\n}\n\n/**\n * Replace the ++ +- -- by their proper value:\n * - `++` = `+`\n * - `+-` = `-`\n * - `--` = `+`\n * @param dice {string}\n */\nexport function cleanedDice(dice: string) {\n\treturn dice.replaceAll(\"+-\", \"-\").replaceAll(\"--\", \"+\").replaceAll(\"++\", \"+\");\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { evaluate } from \"mathjs\";\nimport { Random } from \"random-js\";\nimport removeAccents from \"remove-accents\";\n\nimport type { Statistic, StatisticalTemplate } from \".\";\nimport { roll } from \"./dice\";\nimport { escapeRegex, replaceFormulaInDice } from \"./utils\";\nimport {\n\tDiceTypeError,\n\tEmptyObjectError,\n\tFormulaError,\n\tMaxGreater,\n\tNoStatisticsError,\n\tTooManyDice,\n\tTooManyStats,\n} from \"./errors\";\n\n/**\n * Verify if the provided dice work with random value\n * @param testDice {string}\n * @param stats {[name: string]: number}\n */\nexport function evalStatsDice(testDice: string, stats?: { [name: string]: number }) {\n\tlet dice = testDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (testDice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = testDice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\tif (!roll(replaceFormulaInDice(dice)))\n\t\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", \"no roll result\");\n\t\treturn testDice;\n\t} catch (error) {\n\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", error);\n\t}\n}\n\n/**\n * Generate a random dice and remove the formula (+ evaluate it)\n * Used for diceDamage only\n * @param value {string}\n * @param template {StatisticalTemplate}\n * @returns\n */\nexport function diceRandomParse(value: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return value;\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tvalue = removeAccents(value);\n\tconst allStats = Object.keys(template.statistics).map((stat) =>\n\t\tremoveAccents(stat).toLowerCase()\n\t);\n\tlet newDice = value;\n\tfor (const stat of allStats) {\n\t\tconst regex = new RegExp(escapeRegex(stat), \"gi\");\n\t\tif (value.match(regex)) {\n\t\t\tlet max: undefined | number = undefined;\n\t\t\tlet min: undefined | number = undefined;\n\t\t\tconst stats = template.statistics?.[stat];\n\t\t\tif (stats) {\n\t\t\t\tmax = template.statistics[removeAccents(stat).toLowerCase()].max;\n\t\t\t\tmin = template.statistics[removeAccents(stat).toLowerCase()].min;\n\t\t\t}\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tnewDice = value.replace(regex, randomStatValue.toString());\n\t\t}\n\t}\n\treturn replaceFormulaInDice(newDice);\n}\n\n/**\n * Same as damageDice but for DiceType\n * @param dice {string}\n * @param template {StatisticalTemplate}\n */\nexport function diceTypeRandomParse(dice: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return dice;\n\tconst firstStatNotCombinaison = Object.keys(template.statistics).find(\n\t\t(stat) => !template.statistics?.[stat].combinaison\n\t);\n\tif (!firstStatNotCombinaison) return dice;\n\tconst stats = template.statistics[firstStatNotCombinaison];\n\tconst { min, max } = stats;\n\tconst total = template.total || 100;\n\tconst randomStatValue = generateRandomStat(total, max, min);\n\treturn replaceFormulaInDice(dice.replace(\"$\", randomStatValue.toString()));\n}\n\n/**\n * Random the combinaison and evaluate it to check if everything is valid\n * @param combinaison {[name: string]: string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalCombinaison(\n\tcombinaison: { [name: string]: string },\n\tstats: { [name: string]: string | number }\n) {\n\tconst newStats: { [name: string]: number } = {};\n\tfor (const [stat, combin] of Object.entries(combinaison)) {\n\t\t//replace the stats in formula\n\t\tlet formula = removeAccents(combin);\n\t\tfor (const [statName, value] of Object.entries(stats)) {\n\t\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\t\tformula = formula.replace(regex, value.toString());\n\t\t}\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\tnewStats[stat] = result;\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(stat, \"evalCombinaison\", error);\n\t\t}\n\t}\n\treturn newStats;\n}\n\n/**\n * Evaluate one selected combinaison\n * @param combinaison {string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalOneCombinaison(\n\tcombinaison: string,\n\tstats: { [name: string]: string | number }\n) {\n\tlet formula = removeAccents(combinaison);\n\tfor (const [statName, value] of Object.entries(stats)) {\n\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\tformula = formula.replace(regex, value.toString());\n\t}\n\ttry {\n\t\treturn evaluate(formula);\n\t} catch (error) {\n\t\tthrow new FormulaError(combinaison, \"evalOneCombinaison\", error);\n\t}\n}\n\n/**\n * Parse the provided JSON and verify each field to check if everything could work when rolling\n * @param {any} template\n * @returns {StatisticalTemplate}\n */\n//biome-ignore lint/suspicious/noExplicitAny: I need to use any to allow any type\nexport function verifyTemplateValue(template: any): StatisticalTemplate {\n\tconst statistiqueTemplate: StatisticalTemplate = {\n\t\tdiceType: \"\",\n\t\tstatistics: {} as Statistic,\n\t};\n\tif (!template.statistics) statistiqueTemplate.statistics = undefined;\n\telse if (template.statistics && Object.keys(template.statistics).length > 0) {\n\t\tif (Object.keys(template.statistics).length > 25) throw new TooManyStats();\n\t\tfor (const [key, value] of Object.entries(template.statistics)) {\n\t\t\tconst dataValue = value as { max?: number; min?: number; combinaison?: string };\n\t\t\tif (dataValue.max && dataValue.min && dataValue.max <= dataValue.min)\n\t\t\t\tthrow new MaxGreater(dataValue.min, dataValue.max);\n\t\t\tif (dataValue.max && dataValue.max <= 0) dataValue.max = undefined;\n\t\t\tif (dataValue.min && dataValue.min <= 0) dataValue.min = undefined;\n\t\t\tlet formula = dataValue.combinaison\n\t\t\t\t? removeAccents(dataValue.combinaison).toLowerCase()\n\t\t\t\t: undefined;\n\t\t\tformula = formula && formula.trim().length > 0 ? formula : undefined;\n\t\t\tif (!statistiqueTemplate.statistics) {\n\t\t\t\tstatistiqueTemplate.statistics = {} as Statistic;\n\t\t\t}\n\t\t\tstatistiqueTemplate.statistics[key] = {\n\t\t\t\tmax: dataValue.max,\n\t\t\t\tmin: dataValue.min,\n\t\t\t\tcombinaison: formula || undefined,\n\t\t\t};\n\t\t}\n\t}\n\tif (template.diceType) {\n\t\ttry {\n\t\t\tstatistiqueTemplate.diceType = template.diceType;\n\t\t\tconst cleanedDice = diceTypeRandomParse(template.diceType, statistiqueTemplate);\n\t\t\tconst rolled = roll(cleanedDice);\n\t\t\tif (!rolled)\n\t\t\t\tthrow new DiceTypeError(cleanedDice, \"verifyTemplateValue\", \"no roll result\");\n\t\t} catch (e) {\n\t\t\tthrow new Error((e as Error).message);\n\t\t}\n\t}\n\n\tif (template.critical && Object.keys(template.critical).length > 0) {\n\t\tstatistiqueTemplate.critical = {\n\t\t\tfailure: template.critical.failure ?? undefined,\n\t\t\tsuccess: template.critical.success ?? undefined,\n\t\t};\n\t}\n\tif (template.total) {\n\t\tif (template.total <= 0) template.total = undefined;\n\t\tstatistiqueTemplate.total = template.total;\n\t}\n\tif (template.charName) statistiqueTemplate.charName = template.charName;\n\tif (template.damage) statistiqueTemplate.damage = template.damage;\n\ttry {\n\t\ttestDiceRegistered(statistiqueTemplate);\n\t\ttestStatCombinaison(statistiqueTemplate);\n\t} catch (error) {\n\t\tthrow new Error((error as Error).message);\n\t}\n\treturn statistiqueTemplate;\n}\n\n/**\n * Test each damage roll from the template.damage\n * @param {StatisticalTemplate} template\n */\nexport function testDiceRegistered(template: StatisticalTemplate) {\n\tif (!template.damage) return;\n\tif (Object.keys(template.damage).length === 0) throw new EmptyObjectError();\n\tif (Object.keys(template.damage).length > 25) throw new TooManyDice();\n\tfor (const [name, dice] of Object.entries(template.damage)) {\n\t\tif (!dice) continue;\n\t\tconst randomDiceParsed = diceRandomParse(dice, template);\n\t\ttry {\n\t\t\tconst rolled = roll(randomDiceParsed);\n\t\t\tif (!rolled) throw new DiceTypeError(name, \"testDiceRegistered\", \"no roll result\");\n\t\t} catch (error) {\n\t\t\tthrow new DiceTypeError(name, \"testDiceRegistered\", error);\n\t\t}\n\t}\n}\n\n/**\n * Test all combinaison with generated random value\n * @param {StatisticalTemplate} template\n */\nexport function testStatCombinaison(template: StatisticalTemplate) {\n\tif (!template.statistics) return;\n\tconst onlyCombinaisonStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(\n\t\t\t([_, value]) => value.combinaison !== undefined\n\t\t)\n\t);\n\tconst allOtherStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(([_, value]) => !value.combinaison)\n\t);\n\tif (Object.keys(onlyCombinaisonStats).length === 0) return;\n\tconst allStats = Object.keys(template.statistics).filter(\n\t\t(stat) => !template.statistics![stat].combinaison\n\t);\n\tif (allStats.length === 0) throw new NoStatisticsError();\n\tconst error = [];\n\tfor (const [stat, value] of Object.entries(onlyCombinaisonStats)) {\n\t\tlet formula = value.combinaison as string;\n\t\tfor (const [other, data] of Object.entries(allOtherStats)) {\n\t\t\tconst { max, min } = data;\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tconst regex = new RegExp(other, \"gi\");\n\t\t\tformula = formula.replace(regex, randomStatValue.toString());\n\t\t}\n\t\ttry {\n\t\t\tevaluate(formula);\n\t\t} catch (e) {\n\t\t\terror.push(stat);\n\t\t}\n\t}\n\tif (error.length > 0) throw new FormulaError(error.join(\", \"), \"testStatCombinaison\");\n\treturn;\n}\n\n/**\n * Generate a random stat based on the template and the statistical min and max\n * @param {number|undefined} total\n * @param {number | undefined} max\n * @param {number | undefined} min\n * @returns\n */\nexport function generateRandomStat(\n\ttotal: number | undefined = 100,\n\tmax?: number,\n\tmin?: number\n) {\n\tlet randomStatValue = total + 1;\n\twhile (randomStatValue >= total) {\n\t\tconst random = new Random();\n\t\tif (max && min) randomStatValue = random.integer(min, max);\n\t\telse if (max) randomStatValue = random.integer(0, max);\n\t\telse if (min) randomStatValue = random.integer(min, total);\n\t\telse randomStatValue = random.integer(0, total);\n\t}\n\treturn randomStatValue;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,6BAA2B;AAC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AAAG;AACpD,QAAM,WAAW,OAAO,KAAK,SAAS,UAAU,EAAE;AAAA,IACjD,CAAC,SAAS,CAAC,SAAS,WAAY,IAAI,EAAE;AAAA,EACvC;AACA,MAAI,SAAS,WAAW;AAAG,UAAM,IAAI,kBAAkB;AACvD,QAAM,QAAQ,CAAC;AACf,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,oBAAoB,GAAG;AACjE,QAAI,UAAU,MAAM;AACpB,eAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,aAAa,GAAG;AAC1D,YAAM,EAAE,KAAK,IAAI,IAAI;AACrB,YAAM,QAAQ,SAAS,SAAS;AAChC,YAAM,kBAAkB,mBAAmB,OAAO,KAAK,GAAG;AAC1D,YAAM,QAAQ,IAAI,OAAO,OAAO,IAAI;AACpC,gBAAU,QAAQ,QAAQ,OAAO,gBAAgB,SAAS,CAAC;AAAA,IAC5D;AACA,QAAI;AACH,mCAAS,OAAO;AAAA,IACjB,SAAS,GAAG;AACX,YAAM,KAAK,IAAI;AAAA,IAChB;AAAA,EACD;AACA,MAAI,MAAM,SAAS;AAAG,UAAM,IAAI,aAAa,MAAM,KAAK,IAAI,GAAG,qBAAqB;AACpF;AACD;AASO,SAAS,mBACf,QAA4B,KAC5B,KACA,KACC;AACD,MAAI,kBAAkB,QAAQ;AAC9B,SAAO,mBAAmB,OAAO;AAChC,UAAM,SAAS,IAAI,wBAAO;AAC1B,QAAI,OAAO;AAAK,wBAAkB,OAAO,QAAQ,KAAK,GAAG;AAAA,aAChD;AAAK,wBAAkB,OAAO,QAAQ,GAAG,GAAG;AAAA,aAC5C;AAAK,wBAAkB,OAAO,QAAQ,KAAK,KAAK;AAAA;AACpD,wBAAkB,OAAO,QAAQ,GAAG,KAAK;AAAA,EAC/C;AACA,SAAO;AACR;","names":["roller","import_mathjs","removeAccents","formula","import_mathjs","import_remove_accents","removeAccents","cleanedDice"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/dice.ts","../src/errors.ts","../src/utils.ts","../src/verify_template.ts"],"sourcesContent":["export * from \"./dice\";\nexport * from \"./interface\";\nexport * from \"./utils\";\nexport * from \"./verify_template\";\nexport * from \"./errors\";\n","/* eslint-disable no-useless-escape */\nimport { DiceRoller } from \"@dice-roller/rpg-dice-roller\";\nimport { evaluate } from \"mathjs\";\n\nimport type { Compare, Modifier, Resultat, Sign } from \".\";\nimport { DiceTypeError } from \"./errors\";\n\nexport const COMMENT_REGEX = /\\s+(#|\\/{2}|\\[|\\/\\*)(.*)/;\nconst SIGN_REGEX = /[><=!]+/;\nconst SIGN_REGEX_SPACE = /[><=!]+(\\S+)/;\n\nfunction getCompare(dice: string, compareRegex: RegExpMatchArray): {dice: string; compare: Compare | undefined} {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tdice = dice.replace(SIGN_REGEX_SPACE, \"\");\n\tlet compare: Compare;\n\tconst calc = compareRegex[1];\n\tconst sign = calc.match(/[+-\\/\\*\\^]/)?.[0];\n\tconst compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];\n\tif (sign) {\n\t\tconst toCalc = calc.replace(SIGN_REGEX, \"\").replace(/\\s/g, \"\").replace(/;(.*)/, \"\");\n\t\tconst total = evaluate(toCalc);\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);\n\t\tcompare = {\n\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\tvalue: total,\n\t\t};\n\t} else\n\t\tcompare = {\n\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\tvalue: Number.parseInt(calc, 10),\n\t\t};\n\treturn {dice, compare};\n}\n\nfunction getModifier(dice: string) {\n\tconst modifier = dice.matchAll(/(\\+|\\-|%|\\/|\\^|\\*|\\*{2})(\\d+)/gi);\n\tlet modificator: Modifier | undefined;\n\tfor (const mod of modifier) {\n\t\t//calculate the modifier if multiple\n\t\tif (modificator) {\n\t\t\tconst sign = modificator.sign;\n\t\t\tlet value = modificator.value;\n\t\t\tif (sign) value = calculator(sign, value, Number.parseInt(mod[2], 10));\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t} else {\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue: Number.parseInt(mod[2], 10),\n\t\t\t};\n\t\t}\n\t}\n\treturn modificator;\n}\n\n/**\n * Parse the string provided and turn it as a readable dice for dice parser\n * @param dice {string}\n */\nexport function roll(dice: string): Resultat | undefined {\n\t//parse dice string\n\tif (!dice.includes(\"d\")) return undefined;\n\tconst compareRegex = dice.match(SIGN_REGEX_SPACE);\n\tlet compare: Compare | undefined;\n\tif (dice.includes(\";\") && dice.includes(\"µ\")) return multipleFunction(dice);\n\tif (compareRegex) {\n\t\tconst compareResult = getCompare(dice, compareRegex);\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = compareResult.dice;\n\t\tcompare = compareResult.compare;\n\t}\n\tconst modificator = getModifier(dice);\n\n\tif (dice.match(/\\d+?#(.*)/)) {\n\t\tconst diceArray = dice.split(\"#\");\n\t\tconst numberOfDice = Number.parseInt(diceArray[0], 10);\n\t\tconst diceToRoll = diceArray[1].replace(COMMENT_REGEX, \"\");\n\t\tconst commentsMatch = diceArray[1].match(COMMENT_REGEX);\n\t\tconst comments = commentsMatch ? commentsMatch[2] : undefined;\n\t\tconst roller = new DiceRoller();\n\t\t//remove comments if any\n\t\tfor (let i = 0; i < numberOfDice; i++) {\n\t\t\ttry {\n\t\t\t\troller.roll(diceToRoll);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new DiceTypeError(diceToRoll, \"roll\", error);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tdice: diceToRoll,\n\t\t\tresult: roller.output,\n\t\t\tcomment: comments,\n\t\t\tcompare: compare ? compare : undefined,\n\t\t\tmodifier: modificator,\n\t\t\ttotal: roller.total,\n\t\t};\n\t}\n\tconst roller = new DiceRoller();\n\tconst diceWithoutComment = dice.replace(COMMENT_REGEX, \"\");\n\ttry {\n\t\troller.roll(diceWithoutComment);\n\t} catch (error) {\n\t\tthrow new DiceTypeError(diceWithoutComment, \"roll\", error);\n\t}\n\tconst commentMatch = dice.match(COMMENT_REGEX);\n\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\treturn {\n\t\tdice,\n\t\tresult: roller.output,\n\t\tcomment,\n\t\tcompare: compare ? compare : undefined,\n\t\tmodifier: modificator,\n\t\ttotal: roller.total,\n\t};\n}\n/**\n * Evaluate a formula and replace \"^\" by \"**\" if any\n * @param {Sign} sign\n * @param {number} value\n * @param {number} total\n * @returns\n */\nexport function calculator(sign: Sign, value: number, total: number): number {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tif (sign === \"^\") sign = \"**\";\n\treturn evaluate(`${total} ${sign} ${value}`);\n}\n\nfunction compareResult(result: number, compare: Compare): boolean {\n\tswitch (compare.sign) {\n\t\tcase \"<\":\n\t\t\treturn result < compare.value;\n\t\tcase \">\":\n\t\t\treturn result > compare.value;\n\t\tcase \"<=\":\n\t\t\treturn result <= compare.value;\n\t\tcase \">=\":\n\t\t\treturn result >= compare.value;\n\t\tcase \"=\":\n\t\t\treturn result === compare.value;\n\t\tcase \"==\":\n\t\t\treturn result === compare.value;\n\t\tcase \"!=\":\n\t\t\treturn result !== compare.value;\n\t}\n}\n\nfunction inverseSign(sign: \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\"): \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\" {\n\tswitch (sign) {\n\t\tcase \"<\":\n\t\t\treturn \">\";\n\t\tcase \">\":\n\t\t\treturn \"<\";\n\t\tcase \"<=\":\n\t\t\treturn \">=\";\n\t\tcase \">=\":\n\t\t\treturn \"<=\";\n\t\tcase \"=\":\n\t\t\treturn \"!=\";\n\t\tcase \"==\":\n\t\t\treturn \"!=\";\n\t\tcase \"!=\":\n\t\t\treturn \"==\";\n\t}\n}\n\nexport function multipleFunction(dice: string): Resultat | undefined {\n\tconst results = [];\n\tconst split = dice.split(\";\");\n\tconst diceResult = roll(split[0]);\n\tif (!diceResult || !diceResult.total) return undefined;\n\tresults.push(`${diceResult.result}`);\n\t\n\tlet total = diceResult.total;\n\tlet comments = diceResult.comment ?? \"\";\n\tif (!total) return diceResult;\n\tfor (let element of split.slice(1)) {\n\t\tif (!element.includes(\"µ\")) {\n\t\t\tconst result = roll(element);\n\t\t\tif (!result) continue;\n\t\t\tresults.push(result.result);\n\t\t\tcontinue;\n\t\t}\n\t\t//remove comments & keep it\n\t\tconst commentMatch = element.match(COMMENT_REGEX);\n\t\telement = element.replace(COMMENT_REGEX, \"\");\n\t\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\t\tif (comment) comments += ` ${comment}`;\n\t\tlet toRoll = element.replace(\"µ\", `${diceResult.total}`);\n\t\tlet resultat: number;\n\t\tconst compareRegex = toRoll.match(SIGN_REGEX_SPACE);\n\t\tif (compareRegex) {\n\t\t\tconst compareResult = getCompare(toRoll, compareRegex);\n\t\t\tresultat = compareResult.compare!.value;\n\t\t\ttoRoll = compareResult.dice;\n\t\t\tconst toCompare = `${toRoll}${compareResult.compare?.sign}${compareResult.compare?.value}`;\n\t\t\tconst res = evaluate(toCompare);\n\t\t\tif (typeof res === \"boolean\") {\n\t\t\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\t\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\t\t\tconst validSign = res ? \"✓\" : \"✕\";\n\t\t\t\tconst invertedSign = res ? compareResult.compare!.sign : inverseSign(compareResult.compare!.sign);\n\t\t\t\tresults.push(`${validSign} ${diceAll}: ${formule} = ${evaluate(toRoll)}${invertedSign}${compareResult.compare?.value}`);\n\t\t\t}\n\t\t} else {\n\t\t\tresultat = evaluate(toRoll);\n\t\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\t\tresults.push(`◈ ${diceAll}: ${formule} = ${resultat}`);\n\t\t}\n\t\ttotal += resultat;\n\t}\n\n\treturn {\n\t\t\tdice: split[0],\n\t\t\tresult: results.join(\";\"),\n\t\t\tcomment: comments,\n\t\t\tcompare: diceResult.compare,\n\t\t\tmodifier: diceResult.modifier,\n\t\t\ttotal\n\t\t}\n\t\n}\n","export class DiceTypeError extends Error {\n\tpublic readonly dice: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(dice: string, cause?: string, method?: unknown) {\n\t\tsuper(dice);\n\t\tthis.name = \"Invalid_Dice_Type\";\n\t\tthis.dice = dice;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class FormulaError extends Error {\n\tpublic readonly formula: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(formula: string, cause?: string, method?: unknown) {\n\t\tsuper(formula);\n\t\tthis.name = \"Invalid_Formula\";\n\t\tthis.formula = formula;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class MaxGreater extends Error {\n\tpublic readonly name: string;\n\tpublic readonly value: number;\n\tpublic readonly max: number;\n\n\tconstructor(value: number, max: number) {\n\t\tsuper(value.toString());\n\t\tthis.name = \"Max_Greater\";\n\t\tthis.value = value;\n\t\tthis.max = max;\n\t}\n}\n\nexport class EmptyObjectError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Empty_Object\";\n\t}\n}\n\nexport class TooManyDice extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Dice\";\n\t}\n}\n\nexport class TooManyStats extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Stats\";\n\t}\n}\n\nexport class NoStatisticsError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"No_Statistics\";\n\t}\n}\n","import { evaluate } from \"mathjs\";\nimport removeAccents from \"remove-accents\";\nimport { FormulaError } from \"./errors\";\n\n/**\n * Escape regex string\n * @param string {string}\n */\nexport function escapeRegex(string: string) {\n\treturn string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Replace the stat name by their value using stat and after evaluate any formula using `replaceFormulaInDice`\n * @param originalDice {dice}\n * @param stats {[name: string]: number}\n */\nexport function generateStatsDice(\n\toriginalDice: string,\n\tstats?: { [name: string]: number }\n) {\n\tlet dice = originalDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\t//damage field support adding statistic, like : 1d6 + strength\n\t\t//check if the value contains a statistic & calculate if it's okay\n\t\t//the dice will be converted before roll\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (dice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = dice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\treturn replaceFormulaInDice(dice);\n}\n\n/**\n * Replace the {{}} in the dice string and evaluate the interior if any\n * @param dice {string}\n */\nexport function replaceFormulaInDice(dice: string) {\n\tconst formula = /(?<formula>\\{{2}(.+?)\\}{2})/gim;\n\tconst formulaMatch = formula.exec(dice);\n\tif (formulaMatch?.groups?.formula) {\n\t\tconst formula = formulaMatch.groups.formula.replaceAll(\"{{\", \"\").replaceAll(\"}}\", \"\");\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\treturn cleanedDice(dice.replace(formulaMatch.groups.formula, result.toString()));\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(formulaMatch.groups.formula, \"replaceFormulaInDice\", error);\n\t\t}\n\t}\n\treturn cleanedDice(dice);\n}\n\n/**\n * Replace the ++ +- -- by their proper value:\n * - `++` = `+`\n * - `+-` = `-`\n * - `--` = `+`\n * @param dice {string}\n */\nexport function cleanedDice(dice: string) {\n\treturn dice.replaceAll(\"+-\", \"-\").replaceAll(\"--\", \"+\").replaceAll(\"++\", \"+\");\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { evaluate } from \"mathjs\";\nimport { Random } from \"random-js\";\nimport removeAccents from \"remove-accents\";\n\nimport type { Statistic, StatisticalTemplate } from \".\";\nimport { roll } from \"./dice\";\nimport { escapeRegex, replaceFormulaInDice } from \"./utils\";\nimport {\n\tDiceTypeError,\n\tEmptyObjectError,\n\tFormulaError,\n\tMaxGreater,\n\tNoStatisticsError,\n\tTooManyDice,\n\tTooManyStats,\n} from \"./errors\";\n\n/**\n * Verify if the provided dice work with random value\n * @param testDice {string}\n * @param stats {[name: string]: number}\n */\nexport function evalStatsDice(testDice: string, stats?: { [name: string]: number }) {\n\tlet dice = testDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (testDice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = testDice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\tif (!roll(replaceFormulaInDice(dice)))\n\t\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", \"no roll result\");\n\t\treturn testDice;\n\t} catch (error) {\n\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", error);\n\t}\n}\n\n/**\n * Generate a random dice and remove the formula (+ evaluate it)\n * Used for diceDamage only\n * @param value {string}\n * @param template {StatisticalTemplate}\n * @returns\n */\nexport function diceRandomParse(value: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return value;\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tvalue = removeAccents(value);\n\tconst allStats = Object.keys(template.statistics).map((stat) =>\n\t\tremoveAccents(stat).toLowerCase()\n\t);\n\tlet newDice = value;\n\tfor (const stat of allStats) {\n\t\tconst regex = new RegExp(escapeRegex(stat), \"gi\");\n\t\tif (value.match(regex)) {\n\t\t\tlet max: undefined | number = undefined;\n\t\t\tlet min: undefined | number = undefined;\n\t\t\tconst stats = template.statistics?.[stat];\n\t\t\tif (stats) {\n\t\t\t\tmax = template.statistics[removeAccents(stat).toLowerCase()].max;\n\t\t\t\tmin = template.statistics[removeAccents(stat).toLowerCase()].min;\n\t\t\t}\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tnewDice = value.replace(regex, randomStatValue.toString());\n\t\t}\n\t}\n\treturn replaceFormulaInDice(newDice);\n}\n\n/**\n * Same as damageDice but for DiceType\n * @param dice {string}\n * @param template {StatisticalTemplate}\n */\nexport function diceTypeRandomParse(dice: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return dice;\n\tconst firstStatNotCombinaison = Object.keys(template.statistics).find(\n\t\t(stat) => !template.statistics?.[stat].combinaison\n\t);\n\tif (!firstStatNotCombinaison) return dice;\n\tconst stats = template.statistics[firstStatNotCombinaison];\n\tconst { min, max } = stats;\n\tconst total = template.total || 100;\n\tconst randomStatValue = generateRandomStat(total, max, min);\n\treturn replaceFormulaInDice(dice.replace(\"$\", randomStatValue.toString()));\n}\n\n/**\n * Random the combinaison and evaluate it to check if everything is valid\n * @param combinaison {[name: string]: string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalCombinaison(\n\tcombinaison: { [name: string]: string },\n\tstats: { [name: string]: string | number }\n) {\n\tconst newStats: { [name: string]: number } = {};\n\tfor (const [stat, combin] of Object.entries(combinaison)) {\n\t\t//replace the stats in formula\n\t\tlet formula = removeAccents(combin);\n\t\tfor (const [statName, value] of Object.entries(stats)) {\n\t\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\t\tformula = formula.replace(regex, value.toString());\n\t\t}\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\tnewStats[stat] = result;\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(stat, \"evalCombinaison\", error);\n\t\t}\n\t}\n\treturn newStats;\n}\n\n/**\n * Evaluate one selected combinaison\n * @param combinaison {string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalOneCombinaison(\n\tcombinaison: string,\n\tstats: { [name: string]: string | number }\n) {\n\tlet formula = removeAccents(combinaison);\n\tfor (const [statName, value] of Object.entries(stats)) {\n\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\tformula = formula.replace(regex, value.toString());\n\t}\n\ttry {\n\t\treturn evaluate(formula);\n\t} catch (error) {\n\t\tthrow new FormulaError(combinaison, \"evalOneCombinaison\", error);\n\t}\n}\n\n/**\n * Parse the provided JSON and verify each field to check if everything could work when rolling\n * @param {any} template\n * @returns {StatisticalTemplate}\n */\n//biome-ignore lint/suspicious/noExplicitAny: I need to use any to allow any type\nexport function verifyTemplateValue(template: any): StatisticalTemplate {\n\tconst statistiqueTemplate: StatisticalTemplate = {\n\t\tdiceType: \"\",\n\t\tstatistics: {} as Statistic,\n\t};\n\tif (!template.statistics) statistiqueTemplate.statistics = undefined;\n\telse if (template.statistics && Object.keys(template.statistics).length > 0) {\n\t\tif (Object.keys(template.statistics).length > 25) throw new TooManyStats();\n\t\tfor (const [key, value] of Object.entries(template.statistics)) {\n\t\t\tconst dataValue = value as { max?: number; min?: number; combinaison?: string };\n\t\t\tif (dataValue.max && dataValue.min && dataValue.max <= dataValue.min)\n\t\t\t\tthrow new MaxGreater(dataValue.min, dataValue.max);\n\t\t\tif (dataValue.max && dataValue.max <= 0) dataValue.max = undefined;\n\t\t\tif (dataValue.min && dataValue.min <= 0) dataValue.min = undefined;\n\t\t\tlet formula = dataValue.combinaison\n\t\t\t\t? removeAccents(dataValue.combinaison).toLowerCase()\n\t\t\t\t: undefined;\n\t\t\tformula = formula && formula.trim().length > 0 ? formula : undefined;\n\t\t\tif (!statistiqueTemplate.statistics) {\n\t\t\t\tstatistiqueTemplate.statistics = {} as Statistic;\n\t\t\t}\n\t\t\tstatistiqueTemplate.statistics[key] = {\n\t\t\t\tmax: dataValue.max,\n\t\t\t\tmin: dataValue.min,\n\t\t\t\tcombinaison: formula || undefined,\n\t\t\t};\n\t\t}\n\t}\n\tif (template.diceType) {\n\t\ttry {\n\t\t\tstatistiqueTemplate.diceType = template.diceType;\n\t\t\tconst cleanedDice = diceTypeRandomParse(template.diceType, statistiqueTemplate);\n\t\t\tconst rolled = roll(cleanedDice);\n\t\t\tif (!rolled)\n\t\t\t\tthrow new DiceTypeError(cleanedDice, \"verifyTemplateValue\", \"no roll result\");\n\t\t} catch (e) {\n\t\t\tthrow new Error((e as Error).message);\n\t\t}\n\t}\n\n\tif (template.critical && Object.keys(template.critical).length > 0) {\n\t\tstatistiqueTemplate.critical = {\n\t\t\tfailure: template.critical.failure ?? undefined,\n\t\t\tsuccess: template.critical.success ?? undefined,\n\t\t};\n\t}\n\tif (template.total) {\n\t\tif (template.total <= 0) template.total = undefined;\n\t\tstatistiqueTemplate.total = template.total;\n\t}\n\tif (template.charName) statistiqueTemplate.charName = template.charName;\n\tif (template.damage) statistiqueTemplate.damage = template.damage;\n\ttry {\n\t\ttestDiceRegistered(statistiqueTemplate);\n\t\ttestStatCombinaison(statistiqueTemplate);\n\t} catch (error) {\n\t\tthrow new Error((error as Error).message);\n\t}\n\treturn statistiqueTemplate;\n}\n\n/**\n * Test each damage roll from the template.damage\n * @param {StatisticalTemplate} template\n */\nexport function testDiceRegistered(template: StatisticalTemplate) {\n\tif (!template.damage) return;\n\tif (Object.keys(template.damage).length === 0) throw new EmptyObjectError();\n\tif (Object.keys(template.damage).length > 25) throw new TooManyDice();\n\tfor (const [name, dice] of Object.entries(template.damage)) {\n\t\tif (!dice) continue;\n\t\tconst randomDiceParsed = diceRandomParse(dice, template);\n\t\ttry {\n\t\t\tconst rolled = roll(randomDiceParsed);\n\t\t\tif (!rolled) throw new DiceTypeError(name, \"testDiceRegistered\", \"no roll result\");\n\t\t} catch (error) {\n\t\t\tthrow new DiceTypeError(name, \"testDiceRegistered\", error);\n\t\t}\n\t}\n}\n\n/**\n * Test all combinaison with generated random value\n * @param {StatisticalTemplate} template\n */\nexport function testStatCombinaison(template: StatisticalTemplate) {\n\tif (!template.statistics) return;\n\tconst onlyCombinaisonStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(\n\t\t\t([_, value]) => value.combinaison !== undefined\n\t\t)\n\t);\n\tconst allOtherStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(([_, value]) => !value.combinaison)\n\t);\n\tif (Object.keys(onlyCombinaisonStats).length === 0) return;\n\tconst allStats = Object.keys(template.statistics).filter(\n\t\t(stat) => !template.statistics![stat].combinaison\n\t);\n\tif (allStats.length === 0) throw new NoStatisticsError();\n\tconst error = [];\n\tfor (const [stat, value] of Object.entries(onlyCombinaisonStats)) {\n\t\tlet formula = value.combinaison as string;\n\t\tfor (const [other, data] of Object.entries(allOtherStats)) {\n\t\t\tconst { max, min } = data;\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tconst regex = new RegExp(other, \"gi\");\n\t\t\tformula = formula.replace(regex, randomStatValue.toString());\n\t\t}\n\t\ttry {\n\t\t\tevaluate(formula);\n\t\t} catch (e) {\n\t\t\terror.push(stat);\n\t\t}\n\t}\n\tif (error.length > 0) throw new FormulaError(error.join(\", \"), \"testStatCombinaison\");\n\treturn;\n}\n\n/**\n * Generate a random stat based on the template and the statistical min and max\n * @param {number|undefined} total\n * @param {number | undefined} max\n * @param {number | undefined} min\n * @returns\n */\nexport function generateRandomStat(\n\ttotal: number | undefined = 100,\n\tmax?: number,\n\tmin?: number\n) {\n\tlet randomStatValue = total + 1;\n\twhile (randomStatValue >= total) {\n\t\tconst random = new Random();\n\t\tif (max && min) randomStatValue = random.integer(min, max);\n\t\telse if (max) randomStatValue = random.integer(0, max);\n\t\telse if (min) randomStatValue = random.integer(min, total);\n\t\telse randomStatValue = random.integer(0, total);\n\t}\n\treturn randomStatValue;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,6BAA2B;AAC3B,oBAAyB;;;ACFlB,IAAM,gBAAN,cAA4B,MAAM;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YAAY,MAAc,OAAgB,QAAkB;AAC3D,UAAM,IAAI;AACV,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,SAAS;AAAA,EACf;AACD;AAEO,IAAM,eAAN,cAA2B,MAAM;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YAAY,SAAiB,OAAgB,QAAkB;AAC9D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,SAAK,QAAQ;AACb,SAAK,SAAS;AAAA,EACf;AACD;AAEO,IAAM,aAAN,cAAyB,MAAM;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YAAY,OAAe,KAAa;AACvC,UAAM,MAAM,SAAS,CAAC;AACtB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,MAAM;AAAA,EACZ;AACD;AAEO,IAAM,mBAAN,cAA+B,MAAM;AAAA,EAC3B;AAAA,EAEhB,cAAc;AACb,UAAM;AACN,SAAK,OAAO;AAAA,EACb;AACD;AAEO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACtB;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AS;AAAG,UAAM,IAAI,aAAa,MAAM,KAAK,IAAI,GAAG,qBAAqB;AACpF;AACD;AASO,SAAS,mBACf,QAA4B,KAC5B,KACA,KACC;AACD,MAAI,kBAAkB,QAAQ;AAC9B,SAAO,mBAAmB,OAAO;AAChC,UAAM,SAAS,IAAI,wBAAO;AAC1B,QAAI,OAAO;AAAK,wBAAkB,OAAO,QAAQ,KAAK,GAAG;AAAA,aAChD;AAAK,wBAAkB,OAAO,QAAQ,GAAG,GAAG;AAAA,aAC5C;AAAK,wBAAkB,OAAO,QAAQ,KAAK,KAAK;AAAA;AACpD,wBAAkB,OAAO,QAAQ,GAAG,KAAK;AAAA,EAC/C;AACA,SAAO;AACR;","names":["roller","import_mathjs","removeAccents","formula","import_mathjs","import_remove_accents","removeAccents","cleanedDice"]}
package/dist/index.mjs CHANGED
@@ -71,30 +71,28 @@ var NoStatisticsError = class extends Error {
71
71
  var COMMENT_REGEX = /\s+(#|\/{2}|\[|\/\*)(.*)/;
72
72
  var SIGN_REGEX = /[><=!]+/;
73
73
  var SIGN_REGEX_SPACE = /[><=!]+(\S+)/;
74
- function roll(dice) {
75
- if (!dice.includes("d"))
76
- return void 0;
77
- const compareRegex = dice.match(SIGN_REGEX_SPACE);
74
+ function getCompare(dice, compareRegex) {
75
+ dice = dice.replace(SIGN_REGEX_SPACE, "");
78
76
  let compare;
79
- if (compareRegex) {
80
- dice = dice.replace(SIGN_REGEX_SPACE, "");
81
- const calc = compareRegex[1];
82
- const sign = calc.match(/[+-\/\*\^]/)?.[0];
83
- const compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];
84
- if (sign) {
85
- const toCalc = calc.replace(SIGN_REGEX, "").replace(/\s/g, "").replace(/;(.*)/, "");
86
- const total = evaluate(toCalc);
87
- dice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);
88
- compare = {
89
- sign: compareSign,
90
- value: total
91
- };
92
- } else
93
- compare = {
94
- sign: compareSign,
95
- value: Number.parseInt(calc, 10)
96
- };
97
- }
77
+ const calc = compareRegex[1];
78
+ const sign = calc.match(/[+-\/\*\^]/)?.[0];
79
+ const compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];
80
+ if (sign) {
81
+ const toCalc = calc.replace(SIGN_REGEX, "").replace(/\s/g, "").replace(/;(.*)/, "");
82
+ const total = evaluate(toCalc);
83
+ dice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);
84
+ compare = {
85
+ sign: compareSign,
86
+ value: total
87
+ };
88
+ } else
89
+ compare = {
90
+ sign: compareSign,
91
+ value: Number.parseInt(calc, 10)
92
+ };
93
+ return { dice, compare };
94
+ }
95
+ function getModifier(dice) {
98
96
  const modifier = dice.matchAll(/(\+|\-|%|\/|\^|\*|\*{2})(\d+)/gi);
99
97
  let modificator;
100
98
  for (const mod of modifier) {
@@ -114,8 +112,21 @@ function roll(dice) {
114
112
  };
115
113
  }
116
114
  }
115
+ return modificator;
116
+ }
117
+ function roll(dice) {
118
+ if (!dice.includes("d"))
119
+ return void 0;
120
+ const compareRegex = dice.match(SIGN_REGEX_SPACE);
121
+ let compare;
117
122
  if (dice.includes(";") && dice.includes("\xB5"))
118
123
  return multipleFunction(dice);
124
+ if (compareRegex) {
125
+ const compareResult = getCompare(dice, compareRegex);
126
+ dice = compareResult.dice;
127
+ compare = compareResult.compare;
128
+ }
129
+ const modificator = getModifier(dice);
119
130
  if (dice.match(/\d+?#(.*)/)) {
120
131
  const diceArray = dice.split("#");
121
132
  const numberOfDice = Number.parseInt(diceArray[0], 10);
@@ -162,6 +173,24 @@ function calculator(sign, value, total) {
162
173
  sign = "**";
163
174
  return evaluate(`${total} ${sign} ${value}`);
164
175
  }
176
+ function inverseSign(sign) {
177
+ switch (sign) {
178
+ case "<":
179
+ return ">";
180
+ case ">":
181
+ return "<";
182
+ case "<=":
183
+ return ">=";
184
+ case ">=":
185
+ return "<=";
186
+ case "=":
187
+ return "!=";
188
+ case "==":
189
+ return "!=";
190
+ case "!=":
191
+ return "==";
192
+ }
193
+ }
165
194
  function multipleFunction(dice) {
166
195
  const results = [];
167
196
  const split = dice.split(";");
@@ -174,21 +203,45 @@ function multipleFunction(dice) {
174
203
  if (!total)
175
204
  return diceResult;
176
205
  for (let element of split.slice(1)) {
206
+ if (!element.includes("\xB5")) {
207
+ const result = roll(element);
208
+ if (!result)
209
+ continue;
210
+ results.push(result.result);
211
+ continue;
212
+ }
177
213
  const commentMatch = element.match(COMMENT_REGEX);
178
214
  element = element.replace(COMMENT_REGEX, "");
179
215
  const comment = commentMatch ? commentMatch[2] : void 0;
180
216
  if (comment)
181
217
  comments += ` ${comment}`;
182
- const toRoll = element.replace("\xB5", `${diceResult.total}`);
183
- const formule = element.replace("\xB5", `[${diceResult.total}]`);
184
- const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
185
- const resultat = evaluate(toRoll);
186
- results.push(`\u2713 ${diceAll}: ${formule} = ${resultat}`);
218
+ let toRoll = element.replace("\xB5", `${diceResult.total}`);
219
+ let resultat;
220
+ const compareRegex = toRoll.match(SIGN_REGEX_SPACE);
221
+ if (compareRegex) {
222
+ const compareResult = getCompare(toRoll, compareRegex);
223
+ resultat = compareResult.compare.value;
224
+ toRoll = compareResult.dice;
225
+ const toCompare = `${toRoll}${compareResult.compare?.sign}${compareResult.compare?.value}`;
226
+ const res = evaluate(toCompare);
227
+ if (typeof res === "boolean") {
228
+ const formule = element.replace("\xB5", `[${diceResult.total}]`);
229
+ const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
230
+ const validSign = res ? "\u2713" : "\u2715";
231
+ const invertedSign = res ? compareResult.compare.sign : inverseSign(compareResult.compare.sign);
232
+ results.push(`${validSign} ${diceAll}: ${formule} = ${evaluate(toRoll)}${invertedSign}${compareResult.compare?.value}`);
233
+ }
234
+ } else {
235
+ resultat = evaluate(toRoll);
236
+ const formule = element.replace("\xB5", `[${diceResult.total}]`);
237
+ const diceAll = element.replace("\xB5", diceResult.dice.replace(COMMENT_REGEX, ""));
238
+ results.push(`\u25C8 ${diceAll}: ${formule} = ${resultat}`);
239
+ }
187
240
  total += resultat;
188
241
  }
189
242
  return {
190
243
  dice: split[0],
191
- result: results.join("\n"),
244
+ result: results.join(";"),
192
245
  comment: comments,
193
246
  compare: diceResult.compare,
194
247
  modifier: diceResult.modifier,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dice.ts","../src/errors.ts","../src/utils.ts","../src/verify_template.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\nimport { DiceRoller } from \"@dice-roller/rpg-dice-roller\";\nimport { evaluate } from \"mathjs\";\n\nimport type { Compare, Modifier, Resultat, Sign } from \".\";\nimport { DiceTypeError } from \"./errors\";\n\nexport const COMMENT_REGEX = /\\s+(#|\\/{2}|\\[|\\/\\*)(.*)/;\nconst SIGN_REGEX = /[><=!]+/;\nconst SIGN_REGEX_SPACE = /[><=!]+(\\S+)/;\n\n/**\n * Parse the string provided and turn it as a readable dice for dice parser\n * @param dice {string}\n */\nexport function roll(dice: string): Resultat | undefined {\n\t//parse dice string\n\tif (!dice.includes(\"d\")) return undefined;\n\tconst compareRegex = dice.match(SIGN_REGEX_SPACE);\n\tlet compare: Compare | undefined;\n\tif (compareRegex) {\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = dice.replace(SIGN_REGEX_SPACE, \"\");\n\t\tconst calc = compareRegex[1];\n\t\tconst sign = calc.match(/[+-\\/\\*\\^]/)?.[0];\n\t\tconst compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];\n\t\tif (sign) {\n\t\t\tconst toCalc = calc.replace(SIGN_REGEX, \"\").replace(/\\s/g, \"\").replace(/;(.*)/, \"\");\n\t\t\tconst total = evaluate(toCalc);\n\t\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\t\tdice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);\n\t\t\tcompare = {\n\t\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\t\tvalue: total,\n\t\t\t};\n\t\t} else\n\t\t\tcompare = {\n\t\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\t\tvalue: Number.parseInt(calc, 10),\n\t\t\t};\n\t}\n\tconst modifier = dice.matchAll(/(\\+|\\-|%|\\/|\\^|\\*|\\*{2})(\\d+)/gi);\n\tlet modificator: Modifier | undefined;\n\tfor (const mod of modifier) {\n\t\t//calculate the modifier if multiple\n\t\tif (modificator) {\n\t\t\tconst sign = modificator.sign;\n\t\t\tlet value = modificator.value;\n\t\t\tif (sign) value = calculator(sign, value, Number.parseInt(mod[2], 10));\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t} else {\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue: Number.parseInt(mod[2], 10),\n\t\t\t};\n\t\t}\n\t}\n\tif (dice.includes(\";\") && dice.includes(\"µ\")) return multipleFunction(dice);\n\n\tif (dice.match(/\\d+?#(.*)/)) {\n\t\tconst diceArray = dice.split(\"#\");\n\t\tconst numberOfDice = Number.parseInt(diceArray[0], 10);\n\t\tconst diceToRoll = diceArray[1].replace(COMMENT_REGEX, \"\");\n\t\tconst commentsMatch = diceArray[1].match(COMMENT_REGEX);\n\t\tconst comments = commentsMatch ? commentsMatch[2] : undefined;\n\t\tconst roller = new DiceRoller();\n\t\t//remove comments if any\n\t\tfor (let i = 0; i < numberOfDice; i++) {\n\t\t\ttry {\n\t\t\t\troller.roll(diceToRoll);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new DiceTypeError(diceToRoll, \"roll\", error);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tdice: diceToRoll,\n\t\t\tresult: roller.output,\n\t\t\tcomment: comments,\n\t\t\tcompare: compare ? compare : undefined,\n\t\t\tmodifier: modificator,\n\t\t\ttotal: roller.total,\n\t\t};\n\t}\n\tconst roller = new DiceRoller();\n\tconst diceWithoutComment = dice.replace(COMMENT_REGEX, \"\");\n\ttry {\n\t\troller.roll(diceWithoutComment);\n\t} catch (error) {\n\t\tthrow new DiceTypeError(diceWithoutComment, \"roll\", error);\n\t}\n\tconst commentMatch = dice.match(COMMENT_REGEX);\n\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\treturn {\n\t\tdice,\n\t\tresult: roller.output,\n\t\tcomment,\n\t\tcompare: compare ? compare : undefined,\n\t\tmodifier: modificator,\n\t\ttotal: roller.total,\n\t};\n}\n/**\n * Evaluate a formula and replace \"^\" by \"**\" if any\n * @param {Sign} sign\n * @param {number} value\n * @param {number} total\n * @returns\n */\nexport function calculator(sign: Sign, value: number, total: number): number {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tif (sign === \"^\") sign = \"**\";\n\treturn evaluate(`${total} ${sign} ${value}`);\n}\n\nexport function multipleFunction(dice: string): Resultat | undefined {\n\tconst results = [];\n\tconst split = dice.split(\";\");\n\tconst diceResult = roll(split[0]);\n\tif (!diceResult || !diceResult.total) return undefined;\n\tresults.push(`${diceResult.result}`);\n\tlet total = diceResult.total;\n\tlet comments = diceResult.comment ?? \"\";\n\tif (!total) return diceResult;\n\tfor (let element of split.slice(1)) {\n\t\t//remove comments & keep it\n\t\tconst commentMatch = element.match(COMMENT_REGEX);\n\t\telement = element.replace(COMMENT_REGEX, \"\");\n\t\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\t\tif (comment) comments += ` ${comment}`;\n\t\tconst toRoll = element.replace(\"µ\", `${diceResult.total}`);\n\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\tconst resultat = evaluate(toRoll);\n\t\tresults.push(`✓ ${diceAll}: ${formule} = ${resultat}`);\n\t\ttotal += resultat;\n\t}\n\n\treturn {\n\t\t\tdice: split[0],\n\t\t\tresult: results.join(\"\\n\"),\n\t\t\tcomment: comments,\n\t\t\tcompare: diceResult.compare,\n\t\t\tmodifier: diceResult.modifier,\n\t\t\ttotal\n\t\t}\n\t\n}\n","export class DiceTypeError extends Error {\n\tpublic readonly dice: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(dice: string, cause?: string, method?: unknown) {\n\t\tsuper(dice);\n\t\tthis.name = \"Invalid_Dice_Type\";\n\t\tthis.dice = dice;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class FormulaError extends Error {\n\tpublic readonly formula: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(formula: string, cause?: string, method?: unknown) {\n\t\tsuper(formula);\n\t\tthis.name = \"Invalid_Formula\";\n\t\tthis.formula = formula;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class MaxGreater extends Error {\n\tpublic readonly name: string;\n\tpublic readonly value: number;\n\tpublic readonly max: number;\n\n\tconstructor(value: number, max: number) {\n\t\tsuper(value.toString());\n\t\tthis.name = \"Max_Greater\";\n\t\tthis.value = value;\n\t\tthis.max = max;\n\t}\n}\n\nexport class EmptyObjectError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Empty_Object\";\n\t}\n}\n\nexport class TooManyDice extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Dice\";\n\t}\n}\n\nexport class TooManyStats extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Stats\";\n\t}\n}\n\nexport class NoStatisticsError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"No_Statistics\";\n\t}\n}\n","import { evaluate } from \"mathjs\";\nimport removeAccents from \"remove-accents\";\nimport { FormulaError } from \"./errors\";\n\n/**\n * Escape regex string\n * @param string {string}\n */\nexport function escapeRegex(string: string) {\n\treturn string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Replace the stat name by their value using stat and after evaluate any formula using `replaceFormulaInDice`\n * @param originalDice {dice}\n * @param stats {[name: string]: number}\n */\nexport function generateStatsDice(\n\toriginalDice: string,\n\tstats?: { [name: string]: number }\n) {\n\tlet dice = originalDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\t//damage field support adding statistic, like : 1d6 + strength\n\t\t//check if the value contains a statistic & calculate if it's okay\n\t\t//the dice will be converted before roll\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (dice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = dice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\treturn replaceFormulaInDice(dice);\n}\n\n/**\n * Replace the {{}} in the dice string and evaluate the interior if any\n * @param dice {string}\n */\nexport function replaceFormulaInDice(dice: string) {\n\tconst formula = /(?<formula>\\{{2}(.+?)\\}{2})/gim;\n\tconst formulaMatch = formula.exec(dice);\n\tif (formulaMatch?.groups?.formula) {\n\t\tconst formula = formulaMatch.groups.formula.replaceAll(\"{{\", \"\").replaceAll(\"}}\", \"\");\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\treturn cleanedDice(dice.replace(formulaMatch.groups.formula, result.toString()));\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(formulaMatch.groups.formula, \"replaceFormulaInDice\", error);\n\t\t}\n\t}\n\treturn cleanedDice(dice);\n}\n\n/**\n * Replace the ++ +- -- by their proper value:\n * - `++` = `+`\n * - `+-` = `-`\n * - `--` = `+`\n * @param dice {string}\n */\nexport function cleanedDice(dice: string) {\n\treturn dice.replaceAll(\"+-\", \"-\").replaceAll(\"--\", \"+\").replaceAll(\"++\", \"+\");\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { evaluate } from \"mathjs\";\nimport { Random } from \"random-js\";\nimport removeAccents from \"remove-accents\";\n\nimport type { Statistic, StatisticalTemplate } from \".\";\nimport { roll } from \"./dice\";\nimport { escapeRegex, replaceFormulaInDice } from \"./utils\";\nimport {\n\tDiceTypeError,\n\tEmptyObjectError,\n\tFormulaError,\n\tMaxGreater,\n\tNoStatisticsError,\n\tTooManyDice,\n\tTooManyStats,\n} from \"./errors\";\n\n/**\n * Verify if the provided dice work with random value\n * @param testDice {string}\n * @param stats {[name: string]: number}\n */\nexport function evalStatsDice(testDice: string, stats?: { [name: string]: number }) {\n\tlet dice = testDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (testDice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = testDice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\tif (!roll(replaceFormulaInDice(dice)))\n\t\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", \"no roll result\");\n\t\treturn testDice;\n\t} catch (error) {\n\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", error);\n\t}\n}\n\n/**\n * Generate a random dice and remove the formula (+ evaluate it)\n * Used for diceDamage only\n * @param value {string}\n * @param template {StatisticalTemplate}\n * @returns\n */\nexport function diceRandomParse(value: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return value;\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tvalue = removeAccents(value);\n\tconst allStats = Object.keys(template.statistics).map((stat) =>\n\t\tremoveAccents(stat).toLowerCase()\n\t);\n\tlet newDice = value;\n\tfor (const stat of allStats) {\n\t\tconst regex = new RegExp(escapeRegex(stat), \"gi\");\n\t\tif (value.match(regex)) {\n\t\t\tlet max: undefined | number = undefined;\n\t\t\tlet min: undefined | number = undefined;\n\t\t\tconst stats = template.statistics?.[stat];\n\t\t\tif (stats) {\n\t\t\t\tmax = template.statistics[removeAccents(stat).toLowerCase()].max;\n\t\t\t\tmin = template.statistics[removeAccents(stat).toLowerCase()].min;\n\t\t\t}\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tnewDice = value.replace(regex, randomStatValue.toString());\n\t\t}\n\t}\n\treturn replaceFormulaInDice(newDice);\n}\n\n/**\n * Same as damageDice but for DiceType\n * @param dice {string}\n * @param template {StatisticalTemplate}\n */\nexport function diceTypeRandomParse(dice: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return dice;\n\tconst firstStatNotCombinaison = Object.keys(template.statistics).find(\n\t\t(stat) => !template.statistics?.[stat].combinaison\n\t);\n\tif (!firstStatNotCombinaison) return dice;\n\tconst stats = template.statistics[firstStatNotCombinaison];\n\tconst { min, max } = stats;\n\tconst total = template.total || 100;\n\tconst randomStatValue = generateRandomStat(total, max, min);\n\treturn replaceFormulaInDice(dice.replace(\"$\", randomStatValue.toString()));\n}\n\n/**\n * Random the combinaison and evaluate it to check if everything is valid\n * @param combinaison {[name: string]: string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalCombinaison(\n\tcombinaison: { [name: string]: string },\n\tstats: { [name: string]: string | number }\n) {\n\tconst newStats: { [name: string]: number } = {};\n\tfor (const [stat, combin] of Object.entries(combinaison)) {\n\t\t//replace the stats in formula\n\t\tlet formula = removeAccents(combin);\n\t\tfor (const [statName, value] of Object.entries(stats)) {\n\t\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\t\tformula = formula.replace(regex, value.toString());\n\t\t}\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\tnewStats[stat] = result;\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(stat, \"evalCombinaison\", error);\n\t\t}\n\t}\n\treturn newStats;\n}\n\n/**\n * Evaluate one selected combinaison\n * @param combinaison {string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalOneCombinaison(\n\tcombinaison: string,\n\tstats: { [name: string]: string | number }\n) {\n\tlet formula = removeAccents(combinaison);\n\tfor (const [statName, value] of Object.entries(stats)) {\n\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\tformula = formula.replace(regex, value.toString());\n\t}\n\ttry {\n\t\treturn evaluate(formula);\n\t} catch (error) {\n\t\tthrow new FormulaError(combinaison, \"evalOneCombinaison\", error);\n\t}\n}\n\n/**\n * Parse the provided JSON and verify each field to check if everything could work when rolling\n * @param {any} template\n * @returns {StatisticalTemplate}\n */\n//biome-ignore lint/suspicious/noExplicitAny: I need to use any to allow any type\nexport function verifyTemplateValue(template: any): StatisticalTemplate {\n\tconst statistiqueTemplate: StatisticalTemplate = {\n\t\tdiceType: \"\",\n\t\tstatistics: {} as Statistic,\n\t};\n\tif (!template.statistics) statistiqueTemplate.statistics = undefined;\n\telse if (template.statistics && Object.keys(template.statistics).length > 0) {\n\t\tif (Object.keys(template.statistics).length > 25) throw new TooManyStats();\n\t\tfor (const [key, value] of Object.entries(template.statistics)) {\n\t\t\tconst dataValue = value as { max?: number; min?: number; combinaison?: string };\n\t\t\tif (dataValue.max && dataValue.min && dataValue.max <= dataValue.min)\n\t\t\t\tthrow new MaxGreater(dataValue.min, dataValue.max);\n\t\t\tif (dataValue.max && dataValue.max <= 0) dataValue.max = undefined;\n\t\t\tif (dataValue.min && dataValue.min <= 0) dataValue.min = undefined;\n\t\t\tlet formula = dataValue.combinaison\n\t\t\t\t? removeAccents(dataValue.combinaison).toLowerCase()\n\t\t\t\t: undefined;\n\t\t\tformula = formula && formula.trim().length > 0 ? formula : undefined;\n\t\t\tif (!statistiqueTemplate.statistics) {\n\t\t\t\tstatistiqueTemplate.statistics = {} as Statistic;\n\t\t\t}\n\t\t\tstatistiqueTemplate.statistics[key] = {\n\t\t\t\tmax: dataValue.max,\n\t\t\t\tmin: dataValue.min,\n\t\t\t\tcombinaison: formula || undefined,\n\t\t\t};\n\t\t}\n\t}\n\tif (template.diceType) {\n\t\ttry {\n\t\t\tstatistiqueTemplate.diceType = template.diceType;\n\t\t\tconst cleanedDice = diceTypeRandomParse(template.diceType, statistiqueTemplate);\n\t\t\tconst rolled = roll(cleanedDice);\n\t\t\tif (!rolled)\n\t\t\t\tthrow new DiceTypeError(cleanedDice, \"verifyTemplateValue\", \"no roll result\");\n\t\t} catch (e) {\n\t\t\tthrow new Error((e as Error).message);\n\t\t}\n\t}\n\n\tif (template.critical && Object.keys(template.critical).length > 0) {\n\t\tstatistiqueTemplate.critical = {\n\t\t\tfailure: template.critical.failure ?? undefined,\n\t\t\tsuccess: template.critical.success ?? undefined,\n\t\t};\n\t}\n\tif (template.total) {\n\t\tif (template.total <= 0) template.total = undefined;\n\t\tstatistiqueTemplate.total = template.total;\n\t}\n\tif (template.charName) statistiqueTemplate.charName = template.charName;\n\tif (template.damage) statistiqueTemplate.damage = template.damage;\n\ttry {\n\t\ttestDiceRegistered(statistiqueTemplate);\n\t\ttestStatCombinaison(statistiqueTemplate);\n\t} catch (error) {\n\t\tthrow new Error((error as Error).message);\n\t}\n\treturn statistiqueTemplate;\n}\n\n/**\n * Test each damage roll from the template.damage\n * @param {StatisticalTemplate} template\n */\nexport function testDiceRegistered(template: StatisticalTemplate) {\n\tif (!template.damage) return;\n\tif (Object.keys(template.damage).length === 0) throw new EmptyObjectError();\n\tif (Object.keys(template.damage).length > 25) throw new TooManyDice();\n\tfor (const [name, dice] of Object.entries(template.damage)) {\n\t\tif (!dice) continue;\n\t\tconst randomDiceParsed = diceRandomParse(dice, template);\n\t\ttry {\n\t\t\tconst rolled = roll(randomDiceParsed);\n\t\t\tif (!rolled) throw new DiceTypeError(name, \"testDiceRegistered\", \"no roll result\");\n\t\t} catch (error) {\n\t\t\tthrow new DiceTypeError(name, \"testDiceRegistered\", error);\n\t\t}\n\t}\n}\n\n/**\n * Test all combinaison with generated random value\n * @param {StatisticalTemplate} template\n */\nexport function testStatCombinaison(template: StatisticalTemplate) {\n\tif (!template.statistics) return;\n\tconst onlyCombinaisonStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(\n\t\t\t([_, value]) => value.combinaison !== undefined\n\t\t)\n\t);\n\tconst allOtherStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(([_, value]) => !value.combinaison)\n\t);\n\tif (Object.keys(onlyCombinaisonStats).length === 0) return;\n\tconst allStats = Object.keys(template.statistics).filter(\n\t\t(stat) => !template.statistics![stat].combinaison\n\t);\n\tif (allStats.length === 0) throw new NoStatisticsError();\n\tconst error = [];\n\tfor (const [stat, value] of Object.entries(onlyCombinaisonStats)) {\n\t\tlet formula = value.combinaison as string;\n\t\tfor (const [other, data] of Object.entries(allOtherStats)) {\n\t\t\tconst { max, min } = data;\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tconst regex = new RegExp(other, \"gi\");\n\t\t\tformula = formula.replace(regex, randomStatValue.toString());\n\t\t}\n\t\ttry {\n\t\t\tevaluate(formula);\n\t\t} catch (e) {\n\t\t\terror.push(stat);\n\t\t}\n\t}\n\tif (error.length > 0) throw new FormulaError(error.join(\", \"), \"testStatCombinaison\");\n\treturn;\n}\n\n/**\n * Generate a random stat based on the template and the statistical min and max\n * @param {number|undefined} total\n * @param {number | undefined} max\n * @param {number | undefined} min\n * @returns\n */\nexport function generateRandomStat(\n\ttotal: number | undefined = 100,\n\tmax?: number,\n\tmin?: number\n) {\n\tlet randomStatValue = total + 1;\n\twhile (randomStatValue >= total) {\n\t\tconst random = new Random();\n\t\tif (max && min) randomStatValue = random.integer(min, max);\n\t\telse if (max) randomStatValue = random.integer(0, max);\n\t\telse if (min) randomStatValue = random.integer(min, total);\n\t\telse randomStatValue = random.integer(0, total);\n\t}\n\treturn randomStatValue;\n}\n"],"mappings":";AACA,SAAS,kBAAkB;AAC3B,SAAS,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,CAAC,SAAS,WAAY,IAAI,EAAE;AAAA,EACvC;AACA,MAAI,SAAS,WAAW;AAAG,UAAM,IAAI,kBAAkB;AACvD,QAAM,QAAQ,CAAC;AACf,aAAW,CAAC,MAAM,KAAK,KAAK,OAAO,QAAQ,oBAAoB,GAAG;AACjE,QAAI,UAAU,MAAM;AACpB,eAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,aAAa,GAAG;AAC1D,YAAM,EAAE,KAAK,IAAI,IAAI;AACrB,YAAM,QAAQ,SAAS,SAAS;AAChC,YAAM,kBAAkB,mBAAmB,OAAO,KAAK,GAAG;AAC1D,YAAM,QAAQ,IAAI,OAAO,OAAO,IAAI;AACpC,gBAAU,QAAQ,QAAQ,OAAO,gBAAgB,SAAS,CAAC;AAAA,IAC5D;AACA,QAAI;AACH,MAAAD,UAAS,OAAO;AAAA,IACjB,SAAS,GAAG;AACX,YAAM,KAAK,IAAI;AAAA,IAChB;AAAA,EACD;AACA,MAAI,MAAM,SAAS;AAAG,UAAM,IAAI,aAAa,MAAM,KAAK,IAAI,GAAG,qBAAqB;AACpF;AACD;AASO,SAAS,mBACf,QAA4B,KAC5B,KACA,KACC;AACD,MAAI,kBAAkB,QAAQ;AAC9B,SAAO,mBAAmB,OAAO;AAChC,UAAM,SAAS,IAAI,OAAO;AAC1B,QAAI,OAAO;AAAK,wBAAkB,OAAO,QAAQ,KAAK,GAAG;AAAA,aAChD;AAAK,wBAAkB,OAAO,QAAQ,GAAG,GAAG;AAAA,aAC5C;AAAK,wBAAkB,OAAO,QAAQ,KAAK,KAAK;AAAA;AACpD,wBAAkB,OAAO,QAAQ,GAAG,KAAK;AAAA,EAC/C;AACA,SAAO;AACR;","names":["roller","evaluate","formula","evaluate","evaluate","removeAccents","removeAccents","evaluate","cleanedDice"]}
1
+ {"version":3,"sources":["../src/dice.ts","../src/errors.ts","../src/utils.ts","../src/verify_template.ts"],"sourcesContent":["/* eslint-disable no-useless-escape */\nimport { DiceRoller } from \"@dice-roller/rpg-dice-roller\";\nimport { evaluate } from \"mathjs\";\n\nimport type { Compare, Modifier, Resultat, Sign } from \".\";\nimport { DiceTypeError } from \"./errors\";\n\nexport const COMMENT_REGEX = /\\s+(#|\\/{2}|\\[|\\/\\*)(.*)/;\nconst SIGN_REGEX = /[><=!]+/;\nconst SIGN_REGEX_SPACE = /[><=!]+(\\S+)/;\n\nfunction getCompare(dice: string, compareRegex: RegExpMatchArray): {dice: string; compare: Compare | undefined} {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tdice = dice.replace(SIGN_REGEX_SPACE, \"\");\n\tlet compare: Compare;\n\tconst calc = compareRegex[1];\n\tconst sign = calc.match(/[+-\\/\\*\\^]/)?.[0];\n\tconst compareSign = compareRegex[0].match(SIGN_REGEX)?.[0];\n\tif (sign) {\n\t\tconst toCalc = calc.replace(SIGN_REGEX, \"\").replace(/\\s/g, \"\").replace(/;(.*)/, \"\");\n\t\tconst total = evaluate(toCalc);\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = dice.replace(SIGN_REGEX_SPACE, `${compareSign}${total}`);\n\t\tcompare = {\n\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\tvalue: total,\n\t\t};\n\t} else\n\t\tcompare = {\n\t\t\tsign: compareSign as \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\",\n\t\t\tvalue: Number.parseInt(calc, 10),\n\t\t};\n\treturn {dice, compare};\n}\n\nfunction getModifier(dice: string) {\n\tconst modifier = dice.matchAll(/(\\+|\\-|%|\\/|\\^|\\*|\\*{2})(\\d+)/gi);\n\tlet modificator: Modifier | undefined;\n\tfor (const mod of modifier) {\n\t\t//calculate the modifier if multiple\n\t\tif (modificator) {\n\t\t\tconst sign = modificator.sign;\n\t\t\tlet value = modificator.value;\n\t\t\tif (sign) value = calculator(sign, value, Number.parseInt(mod[2], 10));\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue,\n\t\t\t};\n\t\t} else {\n\t\t\tmodificator = {\n\t\t\t\tsign: mod[1] as Sign,\n\t\t\t\tvalue: Number.parseInt(mod[2], 10),\n\t\t\t};\n\t\t}\n\t}\n\treturn modificator;\n}\n\n/**\n * Parse the string provided and turn it as a readable dice for dice parser\n * @param dice {string}\n */\nexport function roll(dice: string): Resultat | undefined {\n\t//parse dice string\n\tif (!dice.includes(\"d\")) return undefined;\n\tconst compareRegex = dice.match(SIGN_REGEX_SPACE);\n\tlet compare: Compare | undefined;\n\tif (dice.includes(\";\") && dice.includes(\"µ\")) return multipleFunction(dice);\n\tif (compareRegex) {\n\t\tconst compareResult = getCompare(dice, compareRegex);\n\t\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\t\tdice = compareResult.dice;\n\t\tcompare = compareResult.compare;\n\t}\n\tconst modificator = getModifier(dice);\n\n\tif (dice.match(/\\d+?#(.*)/)) {\n\t\tconst diceArray = dice.split(\"#\");\n\t\tconst numberOfDice = Number.parseInt(diceArray[0], 10);\n\t\tconst diceToRoll = diceArray[1].replace(COMMENT_REGEX, \"\");\n\t\tconst commentsMatch = diceArray[1].match(COMMENT_REGEX);\n\t\tconst comments = commentsMatch ? commentsMatch[2] : undefined;\n\t\tconst roller = new DiceRoller();\n\t\t//remove comments if any\n\t\tfor (let i = 0; i < numberOfDice; i++) {\n\t\t\ttry {\n\t\t\t\troller.roll(diceToRoll);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new DiceTypeError(diceToRoll, \"roll\", error);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tdice: diceToRoll,\n\t\t\tresult: roller.output,\n\t\t\tcomment: comments,\n\t\t\tcompare: compare ? compare : undefined,\n\t\t\tmodifier: modificator,\n\t\t\ttotal: roller.total,\n\t\t};\n\t}\n\tconst roller = new DiceRoller();\n\tconst diceWithoutComment = dice.replace(COMMENT_REGEX, \"\");\n\ttry {\n\t\troller.roll(diceWithoutComment);\n\t} catch (error) {\n\t\tthrow new DiceTypeError(diceWithoutComment, \"roll\", error);\n\t}\n\tconst commentMatch = dice.match(COMMENT_REGEX);\n\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\treturn {\n\t\tdice,\n\t\tresult: roller.output,\n\t\tcomment,\n\t\tcompare: compare ? compare : undefined,\n\t\tmodifier: modificator,\n\t\ttotal: roller.total,\n\t};\n}\n/**\n * Evaluate a formula and replace \"^\" by \"**\" if any\n * @param {Sign} sign\n * @param {number} value\n * @param {number} total\n * @returns\n */\nexport function calculator(sign: Sign, value: number, total: number): number {\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tif (sign === \"^\") sign = \"**\";\n\treturn evaluate(`${total} ${sign} ${value}`);\n}\n\nfunction compareResult(result: number, compare: Compare): boolean {\n\tswitch (compare.sign) {\n\t\tcase \"<\":\n\t\t\treturn result < compare.value;\n\t\tcase \">\":\n\t\t\treturn result > compare.value;\n\t\tcase \"<=\":\n\t\t\treturn result <= compare.value;\n\t\tcase \">=\":\n\t\t\treturn result >= compare.value;\n\t\tcase \"=\":\n\t\t\treturn result === compare.value;\n\t\tcase \"==\":\n\t\t\treturn result === compare.value;\n\t\tcase \"!=\":\n\t\t\treturn result !== compare.value;\n\t}\n}\n\nfunction inverseSign(sign: \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\"): \"<\" | \">\" | \">=\" | \"<=\" | \"=\" | \"!=\" | \"==\" {\n\tswitch (sign) {\n\t\tcase \"<\":\n\t\t\treturn \">\";\n\t\tcase \">\":\n\t\t\treturn \"<\";\n\t\tcase \"<=\":\n\t\t\treturn \">=\";\n\t\tcase \">=\":\n\t\t\treturn \"<=\";\n\t\tcase \"=\":\n\t\t\treturn \"!=\";\n\t\tcase \"==\":\n\t\t\treturn \"!=\";\n\t\tcase \"!=\":\n\t\t\treturn \"==\";\n\t}\n}\n\nexport function multipleFunction(dice: string): Resultat | undefined {\n\tconst results = [];\n\tconst split = dice.split(\";\");\n\tconst diceResult = roll(split[0]);\n\tif (!diceResult || !diceResult.total) return undefined;\n\tresults.push(`${diceResult.result}`);\n\t\n\tlet total = diceResult.total;\n\tlet comments = diceResult.comment ?? \"\";\n\tif (!total) return diceResult;\n\tfor (let element of split.slice(1)) {\n\t\tif (!element.includes(\"µ\")) {\n\t\t\tconst result = roll(element);\n\t\t\tif (!result) continue;\n\t\t\tresults.push(result.result);\n\t\t\tcontinue;\n\t\t}\n\t\t//remove comments & keep it\n\t\tconst commentMatch = element.match(COMMENT_REGEX);\n\t\telement = element.replace(COMMENT_REGEX, \"\");\n\t\tconst comment = commentMatch ? commentMatch[2] : undefined;\n\t\tif (comment) comments += ` ${comment}`;\n\t\tlet toRoll = element.replace(\"µ\", `${diceResult.total}`);\n\t\tlet resultat: number;\n\t\tconst compareRegex = toRoll.match(SIGN_REGEX_SPACE);\n\t\tif (compareRegex) {\n\t\t\tconst compareResult = getCompare(toRoll, compareRegex);\n\t\t\tresultat = compareResult.compare!.value;\n\t\t\ttoRoll = compareResult.dice;\n\t\t\tconst toCompare = `${toRoll}${compareResult.compare?.sign}${compareResult.compare?.value}`;\n\t\t\tconst res = evaluate(toCompare);\n\t\t\tif (typeof res === \"boolean\") {\n\t\t\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\t\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\t\t\tconst validSign = res ? \"✓\" : \"✕\";\n\t\t\t\tconst invertedSign = res ? compareResult.compare!.sign : inverseSign(compareResult.compare!.sign);\n\t\t\t\tresults.push(`${validSign} ${diceAll}: ${formule} = ${evaluate(toRoll)}${invertedSign}${compareResult.compare?.value}`);\n\t\t\t}\n\t\t} else {\n\t\t\tresultat = evaluate(toRoll);\n\t\t\tconst formule = element.replace(\"µ\", `[${diceResult.total}]`);\n\t\t\tconst diceAll = element.replace(\"µ\", diceResult.dice.replace(COMMENT_REGEX, \"\"));\n\t\t\tresults.push(`◈ ${diceAll}: ${formule} = ${resultat}`);\n\t\t}\n\t\ttotal += resultat;\n\t}\n\n\treturn {\n\t\t\tdice: split[0],\n\t\t\tresult: results.join(\";\"),\n\t\t\tcomment: comments,\n\t\t\tcompare: diceResult.compare,\n\t\t\tmodifier: diceResult.modifier,\n\t\t\ttotal\n\t\t}\n\t\n}\n","export class DiceTypeError extends Error {\n\tpublic readonly dice: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(dice: string, cause?: string, method?: unknown) {\n\t\tsuper(dice);\n\t\tthis.name = \"Invalid_Dice_Type\";\n\t\tthis.dice = dice;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class FormulaError extends Error {\n\tpublic readonly formula: string;\n\tpublic readonly cause: string | undefined;\n\tpublic readonly method: unknown;\n\n\tconstructor(formula: string, cause?: string, method?: unknown) {\n\t\tsuper(formula);\n\t\tthis.name = \"Invalid_Formula\";\n\t\tthis.formula = formula;\n\t\tthis.cause = cause;\n\t\tthis.method = method;\n\t}\n}\n\nexport class MaxGreater extends Error {\n\tpublic readonly name: string;\n\tpublic readonly value: number;\n\tpublic readonly max: number;\n\n\tconstructor(value: number, max: number) {\n\t\tsuper(value.toString());\n\t\tthis.name = \"Max_Greater\";\n\t\tthis.value = value;\n\t\tthis.max = max;\n\t}\n}\n\nexport class EmptyObjectError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Empty_Object\";\n\t}\n}\n\nexport class TooManyDice extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Dice\";\n\t}\n}\n\nexport class TooManyStats extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"Too_Many_Stats\";\n\t}\n}\n\nexport class NoStatisticsError extends Error {\n\tpublic readonly name: string;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.name = \"No_Statistics\";\n\t}\n}\n","import { evaluate } from \"mathjs\";\nimport removeAccents from \"remove-accents\";\nimport { FormulaError } from \"./errors\";\n\n/**\n * Escape regex string\n * @param string {string}\n */\nexport function escapeRegex(string: string) {\n\treturn string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Replace the stat name by their value using stat and after evaluate any formula using `replaceFormulaInDice`\n * @param originalDice {dice}\n * @param stats {[name: string]: number}\n */\nexport function generateStatsDice(\n\toriginalDice: string,\n\tstats?: { [name: string]: number }\n) {\n\tlet dice = originalDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\t//damage field support adding statistic, like : 1d6 + strength\n\t\t//check if the value contains a statistic & calculate if it's okay\n\t\t//the dice will be converted before roll\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (dice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = dice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\treturn replaceFormulaInDice(dice);\n}\n\n/**\n * Replace the {{}} in the dice string and evaluate the interior if any\n * @param dice {string}\n */\nexport function replaceFormulaInDice(dice: string) {\n\tconst formula = /(?<formula>\\{{2}(.+?)\\}{2})/gim;\n\tconst formulaMatch = formula.exec(dice);\n\tif (formulaMatch?.groups?.formula) {\n\t\tconst formula = formulaMatch.groups.formula.replaceAll(\"{{\", \"\").replaceAll(\"}}\", \"\");\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\treturn cleanedDice(dice.replace(formulaMatch.groups.formula, result.toString()));\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(formulaMatch.groups.formula, \"replaceFormulaInDice\", error);\n\t\t}\n\t}\n\treturn cleanedDice(dice);\n}\n\n/**\n * Replace the ++ +- -- by their proper value:\n * - `++` = `+`\n * - `+-` = `-`\n * - `--` = `+`\n * @param dice {string}\n */\nexport function cleanedDice(dice: string) {\n\treturn dice.replaceAll(\"+-\", \"-\").replaceAll(\"--\", \"+\").replaceAll(\"++\", \"+\");\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { evaluate } from \"mathjs\";\nimport { Random } from \"random-js\";\nimport removeAccents from \"remove-accents\";\n\nimport type { Statistic, StatisticalTemplate } from \".\";\nimport { roll } from \"./dice\";\nimport { escapeRegex, replaceFormulaInDice } from \"./utils\";\nimport {\n\tDiceTypeError,\n\tEmptyObjectError,\n\tFormulaError,\n\tMaxGreater,\n\tNoStatisticsError,\n\tTooManyDice,\n\tTooManyStats,\n} from \"./errors\";\n\n/**\n * Verify if the provided dice work with random value\n * @param testDice {string}\n * @param stats {[name: string]: number}\n */\nexport function evalStatsDice(testDice: string, stats?: { [name: string]: number }) {\n\tlet dice = testDice;\n\tif (stats && Object.keys(stats).length > 0) {\n\t\tconst allStats = Object.keys(stats);\n\t\tfor (const stat of allStats) {\n\t\t\tconst regex = new RegExp(escapeRegex(removeAccents(stat)), \"gi\");\n\t\t\tif (testDice.match(regex)) {\n\t\t\t\tconst statValue = stats[stat];\n\t\t\t\tdice = testDice.replace(regex, statValue.toString());\n\t\t\t}\n\t\t}\n\t}\n\ttry {\n\t\tif (!roll(replaceFormulaInDice(dice)))\n\t\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", \"no roll result\");\n\t\treturn testDice;\n\t} catch (error) {\n\t\tthrow new DiceTypeError(dice, \"evalStatsDice\", error);\n\t}\n}\n\n/**\n * Generate a random dice and remove the formula (+ evaluate it)\n * Used for diceDamage only\n * @param value {string}\n * @param template {StatisticalTemplate}\n * @returns\n */\nexport function diceRandomParse(value: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return value;\n\t//biome-ignore lint/style/noParameterAssign: I need to assign the value to the variable\n\tvalue = removeAccents(value);\n\tconst allStats = Object.keys(template.statistics).map((stat) =>\n\t\tremoveAccents(stat).toLowerCase()\n\t);\n\tlet newDice = value;\n\tfor (const stat of allStats) {\n\t\tconst regex = new RegExp(escapeRegex(stat), \"gi\");\n\t\tif (value.match(regex)) {\n\t\t\tlet max: undefined | number = undefined;\n\t\t\tlet min: undefined | number = undefined;\n\t\t\tconst stats = template.statistics?.[stat];\n\t\t\tif (stats) {\n\t\t\t\tmax = template.statistics[removeAccents(stat).toLowerCase()].max;\n\t\t\t\tmin = template.statistics[removeAccents(stat).toLowerCase()].min;\n\t\t\t}\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tnewDice = value.replace(regex, randomStatValue.toString());\n\t\t}\n\t}\n\treturn replaceFormulaInDice(newDice);\n}\n\n/**\n * Same as damageDice but for DiceType\n * @param dice {string}\n * @param template {StatisticalTemplate}\n */\nexport function diceTypeRandomParse(dice: string, template: StatisticalTemplate) {\n\tif (!template.statistics) return dice;\n\tconst firstStatNotCombinaison = Object.keys(template.statistics).find(\n\t\t(stat) => !template.statistics?.[stat].combinaison\n\t);\n\tif (!firstStatNotCombinaison) return dice;\n\tconst stats = template.statistics[firstStatNotCombinaison];\n\tconst { min, max } = stats;\n\tconst total = template.total || 100;\n\tconst randomStatValue = generateRandomStat(total, max, min);\n\treturn replaceFormulaInDice(dice.replace(\"$\", randomStatValue.toString()));\n}\n\n/**\n * Random the combinaison and evaluate it to check if everything is valid\n * @param combinaison {[name: string]: string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalCombinaison(\n\tcombinaison: { [name: string]: string },\n\tstats: { [name: string]: string | number }\n) {\n\tconst newStats: { [name: string]: number } = {};\n\tfor (const [stat, combin] of Object.entries(combinaison)) {\n\t\t//replace the stats in formula\n\t\tlet formula = removeAccents(combin);\n\t\tfor (const [statName, value] of Object.entries(stats)) {\n\t\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\t\tformula = formula.replace(regex, value.toString());\n\t\t}\n\t\ttry {\n\t\t\tconst result = evaluate(formula);\n\t\t\tnewStats[stat] = result;\n\t\t} catch (error) {\n\t\t\tthrow new FormulaError(stat, \"evalCombinaison\", error);\n\t\t}\n\t}\n\treturn newStats;\n}\n\n/**\n * Evaluate one selected combinaison\n * @param combinaison {string}\n * @param stats {[name: string]: string|number}\n */\nexport function evalOneCombinaison(\n\tcombinaison: string,\n\tstats: { [name: string]: string | number }\n) {\n\tlet formula = removeAccents(combinaison);\n\tfor (const [statName, value] of Object.entries(stats)) {\n\t\tconst regex = new RegExp(removeAccents(statName), \"gi\");\n\t\tformula = formula.replace(regex, value.toString());\n\t}\n\ttry {\n\t\treturn evaluate(formula);\n\t} catch (error) {\n\t\tthrow new FormulaError(combinaison, \"evalOneCombinaison\", error);\n\t}\n}\n\n/**\n * Parse the provided JSON and verify each field to check if everything could work when rolling\n * @param {any} template\n * @returns {StatisticalTemplate}\n */\n//biome-ignore lint/suspicious/noExplicitAny: I need to use any to allow any type\nexport function verifyTemplateValue(template: any): StatisticalTemplate {\n\tconst statistiqueTemplate: StatisticalTemplate = {\n\t\tdiceType: \"\",\n\t\tstatistics: {} as Statistic,\n\t};\n\tif (!template.statistics) statistiqueTemplate.statistics = undefined;\n\telse if (template.statistics && Object.keys(template.statistics).length > 0) {\n\t\tif (Object.keys(template.statistics).length > 25) throw new TooManyStats();\n\t\tfor (const [key, value] of Object.entries(template.statistics)) {\n\t\t\tconst dataValue = value as { max?: number; min?: number; combinaison?: string };\n\t\t\tif (dataValue.max && dataValue.min && dataValue.max <= dataValue.min)\n\t\t\t\tthrow new MaxGreater(dataValue.min, dataValue.max);\n\t\t\tif (dataValue.max && dataValue.max <= 0) dataValue.max = undefined;\n\t\t\tif (dataValue.min && dataValue.min <= 0) dataValue.min = undefined;\n\t\t\tlet formula = dataValue.combinaison\n\t\t\t\t? removeAccents(dataValue.combinaison).toLowerCase()\n\t\t\t\t: undefined;\n\t\t\tformula = formula && formula.trim().length > 0 ? formula : undefined;\n\t\t\tif (!statistiqueTemplate.statistics) {\n\t\t\t\tstatistiqueTemplate.statistics = {} as Statistic;\n\t\t\t}\n\t\t\tstatistiqueTemplate.statistics[key] = {\n\t\t\t\tmax: dataValue.max,\n\t\t\t\tmin: dataValue.min,\n\t\t\t\tcombinaison: formula || undefined,\n\t\t\t};\n\t\t}\n\t}\n\tif (template.diceType) {\n\t\ttry {\n\t\t\tstatistiqueTemplate.diceType = template.diceType;\n\t\t\tconst cleanedDice = diceTypeRandomParse(template.diceType, statistiqueTemplate);\n\t\t\tconst rolled = roll(cleanedDice);\n\t\t\tif (!rolled)\n\t\t\t\tthrow new DiceTypeError(cleanedDice, \"verifyTemplateValue\", \"no roll result\");\n\t\t} catch (e) {\n\t\t\tthrow new Error((e as Error).message);\n\t\t}\n\t}\n\n\tif (template.critical && Object.keys(template.critical).length > 0) {\n\t\tstatistiqueTemplate.critical = {\n\t\t\tfailure: template.critical.failure ?? undefined,\n\t\t\tsuccess: template.critical.success ?? undefined,\n\t\t};\n\t}\n\tif (template.total) {\n\t\tif (template.total <= 0) template.total = undefined;\n\t\tstatistiqueTemplate.total = template.total;\n\t}\n\tif (template.charName) statistiqueTemplate.charName = template.charName;\n\tif (template.damage) statistiqueTemplate.damage = template.damage;\n\ttry {\n\t\ttestDiceRegistered(statistiqueTemplate);\n\t\ttestStatCombinaison(statistiqueTemplate);\n\t} catch (error) {\n\t\tthrow new Error((error as Error).message);\n\t}\n\treturn statistiqueTemplate;\n}\n\n/**\n * Test each damage roll from the template.damage\n * @param {StatisticalTemplate} template\n */\nexport function testDiceRegistered(template: StatisticalTemplate) {\n\tif (!template.damage) return;\n\tif (Object.keys(template.damage).length === 0) throw new EmptyObjectError();\n\tif (Object.keys(template.damage).length > 25) throw new TooManyDice();\n\tfor (const [name, dice] of Object.entries(template.damage)) {\n\t\tif (!dice) continue;\n\t\tconst randomDiceParsed = diceRandomParse(dice, template);\n\t\ttry {\n\t\t\tconst rolled = roll(randomDiceParsed);\n\t\t\tif (!rolled) throw new DiceTypeError(name, \"testDiceRegistered\", \"no roll result\");\n\t\t} catch (error) {\n\t\t\tthrow new DiceTypeError(name, \"testDiceRegistered\", error);\n\t\t}\n\t}\n}\n\n/**\n * Test all combinaison with generated random value\n * @param {StatisticalTemplate} template\n */\nexport function testStatCombinaison(template: StatisticalTemplate) {\n\tif (!template.statistics) return;\n\tconst onlyCombinaisonStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(\n\t\t\t([_, value]) => value.combinaison !== undefined\n\t\t)\n\t);\n\tconst allOtherStats = Object.fromEntries(\n\t\tObject.entries(template.statistics).filter(([_, value]) => !value.combinaison)\n\t);\n\tif (Object.keys(onlyCombinaisonStats).length === 0) return;\n\tconst allStats = Object.keys(template.statistics).filter(\n\t\t(stat) => !template.statistics![stat].combinaison\n\t);\n\tif (allStats.length === 0) throw new NoStatisticsError();\n\tconst error = [];\n\tfor (const [stat, value] of Object.entries(onlyCombinaisonStats)) {\n\t\tlet formula = value.combinaison as string;\n\t\tfor (const [other, data] of Object.entries(allOtherStats)) {\n\t\t\tconst { max, min } = data;\n\t\t\tconst total = template.total || 100;\n\t\t\tconst randomStatValue = generateRandomStat(total, max, min);\n\t\t\tconst regex = new RegExp(other, \"gi\");\n\t\t\tformula = formula.replace(regex, randomStatValue.toString());\n\t\t}\n\t\ttry {\n\t\t\tevaluate(formula);\n\t\t} catch (e) {\n\t\t\terror.push(stat);\n\t\t}\n\t}\n\tif (error.length > 0) throw new FormulaError(error.join(\", \"), \"testStatCombinaison\");\n\treturn;\n}\n\n/**\n * Generate a random stat based on the template and the statistical min and max\n * @param {number|undefined} total\n * @param {number | undefined} max\n * @param {number | undefined} min\n * @returns\n */\nexport function generateRandomStat(\n\ttotal: number | undefined = 100,\n\tmax?: number,\n\tmin?: number\n) {\n\tlet randomStatValue = total + 1;\n\twhile (randomStatValue >= total) {\n\t\tconst random = new Random();\n\t\tif (max && min) randomStatValue = random.integer(min, max);\n\t\telse if (max) randomStatValue = random.integer(0, max);\n\t\telse if (min) randomStatValue = random.integer(min, total);\n\t\telse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AACR;","names":["roller","evaluate","formula","evaluate","evaluate","removeAccents","removeAccents","evaluate","cleanedDice"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dicelette/core",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "description": "Core library for the Dicelette Discord bot",
5
5
  "repository": {
6
6
  "type": "git",