First version with weapons

This commit is contained in:
LeRatierBretonnien 2024-08-23 11:45:23 +02:00
parent 45ee08e6c2
commit 8cb2969d70
22 changed files with 3648 additions and 3493 deletions

View File

@ -204,7 +204,15 @@
"breakage_range": "B#s", "breakage_range": "B#s",
"strength": "Str", "strength": "Str",
"fumble_range": "Fumble", "fumble_range": "Fumble",
"equipped": "Equipped" "equipped": "Equipped",
"skill": "Skill",
"hits_multiplier": "Hits Multiplier",
"attack_table": "Attack Table",
"max_rank_size": "Max Rank Size",
"critical_table": "Critical Table",
"lsl_crit_column": "LSL",
"range_modifier": "Range Modifier",
"weapon_bonus": "Weapon Bonus"
}, },
"herb_or_poison": { "herb_or_poison": {
"codes": "Codes", "codes": "Codes",

View File

@ -11,4 +11,14 @@
height: 100% height: 100%
} }
} }
.long-input {
width: 100%;
max-width: 100%;
min-width: 100%;
}
.short-input {
width: 50px;
max-width: 50px;
min-width: 50px;
}
} }

View File

@ -308,6 +308,8 @@ export class RMFRPActor extends Actor {
ownedItems[item._id] = item.name; ownedItems[item._id] = item.name;
} }
} }
// sort the ownedItems by name
ownedItems = Object.fromEntries(Object.entries(ownedItems).sort((a,b) => a[1].localeCompare(b[1])));
return (ownedItems); return (ownedItems);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,50 +1,100 @@
import { RMFRPUtility } from "./rmfrp-utility.js";
import { RMFRP_ATTACK_TABLES } from "./rmfrp-attack-tables.js";
export class RMFRPProcessTable { export class RMFRPProcessTable {
constructor() { constructor() {
// Load a reference to the rmfrp-tables.json file // Load a reference to the rmfrp-tables.json file
this.rmfrpTables = require('./rmfrp-tables.json'); this.rmfrpTables = RMFRP_ATTACK_TABLES
// Loop thru the tables and create a definition object, with key, name and min/ax value of each table // Loop thru the tables and create a definition object, with key, name and min/ax value of each table
this.rmfrpTablesDef = {} this.rmfrpTablesDef = {}
for (let table in this.rmfrpTables) { for (let table in this.rmfrpTables) {
let tableData = this.rmfrpTables[table] let tableData = this.rmfrpTables[table]
// Search min and max values in the tableData // Search min and max values in the tableData
let min = Number.MAX_SAFE_INTEGER; let min = Number.MAX_SAFE_INTEGER;
let minKey = "";
let max = Number.MIN_SAFE_INTEGER; let max = Number.MIN_SAFE_INTEGER;
tableData.forEach((element) => { let maxKey = "";
if (element.result) { for (let resultData of tableData) {
let element = resultData["result"];
if (Number(element.result)) { if (Number(element.result)) {
min = Math.min(min, Number(element.result)); let value = Number(element.result)
max = Math.max(max, Number(element.result)); if (value > max) {
max = value
maxKey = element.result
}
if (value < min) {
min = value
minKey = element.result
} else { } else {
let range = element.result.split("-"); let range = element.result.split("-");
min = Math.min(min, Number(range[0])); if (Number(range[0]) > max) {
max = Math.max(max, Number(range[1])); max = Number(range[0])
maxKey = element.result
}
if (Number(range[1]) < min) {
min = Number(range[1])
minKey = element.result
}
}
} }
} }
});
this.rmfrpTablesDef[table] = { this.rmfrpTablesDef[table] = {
key: table, key: table,
name: RMFRPUtility.capitalizeFirstLetters(table.replace(/_/g, " ")), name: RMFRPUtility.capitalizeFirstLetters(table.replace(/_/g, " ")),
min: min, min: min,
max: max minKey: minKey,
max: max,
maxKey: maxKey
}; };
} }
super(); // Sort rmfrpTablesDef by name
this.rmfrpTablesDef = Object.values(this.rmfrpTablesDef).sort((a, b) => a.name.localeCompare(b.name))
}
getTableDef() {
return this.rmfrpTablesDef;
} }
// Get roll result from table // Get roll result from table
getAttackRollResult(table, roll, armorValue) { getAttackRollResult(tableKey, roll, armorValue) {
let result = this.rmfrpTables[table].find((element) => { roll = Number(roll);
if (isNaN(roll)) {
return undefined;
}
let table = this.rmfrpTables[tableKey]
let tableDef = this.rmfrpTablesDef[tableKey]
if (!table || !tableDef) {
return undefined;
}
// Check min and max values
if (roll < tableDef.min) {
// return the min value
return table.find((element) => {
let elem = element.result == tableDef.minKey;
return elem[String(armorValue)];
});
}
if (roll > tableDef.max) {
// return the min value
return table.find((element) => {
let elem = element.result == tableDef.maxKey;
return elem[String(armorValue)];
});
}
return table.find((element) => {
if (Number(element.result) && Number(element.result) == Number(roll)) { if (Number(element.result) && Number(element.result) == Number(roll)) {
return element[String(armorValue)]; return element[String(armorValue)];
} else { } else {
// SPlit the result into a range // Split the result into a range
let range = element.result.split("-"); let range = element.result.split("-");
if (Number(roll) >= Number(range[0]) && Number(roll) <= Number(range[1])) { if (Number(roll) >= Number(range[0]) && Number(roll) <= Number(range[1])) {
return element[String(armorValue)]; return element[String(armorValue)];
} }
} }
}); });
return undefined;
} }
} }

View File

@ -18,7 +18,7 @@ export class RMFRPUtility {
this.gameSystem = game.settings.get("fvtt-rolemaster-frp", "game_system"); this.gameSystem = game.settings.get("fvtt-rolemaster-frp", "game_system");
const skillCategories = await RFRPUtility.loadCompendium("fvtt-rolemaster-frp.skill_categories") const skillCategories = await RMFRPUtility.loadCompendium("fvtt-rolemaster-frp.skill_categories")
this.skillCategories = skillCategories.map(i => i.toObject()).filter( i => i.system.game_system == "common" || i.system.game_system == this.gameSystem); this.skillCategories = skillCategories.map(i => i.toObject()).filter( i => i.system.game_system == "common" || i.system.game_system == this.gameSystem);
// Sort skill categories by name // Sort skill categories by name
this.skillCategories.sort((a, b) => a.name.localeCompare(b.name)); this.skillCategories.sort((a, b) => a.name.localeCompare(b.name));
@ -58,7 +58,7 @@ export class RMFRPUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async loadCompendium(compendium, filter = item => true) { static async loadCompendium(compendium, filter = item => true) {
let compendiumData = await RFRPUtility.loadCompendiumData(compendium); let compendiumData = await RMFRPUtility.loadCompendiumData(compendium);
return compendiumData.filter(filter); return compendiumData.filter(filter);
} }
@ -70,7 +70,7 @@ export class RMFRPUtility {
} }
static findChatMessageId(current) { static findChatMessageId(current) {
return RFRPUtility.getChatMessageId(HeritiersUtility.findChatMessage(current)); return RMFRPUtility.getChatMessageId(HeritiersUtility.findChatMessage(current));
} }
static getChatMessageId(node) { static getChatMessageId(node) {
@ -78,7 +78,7 @@ export class RMFRPUtility {
} }
static findChatMessage(current) { static findChatMessage(current) {
return RFRPUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id')) return RMFRPUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'))
} }
static findNodeMatching(current, predicate) { static findNodeMatching(current, predicate) {
@ -86,7 +86,7 @@ export class RMFRPUtility {
if (predicate(current)) { if (predicate(current)) {
return current; return current;
} }
return RFRPUtility.findNodeMatching(current.parentElement, predicate); return RMFRPUtility.findNodeMatching(current.parentElement, predicate);
} }
return undefined; return undefined;
} }

View File

@ -28,9 +28,17 @@ export default class RMFRPWeaponSheet extends ItemSheet {
item: baseData.item, item: baseData.item,
system: baseData.item.system, system: baseData.item.system,
config: CONFIG.rmfrp, config: CONFIG.rmfrp,
skills: {},
criticalTables: {},
attackTables: game.rmfrp.attackTables.getTableDef(),
enrichedDescription: enrichedDescription enrichedDescription: enrichedDescription
}; }
console.log("Parent", this.object)
// Add the skill data to the sheet if the item is owned
if (this.object.actor) {
sheetData.skills = this.object.actor.getOwnedItemsByType("skill");
}
console.log(sheetData);
return sheetData; return sheetData;
} }
} }

View File

@ -1 +1 @@
MANIFEST-000150 MANIFEST-000168

View File

@ -1,3 +1,8 @@
2024/08/15-22:43:42.844641 7fdec20006c0 Recovering log #148 2024/08/23-11:39:46.394926 7fa527e006c0 Recovering log #167
2024/08/15-22:43:42.854211 7fdec20006c0 Delete type=3 #146 2024/08/23-11:39:46.405233 7fa527e006c0 Delete type=0 #167
2024/08/15-22:43:42.854261 7fdec20006c0 Delete type=0 #148 2024/08/23-11:39:46.405284 7fa527e006c0 Delete type=3 #166
2024/08/23-11:44:39.425049 7fa525a006c0 Level-0 table #171: started
2024/08/23-11:44:39.425122 7fa525a006c0 Level-0 table #171: 0 bytes OK
2024/08/23-11:44:39.431462 7fa525a006c0 Delete type=0 #169
2024/08/23-11:44:39.441660 7fa525a006c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2024/08/23-11:44:39.441685 7fa525a006c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,3 @@
2024/08/15-22:19:09.675609 7fdec34006c0 Recovering log #144 2024/08/23-10:14:01.919789 7f67a10006c0 Recovering log #164
2024/08/15-22:19:09.731573 7fdec34006c0 Delete type=3 #142 2024/08/23-10:14:01.965430 7f67a10006c0 Delete type=3 #162
2024/08/15-22:19:09.731716 7fdec34006c0 Delete type=0 #144 2024/08/23-10:14:01.965586 7f67a10006c0 Delete type=0 #164
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)

View File

@ -1 +1 @@
MANIFEST-000056 MANIFEST-000074

View File

@ -1,3 +1,8 @@
2024/08/15-22:43:42.856529 7fdec2a006c0 Recovering log #54 2024/08/23-11:39:46.408879 7fa526a006c0 Recovering log #73
2024/08/15-22:43:42.866357 7fdec2a006c0 Delete type=3 #52 2024/08/23-11:39:46.419408 7fa526a006c0 Delete type=0 #73
2024/08/15-22:43:42.866410 7fdec2a006c0 Delete type=0 #54 2024/08/23-11:39:46.419471 7fa526a006c0 Delete type=3 #72
2024/08/23-11:44:39.417619 7fa525a006c0 Level-0 table #77: started
2024/08/23-11:44:39.417692 7fa525a006c0 Level-0 table #77: 0 bytes OK
2024/08/23-11:44:39.424844 7fa525a006c0 Delete type=0 #75
2024/08/23-11:44:39.441644 7fa525a006c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2024/08/23-11:44:39.453852 7fa525a006c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,3 @@
2024/08/15-22:19:09.734714 7fdec16006c0 Recovering log #50 2024/08/23-10:14:01.974311 7f679b4006c0 Recovering log #70
2024/08/15-22:19:09.788430 7fdec16006c0 Delete type=3 #48 2024/08/23-10:14:02.026991 7f679b4006c0 Delete type=3 #68
2024/08/15-22:19:09.788488 7fdec16006c0 Delete type=0 #50 2024/08/23-10:14:02.027094 7f679b4006c0 Delete type=0 #70
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)

View File

@ -551,3 +551,13 @@
.sheet .sheet-content .editor { .sheet .sheet-content .editor {
height: 100%; height: 100%;
} }
.sheet .long-input {
width: 100%;
max-width: 100%;
min-width: 100%;
}
.sheet .short-input {
width: 50px;
max-width: 50px;
min-width: 50px;
}

View File

@ -19,6 +19,7 @@ import RMFRPPlayerSheet from "./module/sheets/actors/rmfrp_player_sheet.js";
import RMFRPToolsSCImporter from "./module/sheets/apps/rmfrp_import_skill_categories.js"; import RMFRPToolsSCImporter from "./module/sheets/apps/rmfrp_import_skill_categories.js";
import RMFRPToolsDiceRoller from "./module/sheets/apps/rmfrp_dice_roller.js"; import RMFRPToolsDiceRoller from "./module/sheets/apps/rmfrp_dice_roller.js";
import { RMFRPUtility } from "./module/rmfrp-utility.js"; import { RMFRPUtility } from "./module/rmfrp-utility.js";
import { RMFRPProcessTable } from "./module/rmfrp-process-table.js";
// Register Scene Controls // Register Scene Controls
// registerGetSceneControlButtonsHook(); // registerGetSceneControlButtonsHook();
@ -32,6 +33,8 @@ Hooks.once("init", function () {
game.rmfrp = { game.rmfrp = {
RMFRPActor, RMFRPActor,
RMFRPItem, RMFRPItem,
RMFRPUtility,
attackTables: new RMFRPProcessTable(),
applications: { applications: {
RMFRPToolsSCImporter, RMFRPToolsSCImporter,
RMFRPToolsDiceRoller RMFRPToolsDiceRoller

View File

@ -3,7 +3,7 @@
"title": "Rolemaster FRP System", "title": "Rolemaster FRP System",
"description": "The Rolemaster FRP system for FoundryVTT.", "description": "The Rolemaster FRP system for FoundryVTT.",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/raw/branch/develop/system.json", "manifest": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/raw/branch/develop/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.16.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.17.zip",
"authors": [ "authors": [
{ {
"name": "Cynicide", "name": "Cynicide",
@ -14,7 +14,7 @@
"email": "" "email": ""
} }
], ],
"version": "12.0.16", "version": "12.0.17",
"compatibility": { "compatibility": {
"minimum": "12", "minimum": "12",
"verified": "12" "verified": "12"

View File

@ -295,11 +295,21 @@
"cost": 0, "cost": 0,
"weight": 0, "weight": 0,
"type" : "", "type" : "",
"fumble_value": 0,
"fumble_table": "",
"fumble_column": "",
"weapon_bonus": 0,
"skill": "",
"hits_multiplier": 0,
"attack_table": "",
"max_rank_size": 0,
"critical_table" : "",
"lsl_crit_column": "",
"range_modifier": [ {"range": 0, "modifier": 0}, {"range": 0, "modifier": 0}, {"range": 0, "modifier": 0}, {"range": 0, "modifier": 0}, {"range": 0, "modifier": 0}, {"range": 0, "modifier": 0} ],
"prod_time": 0, "prod_time": 0,
"at": 0, "at": 0,
"breakage_range": "", "breakage_range": "",
"strength": "", "strength": ""
"fumble_range": ""
}, },
"herb_or_poison": { "herb_or_poison": {
"templates": ["base"], "templates": ["base"],

View File

@ -15,7 +15,6 @@
<th>{{localize "rmfrp.weapon.weight"}}</th> <th>{{localize "rmfrp.weapon.weight"}}</th>
<th>{{localize "rmfrp.weapon.breakage_range"}}</th> <th>{{localize "rmfrp.weapon.breakage_range"}}</th>
<th>{{localize "rmfrp.weapon.strength"}}</th> <th>{{localize "rmfrp.weapon.strength"}}</th>
<th>{{localize "rmfrp.weapon.fumble_range"}}</th>
</tr> </tr>
<td> <td>
@ -42,11 +41,68 @@
<td> <td>
<input name="system.strength" type="text" value="{{system.strength}}" data-dtype="String"/> <input name="system.strength" type="text" value="{{system.strength}}" data-dtype="String"/>
</td> </td>
<td>
<input name="system.fumble_range" type="text" value="{{system.fumble_range}}" data-dtype="String"/>
</td>
</table> </table>
<table>
<tr>
<th>{{localize "rmfrp.weapon.skill"}}</th>
<th>{{localize "rmfrp.weapon.weapon_bonus"}}</th>
</tr>
<td>
<select class="long-input" name="system.skill" type="text" value="{{system.skill}}" data-dtype="String">
{{selectOptions skills selected=system.skill }}
</select>
</td>
<td>
<input class="short-input" name="system.weapon_bonus" type="text" value="{{system.weapon_bonus}}" data-dtype="Number"/>
</td>
</table>
<table>
<tr>
<th>{{localize "rmfrp.weapon.attack_table"}}</th>
<th>{{localize "rmfrp.weapon.max_rank_size"}}</th>
</tr>
<td>
<select class="long-input" name="system.attack_table" type="text" value="{{system.attack_table}}" data-dtype="String">
{{selectOptions attackTables selected=system.attack_table nameAttr="key" valueAttr="key" labelAttr="name"}}
</select>
</td>
<td>
<input class="short-input" name="system.max_rank_size" type="text" value="{{system.max_rank_size}}" data-dtype="Number"/>
</td>
</table>
<table>
<tr>
<th>{{localize "rmfrp.weapon.critical_table"}}</th>
<th>{{localize "rmfrp.weapon.lsl_crit_column"}}</th>
</tr>
<td>
<select class="long-input" name="system.critical_table" type="text" value="{{system.critical_table}}" data-dtype="String">
{{selectOptions criticalTables selected=system.critical_table nameAttr="key" valueAttr="key" labelAttr="name"}}
</select>
</td>
<td>
<input class="short-input" name="system.lsl_crit_column" type="text" value="{{system.lsl_crit_column}}" data-dtype="Number"/>
</td>
</table>
<table class="short-input">
<th class="short-input">{{localize "rmfrp.weapon.range_modifier"}}</th>
{{#each system.range_modifier as |range idx|}}
<tr class="short-input">
<td class="short-input">
<input class="short-input" name="system.range_modifier.{{@index}}.range" type="text" value="{{range.range}}" data-dtype="Number"/>
</td>
<td class="short-input">
<input class="short-input" name="system.range_modifier.{{@index}}.modifier" type="text" value="{{range.modifier}}" data-dtype="Number"/>
</td>
</tr>
{{/each}}
</table>
{{localize "rmfrp.item.description"}} {{localize "rmfrp.item.description"}}
{{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}} {{editor enrichedDescription target="system.description" button=true owner=owner editable=editable}}
</div> </div>