Correction choix carac compétence

Distinction entre "carac" qui représente la liste des
caractéristiques et "caracValue, la valeur selectionnée
This commit is contained in:
Vincent Vandemeulebrouck 2020-11-25 00:46:11 +01:00
parent 544ad7982d
commit 5d04063579
3 changed files with 18 additions and 18 deletions

View File

@ -127,7 +127,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async performRoll(rollData) {
let rolled = await RdDResolutionTable.roll(rollData.carac, rollData.finalLevel);
let rolled = await RdDResolutionTable.roll(rollData.caracValue, rollData.finalLevel);
//rolled.isPart = true; // Pour tester le particulières
rollData.rolled = rolled; // garder le résultat
console.log("performRoll", rollData, rolled)
@ -973,7 +973,7 @@ export class RdDActor extends Actor {
{
let carac;
if ( caracName == "reveActuel") { // Fake carac for Reve Actuel
carac = {type: "number",
carac = {type: "number",
value: this.getReveActuel(),
label: "Rêve Actuel"
}

View File

@ -61,8 +61,8 @@ export class RdDResolutionTable {
/* -------------------------------------------- */
static build() {
let table = []
for (var carac = 0; carac <= 30; carac++) {
table[carac] = this._computeRow(carac);
for (var caracValue = 0; caracValue <= 60; caracValue++) {
table[caracValue] = this._computeRow(caracValue);
}
return table;
}
@ -78,18 +78,18 @@ export class RdDResolutionTable {
static explain(rolled) {
let message = "<br>Jet : <strong>" + rolled.roll + "</strong> sur " + rolled.score + "%";
if (rolled.carac != null && rolled.finalLevel!= null) {
message += " (" + rolled.carac + " à " + Misc.toSignedString(rolled.finalLevel) + ")";
if (rolled.caracValue != null && rolled.finalLevel!= null) {
message += " (" + rolled.caracValue + " à " + Misc.toSignedString(rolled.finalLevel) + ")";
}
return message;
}
/* -------------------------------------------- */
static async roll(carac, finalLevel) {
let chances = this.computeChances(carac, finalLevel);
static async roll(caracValue, finalLevel) {
let chances = this.computeChances(caracValue, finalLevel);
chances.showDice = true;
let rolled = await this.rollChances(chances);
rolled.carac = carac;
rolled.caracValue = caracValue;
rolled.finalLevel = finalLevel;
return rolled;
}
@ -105,14 +105,14 @@ export class RdDResolutionTable {
}
/* -------------------------------------------- */
static computeChances(carac, difficulte) {
static computeChances(caracValue, difficulte) {
if (difficulte < -16) {
return duplicate(levelImpossible);
}
if (difficulte < -10) {
return duplicate(levelDown.find(levelData => levelData.level == difficulte));
}
return duplicate(this.resolutionTable[carac][difficulte + 10]);
return duplicate(this.resolutionTable[caracValue][difficulte + 10]);
}
/* -------------------------------------------- */
@ -142,13 +142,13 @@ export class RdDResolutionTable {
}
/* -------------------------------------------- */
static _computeRow(carac) {
static _computeRow(caracValue) {
let dataRow = [
this._computeCell(-10, Math.max(Math.floor(carac / 4), 1)),
this._computeCell(-9, Math.max(Math.floor(carac / 2), 1))
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(carac * (diff + 10) / 2), 1));
dataRow[diff + 10] = this._computeCell(diff, Math.max(Math.floor(caracValue * (diff + 10) / 2), 1));
}
return dataRow;
}
@ -205,8 +205,8 @@ export class RdDResolutionTable {
let table = $("<table class='table-resolution'/>")
.append(this._buildHTMLHeader(this.resolutionTable[0], minLevel, maxLevel));
for (var carac = minCarac; carac <= maxCarac; carac++) {
table.append(this._buildHTMLRow(this.resolutionTable[carac], carac, caracValue, levelValue, minLevel, maxLevel));
for (var caracValue = minCarac; caracValue <= maxCarac; caracValue++) {
table.append(this._buildHTMLRow(this.resolutionTable[caracValue], caracValue, caracValue, levelValue, minLevel, maxLevel));
}
return table;
}

View File

@ -67,7 +67,7 @@ export class RdDRollDialog extends Dialog {
let rollLevel = RdDRollDialog._computeFinalLevel(rollData);
rollData.finalLevel = rollLevel;
rollData.carac = rollData.selectedCarac.value
rollData.caracValue = caracValue
// Sort management
if ( rollData.selectedSort ) {