Merge branch 'working' into 'master'
Refactoring See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!9
This commit is contained in:
commit
fb52e394e7
@ -15,6 +15,7 @@ import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
|
|||||||
import { RdDActorHumanoideSheet } from "./actor-humanoide-sheet.js";
|
import { RdDActorHumanoideSheet } from "./actor-humanoide-sheet.js";
|
||||||
import { RdDUtility } from "./rdd-utility.js";
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
import { RdDCalendrier } from "./rdd-calendrier.js";
|
import { RdDCalendrier } from "./rdd-calendrier.js";
|
||||||
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
@ -112,12 +113,12 @@ Hooks.once("init", async function() {
|
|||||||
|
|
||||||
// Define custom Entity classes
|
// Define custom Entity classes
|
||||||
CONFIG.Actor.entityClass = RdDActor;
|
CONFIG.Actor.entityClass = RdDActor;
|
||||||
CONFIG.RDD = {}
|
CONFIG.RDD = {
|
||||||
CONFIG.RDD.resolutionTable = RdDUtility.buildResolutionTable();
|
resolutionTable : RdDResolutionTable.resolutionTable,
|
||||||
CONFIG.RDD.level_category = RdDUtility.getLevelCategory();
|
level_category : RdDUtility.getLevelCategory(),
|
||||||
CONFIG.RDD.carac_array = RdDUtility.getCaracArray();
|
carac_array : RdDUtility.getCaracArray(),
|
||||||
CONFIG.RDD.bonusmalus = RdDUtility.getBonusMalus();
|
bonusmalus : RdDUtility.getBonusMalus()
|
||||||
game.data.RdDUtility = RdDUtility;
|
}
|
||||||
|
|
||||||
// Register sheet application classes
|
// Register sheet application classes
|
||||||
Actors.unregisterSheet("core", ActorSheet);
|
Actors.unregisterSheet("core", ActorSheet);
|
||||||
|
99
module/rdd-resolution-table.js
Normal file
99
module/rdd-resolution-table.js
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
|
||||||
|
export class RdDResolutionTable {
|
||||||
|
static resolutionTable = this.build()
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static build() {
|
||||||
|
let table = []
|
||||||
|
for (var carac = 0; carac <= 30; carac++) {
|
||||||
|
table[carac] = this._computeRow(carac);
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static _computeRow(carac) {
|
||||||
|
let dataRow = [
|
||||||
|
this._computeScore(-10, Math.max(Math.floor(carac / 4), 1)),
|
||||||
|
this._computeScore(-9, Math.max(Math.floor(carac / 2), 1))
|
||||||
|
]
|
||||||
|
for (var diff = -8; diff <= 22; diff++) {
|
||||||
|
dataRow[diff + 10] = this._computeScore(diff, Math.max(Math.floor(carac * (diff + 10) / 2), 1));
|
||||||
|
}
|
||||||
|
return dataRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _computeScore(diff, score) {
|
||||||
|
return {
|
||||||
|
niveau: diff,
|
||||||
|
score: score,
|
||||||
|
sign: this._reussiteSignificative(score),
|
||||||
|
part: this._reussitePart(score),
|
||||||
|
epart: this._echecParticulier(score),
|
||||||
|
etotal: this._echecTotal(score)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static _reussiteSignificative(score) {
|
||||||
|
return Math.floor(score / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _reussitePart(score) {
|
||||||
|
return Math.ceil(score / 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static _echecParticulier(score) {
|
||||||
|
return Math.ceil(score / 5) + 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _echecTotal(score) {
|
||||||
|
return Math.ceil(score / 10) + 91;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static buildHTMLTable(caracValue, levelValue, minCarac = 1, maxCarac = 21, minLevel = -10, maxLevel = 11) {
|
||||||
|
return this._buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static _buildHTMLTable(caracValue, levelValue, minCarac, maxCarac, minLevel, maxLevel) {
|
||||||
|
minCarac = Math.max(minCarac, 1);
|
||||||
|
maxCarac = Math.min(maxCarac, 30);
|
||||||
|
minLevel = Math.max(minLevel, -10);
|
||||||
|
maxLevel = Math.min(maxLevel, 22);
|
||||||
|
|
||||||
|
var 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));
|
||||||
|
}
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _buildHTMLHeader(dataRow, minLevel, maxLevel) {
|
||||||
|
var tr = $("<tr/>");
|
||||||
|
for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) {
|
||||||
|
const niveau = dataRow[difficulte + 10].niveau;
|
||||||
|
const txt = (niveau > 0 ? "+" : "") + niveau;
|
||||||
|
tr.append($("<th class='table-resolution-level'/>").text(txt));
|
||||||
|
}
|
||||||
|
return tr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static _buildHTMLRow(dataRow, rowIndex, caracValue, levelValue, minLevel, maxLevel) {
|
||||||
|
var tr = $("<tr/>");
|
||||||
|
for (var difficulte = minLevel; difficulte <= maxLevel; difficulte++) {
|
||||||
|
var td = $("<td/>");
|
||||||
|
let score = dataRow[difficulte + 10].score;
|
||||||
|
if (rowIndex == caracValue && levelValue == difficulte) {
|
||||||
|
td.addClass('table-resolution-target');
|
||||||
|
} else if (difficulte == -8) {
|
||||||
|
td.addClass('table-resolution-carac');
|
||||||
|
}
|
||||||
|
tr.append(td.text(score));
|
||||||
|
}
|
||||||
|
return tr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,59 +1,57 @@
|
|||||||
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
|
import { RdDUtility } from "./rdd-utility.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extend the base Dialog entity by defining a custom window to perform roll.
|
* Extend the base Dialog entity by defining a custom window to perform roll.
|
||||||
* @extends {Dialog}
|
* @extends {Dialog}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export class RdDRollDialog extends Dialog {
|
export class RdDRollDialog extends Dialog {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
constructor(mode, html, rollData, actor) {
|
constructor(mode, html, rollData, actor) {
|
||||||
let myButtons = { rollButton: {
|
|
||||||
label: "Lancer",
|
let myButtons
|
||||||
callback: html => this.performRollSort(html, false)
|
|
||||||
} };
|
|
||||||
if (mode == "sort") {
|
if (mode == "sort") {
|
||||||
myButtons['reserveButton'] = { label: "Mettre en reserve",
|
myButtons = {
|
||||||
callback: html => this.performRollSort(html, true)
|
rollButton: { label: "Lancer le sort", callback: html => this.performRollSort(html, false) },
|
||||||
|
reserveButton: { label: "Mettre en reserve", callback: html => this.performRollSort(html, true) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
myButtons = {
|
||||||
|
rollButton: { label: "Lancer", callback: html => this.actor.performRoll(this.rollData) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Common conf
|
// Common conf
|
||||||
let dialogConf = {
|
let dialogConf = { content: html, title: "Test", buttons: myButtons, default: "rollButton" }
|
||||||
content: html,
|
let dialogOptions = { classes: ["rdddialog"], width: 600, height: 400 }
|
||||||
buttons: myButtons,
|
|
||||||
default: "rollButton"
|
|
||||||
}
|
|
||||||
let dialogOptions = { classes: [ "rdddialog"] }
|
|
||||||
|
|
||||||
// Select proper roll dialog template and stuff
|
// Select proper roll dialog template and stuff
|
||||||
if (mode == "competence" ) {
|
if (mode == "competence") {
|
||||||
dialogConf.title = "Test de compétence",
|
dialogConf.title = "Test de compétence"
|
||||||
dialogOptions.width = 600;
|
dialogConf.height = 400
|
||||||
dialogOptions.height = 360;
|
|
||||||
} else if (mode == "arme") {
|
} else if (mode == "arme") {
|
||||||
dialogConf.title = "Test de combat/arme",
|
dialogConf.title = "Test de combat/arme"
|
||||||
dialogOptions.width = 600;
|
dialogConf.height = 430
|
||||||
dialogOptions.height = 360;
|
|
||||||
} else if (mode == "carac") {
|
} else if (mode == "carac") {
|
||||||
dialogConf.title = "Test de caractéristique",
|
dialogConf.title = "Test de caractéristique"
|
||||||
dialogOptions.width = 600;
|
dialogOptions.height = 350
|
||||||
dialogOptions.height = 320;
|
|
||||||
} else if (mode == "sort") {
|
} else if (mode == "sort") {
|
||||||
dialogConf.title = "Lancer un sort",
|
dialogConf.title = "Lancer un sort"
|
||||||
dialogOptions.width = 600;
|
dialogConf.height = 450
|
||||||
dialogOptions.height = 380;
|
|
||||||
}
|
}
|
||||||
super(dialogConf, dialogOptions);
|
super(dialogConf, dialogOptions)
|
||||||
|
|
||||||
this.mode = mode;
|
this.mode = mode
|
||||||
this.rollData = rollData;
|
this.rollData = rollData
|
||||||
this.actor = actor;
|
this.actor = actor
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
performRollSort (html, isReserve=false) {
|
performRollSort(html, isReserve = false) {
|
||||||
this.rollData.isSortReserve = isReserve;
|
this.rollData.isSortReserve = isReserve;
|
||||||
this.actor.performRoll( this.rollData );
|
this.actor.performRoll(this.rollData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -63,43 +61,30 @@ export class RdDRollDialog extends Dialog {
|
|||||||
// Get the rollData stuff
|
// Get the rollData stuff
|
||||||
var rollData = this.rollData;
|
var rollData = this.rollData;
|
||||||
|
|
||||||
function updateRollResult( rollData ) {
|
function updateRollResult(rollData) {
|
||||||
if ( rollData.competence )
|
let caracValue = parseInt(rollData.selectedCarac.value)
|
||||||
rollData.finalLevel = parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue) + parseInt(rollData.etat);
|
let rollLevel = RdDRollDialog._computeFinalLevel(rollData);
|
||||||
else if ( rollData.draconicList )
|
|
||||||
rollData.finalLevel = parseInt(rollData.selectedDraconic.data.niveau) + parseInt(rollData.selectedSort.data.difficulte) + parseInt(rollData.etat);
|
|
||||||
else
|
|
||||||
rollData.finalLevel = parseInt(rollData.bmValue) + parseInt(rollData.etat);
|
|
||||||
|
|
||||||
rollData.finalLevelStr = (rollData.finalLevel >= 0 ) ? "+" + rollData.finalLevel : rollData.finalLevel;
|
rollData.finalLevel = rollLevel;
|
||||||
$("#roll-param").text( rollData.selectedCarac.value + " / " + rollData.finalLevelStr );
|
rollData.finalLevelStr = (rollLevel > 0 ? "+" : "") + rollLevel;
|
||||||
rollData.rollTarget = game.data.RdDUtility.getResolutionField( rollData.selectedCarac.value, rollData.finalLevel);
|
rollData.rollTarget = RdDUtility.getResolutionField(rollData.selectedCarac.value, rollData.finalLevel);
|
||||||
|
|
||||||
let armeTitle = ( rollData.arme ) ? " ("+rollData.arme.name+") " : ""; // If a weapon is there, add it in the title
|
$("#roll-param").text(rollData.selectedCarac.value + " / " + rollData.finalLevelStr);
|
||||||
let niveauStr = "";
|
$("#compdialogTitle").text(RdDRollDialog._getTitle(rollData));
|
||||||
if ( rollData.competence ) {
|
|
||||||
niveauStr = (rollData.competence.data.niveau >= 0) ? "+" + rollData.competence.data.niveau : rollData.competence.data.niveau;
|
|
||||||
$("#compdialogTitle").text( rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveauStr );
|
|
||||||
} else if ( rollData.draconicList) {
|
|
||||||
$("#compdialogTitle").text( rollData.selectedDraconic.name + " - " + rollData.selectedSort.name );
|
|
||||||
} else {
|
|
||||||
$("#compdialogTitle").text( rollData.selectedCarac.label );
|
|
||||||
}
|
|
||||||
$(".table-resolution").remove();
|
$(".table-resolution").remove();
|
||||||
game.data.RdDUtility.makeHTMLResolutionTable( $("#resolutionTable"), rollData.selectedCarac.value-2, parseInt(rollData.selectedCarac.value) + 2, -10, 11,
|
$("#resolutionTable").append(RdDResolutionTable.buildHTMLTable(caracValue, rollLevel, caracValue - 2, caracValue + 2));
|
||||||
rollData.selectedCarac.value, rollData.finalLevel );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup everything onload
|
// Setup everything onload
|
||||||
$(function() {
|
$(function () {
|
||||||
// Update html, according to data
|
// Update html, according to data
|
||||||
if (rollData.competence) {
|
if (rollData.competence) {
|
||||||
// Set the default carac from the competence item
|
// Set the default carac from the competence item
|
||||||
console.log(rollData.competence.data.defaut_carac, rollData.carac);
|
console.log(rollData.competence.data.defaut_carac, rollData.carac);
|
||||||
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
|
rollData.selectedCarac = rollData.carac[rollData.competence.data.defaut_carac];
|
||||||
$("#carac").val( rollData.competence.data.defaut_carac );
|
$("#carac").val(rollData.competence.data.defaut_carac);
|
||||||
}
|
}
|
||||||
$("#bonusmalus").val( rollData.bmValue );
|
$("#bonusmalus").val(rollData.bmValue);
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -127,6 +112,30 @@ export class RdDRollDialog extends Dialog {
|
|||||||
//console.log("CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue);
|
//console.log("CARAC CLICKED !!!", rollData.selectedCarac, rollData.competence.data.niveau, rollData.bmValue);
|
||||||
updateRollResult(rollData);
|
updateRollResult(rollData);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
static _computeFinalLevel(rollData) {
|
||||||
|
let etat = rollData.etat === undefined ? 0 : parseInt(rollData.etat);
|
||||||
|
if (rollData.competence) {
|
||||||
|
return etat + parseInt(rollData.competence.data.niveau) + parseInt(rollData.bmValue);
|
||||||
|
}
|
||||||
|
if (rollData.draconicList) {
|
||||||
|
return etat + parseInt(rollData.selectedDraconic.data.niveau) + parseInt(rollData.selectedSort.data.difficulte);
|
||||||
|
}
|
||||||
|
return etat + parseInt(rollData.bmValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _getTitle(rollData) {
|
||||||
|
if (rollData.competence) {
|
||||||
|
// If a weapon is there, add it in the title
|
||||||
|
let armeTitle = (rollData.arme) ? " (" + rollData.arme.name + ") " : "";
|
||||||
|
let niveauStr = (rollData.competence.data.niveau > 0 ? "+" : "") + rollData.competence.data.niveau;
|
||||||
|
return rollData.selectedCarac.label + "/" + rollData.competence.name + armeTitle + " " + niveauStr
|
||||||
|
}
|
||||||
|
if (rollData.draconicList) {
|
||||||
|
return rollData.selectedDraconic.name + " - " + rollData.selectedSort.name;
|
||||||
|
}
|
||||||
|
return rollData.selectedCarac.label;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/* Common useful functions shared between objects */
|
/* Common useful functions shared between objects */
|
||||||
|
|
||||||
import { RdDActor } from "./actor.js";
|
|
||||||
import { TMRUtility } from "./tmr-utility.js";
|
import { TMRUtility } from "./tmr-utility.js";
|
||||||
import { RdDRollTables } from "./rdd-rolltables.js";
|
import { RdDRollTables } from "./rdd-rolltables.js";
|
||||||
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||||
|
|
||||||
const level_category = {
|
const level_category = {
|
||||||
"generale": "-4",
|
"generale": "-4",
|
||||||
@ -48,12 +48,12 @@ const specialResults = [ { "part": 0, "epart": 0, "etotal": 0 }, // 0
|
|||||||
{ "part": 19, "epart": 99, "etotal": 100 }, // 81-95
|
{ "part": 19, "epart": 99, "etotal": 100 }, // 81-95
|
||||||
{ "part": 20, "epart": 100, "etotal": 100 } // 96-00
|
{ "part": 20, "epart": 100, "etotal": 100 } // 96-00
|
||||||
];
|
];
|
||||||
const levelDown = [ { "level": -11, "score": 1, "part": 0, "epart": 2, "etotal": 90 },
|
const levelDown = [ { "level": -11, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 90 },
|
||||||
{ "level": -12, "score": 1, "part": 0, "epart": 2, "etotal": 70 },
|
{ "level": -12, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 70 },
|
||||||
{ "level": -13, "score": 1, "part": 0, "epart": 2, "etotal": 50 },
|
{ "level": -13, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 50 },
|
||||||
{ "level": -14, "score": 1, "part": 0, "epart": 2, "etotal": 30 },
|
{ "level": -14, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 30 },
|
||||||
{ "level": -15, "score": 1, "part": 0, "epart": 2, "etotal": 10 },
|
{ "level": -15, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 10 },
|
||||||
{ "level": -16, "score": 1, "part": 0, "epart": 2, "etotal": 2 }
|
{ "level": -16, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 2 }
|
||||||
];
|
];
|
||||||
const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // Dummy filler for the array.
|
const fatigueMatrix = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // Dummy filler for the array.
|
||||||
[2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3 ],
|
[2, 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, 3 ],
|
||||||
@ -102,7 +102,7 @@ const definitionsEncaissement = {
|
|||||||
{ minimum: 20, maximum: undefined, endurance: "100", vie: "1", legeres: 1, graves: 0, critiques: 0 },
|
{ minimum: 20, maximum: undefined, endurance: "100", vie: "1", legeres: 1, graves: 0, critiques: 0 },
|
||||||
],
|
],
|
||||||
"cauchemar": [
|
"cauchemar": [
|
||||||
{ minimum: undefined, maximum: 0, gravite: "frayeur", endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
{ minimum: undefined, maximum: 0, endurance: "0", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||||
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
{ minimum: 1, maximum: 10, endurance: "1d4", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||||
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
{ minimum: 11, maximum: 15, endurance: "1d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||||
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
{ minimum: 16, maximum: 19, endurance: "2d6", vie: "0", legeres: 0, graves: 0, critiques: 0 },
|
||||||
@ -161,39 +161,6 @@ export class RdDUtility {
|
|||||||
return loadTemplates(templatePaths);
|
return loadTemplates(templatePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static buildResolutionTable( ) {
|
|
||||||
let tableRes = []
|
|
||||||
for (var j=0; j<=21; j++) {
|
|
||||||
let subtab = [];
|
|
||||||
for (var i=-10; i<=22; i++) {
|
|
||||||
var m = (i + 10) * 0.5;
|
|
||||||
var v;
|
|
||||||
if (i == -9) {
|
|
||||||
v = Math.floor(j / 2);
|
|
||||||
} else if (i == -10) {
|
|
||||||
v = Math.floor(j / 4);
|
|
||||||
} else {
|
|
||||||
if (j % 2 == 0) {
|
|
||||||
var v = Math.ceil(j * m);
|
|
||||||
} else {
|
|
||||||
var v = Math.floor(j * m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (v < 1) v = 1;
|
|
||||||
let specResults
|
|
||||||
if ( v > 100 )
|
|
||||||
specResults = { part: Math.ceil(v / 5), epart: 1000, etotal: 1000 };
|
|
||||||
else
|
|
||||||
specResults = specialResults[Math.ceil(v / 5 )];
|
|
||||||
let tabIndex = i+10;
|
|
||||||
subtab[tabIndex] = { niveau: i, score: v, part: specResults.part, epart: specResults.epart, etotal: specResults.etotal }
|
|
||||||
}
|
|
||||||
tableRes[j] = subtab;
|
|
||||||
}
|
|
||||||
return tableRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getLevelCategory( )
|
static getLevelCategory( )
|
||||||
{
|
{
|
||||||
@ -208,55 +175,6 @@ export class RdDUtility {
|
|||||||
return bonusmalus;
|
return bonusmalus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static __buildHTMLResolutionHead( dataRow, minLevel=0, maxLevel=32 ) {
|
|
||||||
let r = dataRow;
|
|
||||||
var row = $("<tr/>");
|
|
||||||
for (var colIndex=minLevel; colIndex <= maxLevel; colIndex++) {
|
|
||||||
let c = dataRow[colIndex];
|
|
||||||
let txt = (c.niveau > 0) ? "+"+c.niveau : c.niveau;
|
|
||||||
row.append($("<th class='table-resolution-level'/>").text(txt) );
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static __buildHTMLResolutionRow( dataRow, minLevel=0, maxLevel=32, rowIndex, caracValue, levelValue ) {
|
|
||||||
let r = dataRow;
|
|
||||||
var row = $("<tr/>");
|
|
||||||
for (var colIndex=minLevel; colIndex <= maxLevel; colIndex++) {
|
|
||||||
let c = dataRow[colIndex];
|
|
||||||
if (rowIndex == caracValue && levelValue+10 == colIndex) {
|
|
||||||
row.append($("<td class='table-resolution-target'/>").text(c.score));
|
|
||||||
} else {
|
|
||||||
if ( colIndex == 2 )
|
|
||||||
row.append($("<td class='table-resolution-carac'/>").text(c.score));
|
|
||||||
else
|
|
||||||
row.append($("<td/>").text(c.score));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
static makeHTMLResolutionTable(container, minCarac = 1, maxCarac = 21, minLevel=-10, maxLevel=22, caracValue, levelValue) {
|
|
||||||
minCarac = (minCarac < 1) ? 1 : minCarac;
|
|
||||||
maxCarac = (maxCarac > 21) ? 21 : maxCarac;
|
|
||||||
let data = CONFIG.RDD.resolutionTable;
|
|
||||||
var table = $("<table/>").addClass('table-resolution');
|
|
||||||
// Build first row of levels
|
|
||||||
minLevel = (minLevel < -10) ? 0 : minLevel+10;
|
|
||||||
maxLevel = (maxLevel > 22) ? 32 : maxLevel+10;
|
|
||||||
let row = this.__buildHTMLResolutionHead( data[0], minLevel, maxLevel );
|
|
||||||
table.append(row);
|
|
||||||
// Then the rest...
|
|
||||||
for (var rowIndex=minCarac; rowIndex <= maxCarac; rowIndex++) {
|
|
||||||
let row = this.__buildHTMLResolutionRow( data[rowIndex], minLevel, maxLevel, rowIndex, caracValue, levelValue );
|
|
||||||
table.append(row);
|
|
||||||
}
|
|
||||||
return container.append(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static isTronc( compName )
|
static isTronc( compName )
|
||||||
{
|
{
|
||||||
@ -273,8 +191,9 @@ export class RdDUtility {
|
|||||||
static getResolutionField(caracValue, levelValue )
|
static getResolutionField(caracValue, levelValue )
|
||||||
{
|
{
|
||||||
if ( levelValue < -16 ) {
|
if ( levelValue < -16 ) {
|
||||||
return { "score": 0, "part": 0, "epart": 1, "etotal": 1};
|
return { score: 0, sign:0, part: 0, epart: 1, etotal: 1};
|
||||||
} if ( levelValue < -10 ) {
|
}
|
||||||
|
if ( levelValue < -10 ) {
|
||||||
return levelDown.find(levelData => levelData.level == levelValue);
|
return levelDown.find(levelData => levelData.level == levelValue);
|
||||||
}
|
}
|
||||||
return CONFIG.RDD.resolutionTable[caracValue][levelValue+10];
|
return CONFIG.RDD.resolutionTable[caracValue][levelValue+10];
|
||||||
|
Loading…
Reference in New Issue
Block a user