#11 gestion encombrement et malus associé
This commit is contained in:
		| @@ -1,8 +1,8 @@ | ||||
| /* Common useful functions shared between objects */ | ||||
|  | ||||
| import { RdDActor } from "./actor.js"; | ||||
| import { TMRUtility } from "./tmr-utility.js"; | ||||
| import { RdDRollTables } from "./rdd-rolltables.js"; | ||||
| import { RdDResolutionTable } from "./rdd-resolution-table.js"; | ||||
|  | ||||
| const level_category = {  | ||||
|   "generale": "-4",  | ||||
| @@ -48,12 +48,12 @@ const specialResults = [ { "part":  0, "epart": 0,  "etotal":   0 },  // 0 | ||||
|                            { "part": 19, "epart": 99, "etotal": 100 }, // 81-95 | ||||
|                            { "part": 20, "epart": 100, "etotal": 100 }  // 96-00 | ||||
|                           ]; | ||||
| const levelDown = [ { "level": -11, "score": 1, "part": 0, "epart": 2, "etotal": 90 }, | ||||
|                     { "level": -12, "score": 1, "part": 0, "epart": 2, "etotal": 70 }, | ||||
|                     { "level": -13, "score": 1, "part": 0, "epart": 2, "etotal": 50 }, | ||||
|                     { "level": -14, "score": 1, "part": 0, "epart": 2, "etotal": 30 }, | ||||
|                     { "level": -15, "score": 1, "part": 0, "epart": 2, "etotal": 10 }, | ||||
|                     { "level": -16, "score": 1, "part": 0, "epart": 2, "etotal":  2 } | ||||
| const levelDown = [ { "level": -11, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 90 }, | ||||
|                     { "level": -12, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 70 }, | ||||
|                     { "level": -13, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 50 }, | ||||
|                     { "level": -14, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 30 }, | ||||
|                     { "level": -15, "score": 1, "sign": 0, "part": 0, "epart": 2, "etotal": 10 }, | ||||
|                     { "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. | ||||
|                         [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 }, | ||||
|   ], | ||||
|   "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: 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 }, | ||||
| @@ -162,6 +162,7 @@ export class RdDUtility  { | ||||
|  | ||||
|     return loadTemplates(templatePaths); | ||||
|   } | ||||
| <<<<<<< HEAD | ||||
|    | ||||
|   /************************************************************************************/ | ||||
|   static buildConteneur( objet, niveau ) { | ||||
| @@ -211,6 +212,8 @@ export class RdDUtility  { | ||||
|     } | ||||
|     return tableRes; | ||||
|   } | ||||
| ======= | ||||
| >>>>>>> fb52e394e7e17fad20a0bdaa2ae9ea00c03a465e | ||||
|  | ||||
|   /* -------------------------------------------- */ | ||||
|   static getLevelCategory( )   | ||||
| @@ -226,55 +229,6 @@ export class RdDUtility  { | ||||
|     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 ) | ||||
|   { | ||||
| @@ -291,8 +245,9 @@ export class RdDUtility  { | ||||
|   static getResolutionField(caracValue, levelValue )  | ||||
|   { | ||||
|     if ( levelValue < -16 ) { | ||||
|       return { "score": 0, "part": 0, "epart": 1, "etotal": 1}; | ||||
|     }  if ( levelValue < -10 ) { | ||||
|       return { score: 0, sign:0, part: 0, epart: 1, etotal: 1}; | ||||
|     }  | ||||
|     if ( levelValue < -10 ) { | ||||
|       return levelDown.find(levelData => levelData.level == levelValue); | ||||
|     } | ||||
|     return CONFIG.RDD.resolutionTable[caracValue][levelValue+10]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user