diff --git a/module/documents/item.js b/module/documents/item.js index f06be2b..f135138 100644 --- a/module/documents/item.js +++ b/module/documents/item.js @@ -1,4 +1,4 @@ -import { RFRPUtility } from "../rfrp-utility.js"; +import { RMFRPUtility } from "../rmfrp-utility.js"; export class RMFRPItem extends Item { @@ -107,7 +107,7 @@ export class RMFRPItem extends Item { // Find the relevant skill category if (!this.parent) { return; } // Only if attached to an actor - let skillC = this.parent?.items || RFRPUtility.getSkillCategories(); + let skillC = this.parent?.items || RMFRPUtility.getSkillCategories(); if (skillC) { let item = skillC.find(it => it.type == "skill_category" && it.name.toLowerCase() == itemData.system.category.toLowerCase()); if (item) { diff --git a/module/rmfrp-process-table.js b/module/rmfrp-process-table.js new file mode 100644 index 0000000..d94f54d --- /dev/null +++ b/module/rmfrp-process-table.js @@ -0,0 +1,50 @@ +export class RMFRPProcessTable { + + constructor() { + // Load a reference to the rmfrp-tables.json file + this.rmfrpTables = require('./rmfrp-tables.json'); + // Loop thru the tables and create a definition object, with key, name and min/ax value of each table + this.rmfrpTablesDef = {} + for (let table in this.rmfrpTables) { + let tableData = this.rmfrpTables[table] + // Search min and max values in the tableData + let min = Number.MAX_SAFE_INTEGER; + let max = Number.MIN_SAFE_INTEGER; + tableData.forEach((element) => { + if (element.result) { + if (Number(element.result)) { + min = Math.min(min, Number(element.result)); + max = Math.max(max, Number(element.result)); + } else { + let range = element.result.split("-"); + min = Math.min(min, Number(range[0])); + max = Math.max(max, Number(range[1])); + } + } + }); + this.rmfrpTablesDef[table] = { + key: table, + name: RMFRPUtility.capitalizeFirstLetters(table.replace(/_/g, " ")), + min: min, + max: max + }; + } + super(); + } + + // Get roll result from table + getAttackRollResult(table, roll, armorValue) { + let result = this.rmfrpTables[table].find((element) => { + if (Number(element.result) && Number(element.result) == Number(roll)) { + return element[String(armorValue)]; + } else { + // SPlit the result into a range + let range = element.result.split("-"); + if (Number(roll) >= Number(range[0]) && Number(roll) <= Number(range[1])) { + return element[String(armorValue)]; + } + } + }); + return undefined; + } +} diff --git a/module/sheets/apps/rmfrp-tables.js b/module/rmfrp-tables.js similarity index 100% rename from module/sheets/apps/rmfrp-tables.js rename to module/rmfrp-tables.js diff --git a/module/rfrp-utility.js b/module/rmfrp-utility.js similarity index 97% rename from module/rfrp-utility.js rename to module/rmfrp-utility.js index 9aced1c..2fe0dc8 100644 --- a/module/rfrp-utility.js +++ b/module/rmfrp-utility.js @@ -1,11 +1,17 @@ /* -------------------------------------------- */ -export class RFRPUtility { +export class RMFRPUtility { /* -------------------------------------------- */ static async init() { } + static capitalizeFirstLetters(str){ + return str.toLowerCase().replace(/^\w|\s\w/g, function (letter) { + return letter.toUpperCase(); + }) + } + /* -------------------------------------------- */ static async ready() { this.registerSettings(); diff --git a/module/sheets/apps/rmfrp_import_skill_categories.js b/module/sheets/apps/rmfrp_import_skill_categories.js index aab8509..be6c4e3 100644 --- a/module/sheets/apps/rmfrp_import_skill_categories.js +++ b/module/sheets/apps/rmfrp_import_skill_categories.js @@ -1,4 +1,4 @@ -import { RFRPUtility } from "../../rfrp-utility.js"; +import { RMFRPUtility } from "../../rmfrp-utility.js"; export default class RMFRPToolsSCImporter extends FormApplication { @@ -50,7 +50,7 @@ export default class RMFRPToolsSCImporter extends FormApplication { console.log("Importing New Skills/Skill Categories."); let newDocuments = []; - let gameSystem = RFRPUtility.getGameSystem(); + let gameSystem = RMFRPUtility.getGameSystem(); for (const sc of skillCategoryData) { const newitem = await pack.getDocument(sc._id); if (newitem.type === itemType && (newitem.system.game_system === "common" || newitem.system.game_system === gameSystem)) { diff --git a/module/sheets/skills/rmfrp_skill_sheet.js b/module/sheets/skills/rmfrp_skill_sheet.js index b3015ad..90916f6 100644 --- a/module/sheets/skills/rmfrp_skill_sheet.js +++ b/module/sheets/skills/rmfrp_skill_sheet.js @@ -1,4 +1,4 @@ -import { RFRPUtility } from "../../rfrp-utility.js"; +import { RMFRPUtility } from "../../rmfrp-utility.js"; // Our Item Sheet extends the default export default class RMFRPSkillSheet extends ItemSheet { @@ -72,7 +72,7 @@ export default class RMFRPSkillSheet extends ItemSheet { // If this Skill is owned then we will return a list of Skill Categories and allow them to choose // Otherwise we'll just return 'Skill has no owner' prepareSkillCategoryValues() { - let skillCategories = RFRPUtility.getSkillCategories(); + let skillCategories = RMFRPUtility.getSkillCategories(); if (this.item.isEmbedded) { skillCategories = this.item.parent.items.filter(it => it.type == "skill_category"); } @@ -96,7 +96,7 @@ export default class RMFRPSkillSheet extends ItemSheet { // Iterate through the owned skill categories and if one of them matches the item id of currently // selected skill category then set the Skill Category Bonus field to the Total Bonus field of the Skill Category prepareSelectedSkillCategoryBonus(selected_skillcat) { - let skillC = this.parent?.items || RFRPUtility.getSkillCategories(); + let skillC = this.parent?.items || RMFRPUtility.getSkillCategories(); if (skillC) { let item = skillC.find(it => it.type == "skill_category" && it.name.toLowerCase() == itemData.system.category.toLowerCase()); if (item) { diff --git a/packs/skill_categories/000148.log b/packs/skill_categories/000151.log similarity index 100% rename from packs/skill_categories/000148.log rename to packs/skill_categories/000151.log diff --git a/packs/skill_categories/CURRENT b/packs/skill_categories/CURRENT index ffd4a01..939d9b8 100644 --- a/packs/skill_categories/CURRENT +++ b/packs/skill_categories/CURRENT @@ -1 +1 @@ -MANIFEST-000146 +MANIFEST-000150 diff --git a/packs/skill_categories/LOG b/packs/skill_categories/LOG index edfb491..ef3e783 100644 --- a/packs/skill_categories/LOG +++ b/packs/skill_categories/LOG @@ -1,8 +1,3 @@ -2024/08/15-22:19:09.675609 7fdec34006c0 Recovering log #144 -2024/08/15-22:19:09.731573 7fdec34006c0 Delete type=3 #142 -2024/08/15-22:19:09.731716 7fdec34006c0 Delete type=0 #144 -2024/08/15-22:24:10.619452 7fdec0c006c0 Level-0 table #149: started -2024/08/15-22:24:10.619485 7fdec0c006c0 Level-0 table #149: 0 bytes OK -2024/08/15-22:24:10.626074 7fdec0c006c0 Delete type=0 #147 -2024/08/15-22:24:10.632684 7fdec0c006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) -2024/08/15-22:24:10.646015 7fdec0c006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) +2024/08/15-22:43:42.844641 7fdec20006c0 Recovering log #148 +2024/08/15-22:43:42.854211 7fdec20006c0 Delete type=3 #146 +2024/08/15-22:43:42.854261 7fdec20006c0 Delete type=0 #148 diff --git a/packs/skill_categories/LOG.old b/packs/skill_categories/LOG.old index 5514cf9..edfb491 100644 --- a/packs/skill_categories/LOG.old +++ b/packs/skill_categories/LOG.old @@ -1,8 +1,8 @@ -2024/08/11-18:35:03.709029 7f47856006c0 Recovering log #139 -2024/08/11-18:35:03.719540 7f47856006c0 Delete type=3 #137 -2024/08/11-18:35:03.719589 7f47856006c0 Delete type=0 #139 -2024/08/11-19:09:53.738475 7f4782e006c0 Level-0 table #145: started -2024/08/11-19:09:53.738526 7f4782e006c0 Level-0 table #145: 0 bytes OK -2024/08/11-19:09:53.744948 7f4782e006c0 Delete type=0 #143 -2024/08/11-19:09:53.757342 7f4782e006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) -2024/08/11-19:09:53.767613 7f4782e006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) +2024/08/15-22:19:09.675609 7fdec34006c0 Recovering log #144 +2024/08/15-22:19:09.731573 7fdec34006c0 Delete type=3 #142 +2024/08/15-22:19:09.731716 7fdec34006c0 Delete type=0 #144 +2024/08/15-22:24:10.619452 7fdec0c006c0 Level-0 table #149: started +2024/08/15-22:24:10.619485 7fdec0c006c0 Level-0 table #149: 0 bytes OK +2024/08/15-22:24:10.626074 7fdec0c006c0 Delete type=0 #147 +2024/08/15-22:24:10.632684 7fdec0c006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) +2024/08/15-22:24:10.646015 7fdec0c006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end) diff --git a/packs/skill_categories/MANIFEST-000146 b/packs/skill_categories/MANIFEST-000150 similarity index 72% rename from packs/skill_categories/MANIFEST-000146 rename to packs/skill_categories/MANIFEST-000150 index c5a746e..efe30aa 100644 Binary files a/packs/skill_categories/MANIFEST-000146 and b/packs/skill_categories/MANIFEST-000150 differ diff --git a/packs/skills/000054.log b/packs/skills/000057.log similarity index 100% rename from packs/skills/000054.log rename to packs/skills/000057.log diff --git a/packs/skills/CURRENT b/packs/skills/CURRENT index f774e85..80d9de0 100644 --- a/packs/skills/CURRENT +++ b/packs/skills/CURRENT @@ -1 +1 @@ -MANIFEST-000052 +MANIFEST-000056 diff --git a/packs/skills/LOG b/packs/skills/LOG index 8d3cf19..49ef282 100644 --- a/packs/skills/LOG +++ b/packs/skills/LOG @@ -1,8 +1,3 @@ -2024/08/15-22:19:09.734714 7fdec16006c0 Recovering log #50 -2024/08/15-22:19:09.788430 7fdec16006c0 Delete type=3 #48 -2024/08/15-22:19:09.788488 7fdec16006c0 Delete type=0 #50 -2024/08/15-22:24:10.626217 7fdec0c006c0 Level-0 table #55: started -2024/08/15-22:24:10.626258 7fdec0c006c0 Level-0 table #55: 0 bytes OK -2024/08/15-22:24:10.632488 7fdec0c006c0 Delete type=0 #53 -2024/08/15-22:24:10.632706 7fdec0c006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) -2024/08/15-22:24:10.646031 7fdec0c006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) +2024/08/15-22:43:42.856529 7fdec2a006c0 Recovering log #54 +2024/08/15-22:43:42.866357 7fdec2a006c0 Delete type=3 #52 +2024/08/15-22:43:42.866410 7fdec2a006c0 Delete type=0 #54 diff --git a/packs/skills/LOG.old b/packs/skills/LOG.old index 42a503c..8d3cf19 100644 --- a/packs/skills/LOG.old +++ b/packs/skills/LOG.old @@ -1,8 +1,8 @@ -2024/08/11-18:35:03.722579 7f4784c006c0 Recovering log #45 -2024/08/11-18:35:03.732199 7f4784c006c0 Delete type=3 #43 -2024/08/11-18:35:03.732302 7f4784c006c0 Delete type=0 #45 -2024/08/11-19:09:53.712459 7f4782e006c0 Level-0 table #51: started -2024/08/11-19:09:53.712523 7f4782e006c0 Level-0 table #51: 0 bytes OK -2024/08/11-19:09:53.719097 7f4782e006c0 Delete type=0 #49 -2024/08/11-19:09:53.745186 7f4782e006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) -2024/08/11-19:09:53.757356 7f4782e006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) +2024/08/15-22:19:09.734714 7fdec16006c0 Recovering log #50 +2024/08/15-22:19:09.788430 7fdec16006c0 Delete type=3 #48 +2024/08/15-22:19:09.788488 7fdec16006c0 Delete type=0 #50 +2024/08/15-22:24:10.626217 7fdec0c006c0 Level-0 table #55: started +2024/08/15-22:24:10.626258 7fdec0c006c0 Level-0 table #55: 0 bytes OK +2024/08/15-22:24:10.632488 7fdec0c006c0 Delete type=0 #53 +2024/08/15-22:24:10.632706 7fdec0c006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) +2024/08/15-22:24:10.646031 7fdec0c006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end) diff --git a/packs/skills/MANIFEST-000052 b/packs/skills/MANIFEST-000056 similarity index 73% rename from packs/skills/MANIFEST-000052 rename to packs/skills/MANIFEST-000056 index 7d5e4dc..8e14332 100644 Binary files a/packs/skills/MANIFEST-000052 and b/packs/skills/MANIFEST-000056 differ diff --git a/rmfrp.js b/rmfrp.js index 5d11702..2f4fae8 100644 --- a/rmfrp.js +++ b/rmfrp.js @@ -1,6 +1,5 @@ // Import Configuration Object import { rmfrp } from "./module/config.js"; -//import { registerGetSceneControlButtonsHook } from "./module/controls.js"; // Import document classes. import { RMFRPActor } from "./module/documents/actor.js"; @@ -19,7 +18,7 @@ import RMFRPSkillSheet from "./module/sheets/skills/rmfrp_skill_sheet.js"; import RMFRPPlayerSheet from "./module/sheets/actors/rmfrp_player_sheet.js"; import RMFRPToolsSCImporter from "./module/sheets/apps/rmfrp_import_skill_categories.js"; import RMFRPToolsDiceRoller from "./module/sheets/apps/rmfrp_dice_roller.js"; -import { RFRPUtility } from "./module/rfrp-utility.js"; +import { RMFRPUtility } from "./module/rmfrp-utility.js"; // Register Scene Controls // registerGetSceneControlButtonsHook(); @@ -80,8 +79,8 @@ Hooks.once("init", function () { // Actors Actors.registerSheet("fvtt-rolemaster-frp", RMFRPPlayerSheet, { makeDefault: true, label: "rmfrp.entity_sheet.player_characrer", types: ["character"] }); - RFRPUtility.loadHandlebarsTemplates(); - RFRPUtility.loadHandlebarsHelpers(); + RMFRPUtility.loadHandlebarsTemplates(); + RMFRPUtility.loadHandlebarsHelpers(); }); @@ -89,5 +88,5 @@ Hooks.once("ready", async function () { console.log("rmfrp | Ready"); // Load Utility - await RFRPUtility.ready(); + await RMFRPUtility.ready(); })