diff --git a/module/misc.js b/module/misc.js index e9f03f9e..71ee51d5 100644 --- a/module/misc.js +++ b/module/misc.js @@ -119,6 +119,17 @@ export class Misc { } } + /** + * @returns an array of incremental integers (including from / excluding to). + * if max to) { + return Array.from(Array(from - to).keys()).map(i => from - i) + } + return Array.from(Array(to - from).keys()).map(i => from + i) + } + static distinct(array) { return [...new Set(array)]; } diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 6a576340..4eb6ce2e 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -190,12 +190,8 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ getJoursSuivants(count) { - let jours = []; - let indexDate = this.timestamp.indexDate; - for (let i = 0; i < count; i++, indexDate++) { - jours[i] = { label: RdDTimestamp.formatIndexDate(indexDate), index: indexDate }; - } - return jours; + return Misc.intArray(this.timestamp.indexDate, this.timestamp.indexDate + count) + .map(i => { return { label: RdDTimestamp.formatIndexDate(i), index: i } }) } /* -------------------------------------------- */ diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index b5467845..46700826 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -283,12 +283,9 @@ export class RdDResolutionTable { carac: carac, difficulte: level, min: minLevel, - rows: RdDResolutionTable.incrementalArray(minCarac, maxCarac), - cols: RdDResolutionTable.incrementalArray(minLevel, maxLevel) + rows: Misc.intArray(minCarac, maxCarac+1), + cols: Misc.intArray(minLevel, maxLevel+1) }); } - static incrementalArray(min, max) { - return Array.from(Array(max-min+1).keys()).map(i=>i+min) - } } \ No newline at end of file diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 3b186b1d..3eab79ac 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -19,9 +19,9 @@ import { RdDRaretes } from "./item/raretes.js"; /* -------------------------------------------- */ // This table starts at 0 -> niveau -10 const carac_array = ["taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; -const difficultesLibres = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]; -const ajustementsConditions = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; -const ajustementsEncaissement = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25]; +const difficultesLibres = Misc.intArray(0, -11); +const ajustementsConditions = Misc.intArray(-10, 11); +const ajustementsEncaissement = Misc.intArray(-10, 26); /* -------------------------------------------- */ function _buildAllSegmentsFatigue(max) {