Final v0.0.2

This commit is contained in:
2020-11-30 06:23:35 +01:00
parent 512d0de4e5
commit 6f030bd6b5
20 changed files with 884 additions and 135 deletions

View File

@@ -1,15 +1,22 @@
export default class KHHooks {
static async onCreateActor(actor, options, userId) {
if (actor.data.type == "character") {
const actorbaseSkills = actor.data.data.baseSkills;
// Load Skills Compendium skills
let skillIndex;
let actorbaseSkills;
if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") {
actorbaseSkills = CONFIG.KH.baseSkillsHT
skillIndex = await game.packs.get("kopparhavet.skills-ht").getContent();
} else {
actorbaseSkills = CONFIG.KH.baseSkills;
skillIndex = await game.packs.get("kopparhavet.skills").getContent();
}
// Check if skill already exists by some chance
const existingSkills = actor.items.filter((i) => i.type === ItemType.Skill).map((i) => i.name);
const skillsToAdd = actorbaseSkills.filter((s) => !existingSkills.includes(s));
// Load Skills Compendium skills
const skillIndex = await game.packs.get("kopparhavet.skills").getContent();
// Filter skillIndex array to include only skills for Actor Type.
let _skillsList = skillIndex.filter((i) => skillsToAdd.includes(i.data.name));