Rework skill/skill categ links
This commit is contained in:
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user