Better import and various stuff

This commit is contained in:
2024-08-10 09:48:43 +02:00
parent 2b1da44f3a
commit aad90144fe
22 changed files with 97 additions and 75 deletions

View File

@ -46,10 +46,11 @@ export class RMSSItem extends Item {
prepareDerivedData() {
const itemData = this;
const systemData = itemData.system;
const flags = itemData.flags.rmss || {};
if (this.parent?.getFlag("world", "importing")) {
return; // Don't calculate skill bonuses if we are importing
}
// Make separate methods for each item type to keep things organized.
if (itemData.type === "skill") {
this._prepareSkillCategoryData(itemData);
}
@ -68,6 +69,7 @@ export class RMSSItem extends Item {
_prepareSkillData(itemData) {
if (itemData.type !== "skill") return;
console.log(`rmss | item.js | Preparing Skill Data for: ${itemData.name}`);
// Make modifications to data here. For example:
// const systemData = itemData.system;
@ -103,12 +105,18 @@ export class RMSSItem extends Item {
calculateSelectedSkillCategoryBonus(itemData) {
// Find the relevant skill category
if (!this.parent) { return; } // Only if attached to an actor
let skillC = this.parent?.items || RFRPUtility.getSkillCategories();
if (skillC) {
let item = skillC.find(it => it.type == "skill_category" && it.name.toLowerCase() == itemData.system.category.toLowerCase());
this.system.category_bonus = item.system.total_bonus;
if (item) {
this.system.category_bonus = item.system.total_bonus;
} else {
ui.notifications.warn(`Skill Category ${itemData.system.category} not found for Skill ${itemData.name}`);
}
} else {
ui.notifications.warn("No Skill Categories found. Please create a Skill Category.");
ui.notifications.info("No Skill Categories found. Please create a Skill Category.");
}
}
}