first commit

This commit is contained in:
2020-11-28 19:12:19 +01:00
commit c3a7388592
38 changed files with 3189 additions and 0 deletions

23
module/kh-hooks.js Normal file
View File

@@ -0,0 +1,23 @@
export default class KHHooks {
static async onCreateActor(actor, options, userId) {
if (actor.data.type == "character") {
const actorbaseSkills = actor.data.data.baseSkills;
// 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));
await actor.createEmbeddedEntity("OwnedItem", _skillsList);
} else {
setTimeout(async function () {
await actor.sheet.render(true);
}, 500);
}
}
}