Rework skill/skill categ links

This commit is contained in:
2024-08-03 16:41:04 +02:00
parent 1f2558b680
commit cba4394a37
13 changed files with 231 additions and 127 deletions

View File

@ -1,3 +1,5 @@
import { RFRPUtility } from "../rfrp-utility.js";
export class RMSSItem extends Item {
/** @override */
@ -100,21 +102,13 @@ export class RMSSItem extends Item {
}
calculateSelectedSkillCategoryBonus(itemData) {
if (this.isEmbedded === null) {
console.log(`rmss | item.js | Skill ${this.name} has no owner. Not calculating Skill Category bonus`);
}
else
{
const items = this.parent?.items;
console.log(`rmss | item.js | Skill ${this.name} has owner, calculating skill category bonus.`);
if (items) {
for (const item of items) {
if (item.type === "skill_category" && item._id === itemData.system.category) {
console.log(`rmss | item.js | Calculating Skill Category bonus for skill: ${this.name}`);
this.system.category_bonus = item.system.total_bonus;
}
}
}
// Find the relevant skill category
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;
} else {
ui.notifications.warn("No Skill Categories found. Please create a Skill Category.");
}
}
}