2020-10-29 16:18:38 +01:00
|
|
|
// Import Modules
|
|
|
|
import { DS4Actor } from "./actor/actor.js";
|
|
|
|
import { DS4ActorSheet } from "./actor/actor-sheet.js";
|
|
|
|
import { DS4Item } from "./item/item.js";
|
|
|
|
import { DS4ItemSheet } from "./item/item-sheet.js";
|
|
|
|
import { DS4 } from "./config.js";
|
|
|
|
|
|
|
|
Hooks.once("init", async function () {
|
|
|
|
console.log(`DS4 | Initializing the DS4 Game System\n${DS4.ASCII}`);
|
|
|
|
|
|
|
|
game.ds4 = {
|
|
|
|
DS4Actor,
|
|
|
|
DS4Item,
|
|
|
|
DS4,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Record configuration
|
|
|
|
CONFIG.DS4 = DS4;
|
|
|
|
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Actor.entityClass = DS4Actor;
|
|
|
|
CONFIG.Item.entityClass = DS4Item;
|
|
|
|
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("ds4", DS4ActorSheet, { makeDefault: true });
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("ds4", DS4ItemSheet, { makeDefault: true });
|
2020-10-29 22:01:13 +01:00
|
|
|
|
|
|
|
registerHandlebarsPartials();
|
2020-10-29 16:18:38 +01:00
|
|
|
});
|
|
|
|
|
2020-10-29 22:01:13 +01:00
|
|
|
async function registerHandlebarsPartials() {
|
|
|
|
const templatePaths = ["systems/ds4/templates/item/partials/description.hbs"];
|
|
|
|
return loadTemplates(templatePaths);
|
|
|
|
}
|
|
|
|
|
2020-10-29 16:18:38 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Setup */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function runs after game data has been requested and loaded from the servers, so entities exist
|
|
|
|
*/
|
|
|
|
Hooks.once("setup", function () {
|
|
|
|
// Localize CONFIG objects once up-front
|
2020-10-29 22:01:13 +01:00
|
|
|
const toLocalize = ["attackTypes", "itemAvailabilities", "itemTypes", "armorTypes", "armorMaterialTypes"];
|
2020-10-29 16:18:38 +01:00
|
|
|
|
|
|
|
// Exclude some from sorting where the default order matters
|
|
|
|
const noSort = [];
|
|
|
|
|
|
|
|
// Localize and sort CONFIG objects
|
|
|
|
for (let o of toLocalize) {
|
|
|
|
const localized = Object.entries(CONFIG.DS4[o]).map((e) => {
|
|
|
|
return [e[0], game.i18n.localize(e[1])];
|
|
|
|
});
|
|
|
|
if (!noSort.includes(o)) localized.sort((a, b) => a[1].localeCompare(b[1]));
|
|
|
|
CONFIG.DS4[o] = localized.reduce((obj, e) => {
|
|
|
|
obj[e[0]] = e[1];
|
|
|
|
return obj;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
});
|