Files
kopparhavet/module/kh-hooks.js
erebus 2e389704ea v0.0.3
Finishing v0.0.3

Layout fixes
Added support for rolling skill on spells
Fixed migration
Cleaned up the code
Fixed Hjältarnas Tid skill error, updated layout, fixed buttons not working
Fixed right click menu for weapons
Added roll dialog and exceptional rolls
Updated skills styling
Co-Authored-By: erebus <erebus@rikspolisen.se>
Co-Committed-By: erebus <erebus@rikspolisen.se>
2020-12-01 16:30:39 +00:00

33 lines
1.4 KiB
JavaScript

export default class KHHooks {
static async onCreateActor(actor, options, userId) {
if (actor.data.type == "character") {
// Load Skills Compendium skills
let skillIndex;
let actorbaseSkills;
if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") {
// Set currency name
actor.update({ "data.currency.shekel.label": "CURRENCY.SILVER" });
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));
// 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);
}
}
}