Création de tableaux d'entiers
ajout d'une méthode propre pour construire un tableau d'entiers consécutifs
This commit is contained in:
parent
5fd3a43b2a
commit
42ed5da2d4
@ -119,6 +119,17 @@ export class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns an array of incremental integers (including from / excluding to).
|
||||
* if max<min, the array is decrementing integers
|
||||
*/
|
||||
static intArray(from, to) {
|
||||
if (from > 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)];
|
||||
}
|
||||
|
@ -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 } })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user