Extraction calcul chances

This commit is contained in:
Vincent Vandemeulebrouck 2021-04-26 23:45:43 +02:00
parent ccb9cd73f4
commit a68aa29b53

View File

@ -165,7 +165,8 @@ export class RdDResolutionTable {
if (difficulte < -10) {
return duplicate(levelDown.find(levelData => levelData.level == difficulte));
}
return duplicate(RdDResolutionTable.resolutionTable[caracValue][difficulte + 10]);
const chances = RdDResolutionTable.resolutionTable[caracValue][difficulte + 10];
return chances ? duplicate(chances) : RdDResolutionTable._computeCell(difficulte, RdDResolutionTable.computeChances(caracValue, difficulte));
}
/* -------------------------------------------- */
@ -224,16 +225,26 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static _computeRow(caracValue) {
let dataRow = [
this._computeCell(-10, Math.max(Math.floor(caracValue / 4), 1)),
this._computeCell(-9, Math.max(Math.floor(caracValue / 2), 1))
]
for (var diff = -8; diff <= 22; diff++) {
dataRow[diff + 10] = this._computeCell(diff, Math.max(Math.floor(caracValue * (diff + 10) / 2), 1));
let dataRow = [];
for (var diff = -10; diff <= 22; diff++) {
dataRow[diff + 10] = this._computeCell(diff, RdDResolutionTable._computePercentage(caracValue, diff));
}
return dataRow;
}
static _computePercentage(caracValue, diff) {
if (diff <-10) {
return 1;
}
if (diff == -10){
return Math.max(Math.floor(caracValue / 4), 1);
}
if (diff == -9) {
return Math.max(Math.floor(caracValue / 2), 1)
}
return Math.max(Math.floor(caracValue * (diff + 10) / 2), 1);
}
/* -------------------------------------------- */
static _computeCell(niveau, percentage) {
return {