2020-12-23 16:52:20 +01:00
|
|
|
// Import Modules
|
2020-12-23 17:05:12 +01:00
|
|
|
import { DS4Actor } from "./actor/actor";
|
|
|
|
import { DS4ActorSheet } from "./actor/actor-sheet";
|
|
|
|
import { DS4Item } from "./item/item";
|
|
|
|
import { DS4ItemSheet } from "./item/item-sheet";
|
|
|
|
import { DS4 } from "./config";
|
2021-01-08 23:18:01 +01:00
|
|
|
import { DS4Check } from "./rolls/check";
|
2020-12-23 16:52:20 +01:00
|
|
|
|
|
|
|
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
|
2020-12-28 17:34:40 +01:00
|
|
|
CONFIG.Actor.entityClass = DS4Actor as typeof Actor;
|
|
|
|
CONFIG.Item.entityClass = DS4Item as typeof Item;
|
2020-12-23 16:52:20 +01:00
|
|
|
|
2021-01-06 19:15:56 +01:00
|
|
|
// Configure Dice
|
2021-01-08 23:18:01 +01:00
|
|
|
CONFIG.Dice.types = [Die, DS4Check];
|
2021-01-06 19:15:56 +01:00
|
|
|
CONFIG.Dice.terms = {
|
|
|
|
c: Coin,
|
|
|
|
d: Die,
|
2021-01-08 23:18:01 +01:00
|
|
|
s: DS4Check,
|
2021-01-06 19:15:56 +01:00
|
|
|
};
|
|
|
|
|
2020-12-23 16:52:20 +01:00
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("ds4", DS4ActorSheet, { makeDefault: true });
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("ds4", DS4ItemSheet, { makeDefault: true });
|
|
|
|
|
|
|
|
registerHandlebarsPartials();
|
|
|
|
});
|
|
|
|
|
|
|
|
async function registerHandlebarsPartials() {
|
2020-12-28 20:38:02 +01:00
|
|
|
const templatePaths = [
|
2021-01-08 23:23:53 +01:00
|
|
|
"systems/ds4/templates/item/partials/sheet-header.hbs",
|
2020-12-28 20:38:02 +01:00
|
|
|
"systems/ds4/templates/item/partials/description.hbs",
|
2020-12-28 18:49:55 +01:00
|
|
|
"systems/ds4/templates/item/partials/details.hbs",
|
|
|
|
"systems/ds4/templates/item/partials/effects.hbs",
|
2020-12-28 18:58:01 +01:00
|
|
|
"systems/ds4/templates/item/partials/body.hbs",
|
2021-01-03 00:08:21 +01:00
|
|
|
"systems/ds4/templates/actor/partials/items-overview.hbs",
|
2021-01-06 01:24:37 +01:00
|
|
|
"systems/ds4/templates/actor/partials/talents-overview.hbs",
|
2021-01-06 16:29:02 +01:00
|
|
|
"systems/ds4/templates/actor/partials/overview-add-button.hbs",
|
|
|
|
"systems/ds4/templates/actor/partials/overview-control-buttons.hbs",
|
2021-01-04 00:55:44 +01:00
|
|
|
"systems/ds4/templates/actor/partials/attributes-traits.hbs",
|
2021-01-04 01:11:05 +01:00
|
|
|
"systems/ds4/templates/actor/partials/combat-values.hbs",
|
2021-01-03 20:54:45 +01:00
|
|
|
"systems/ds4/templates/actor/partials/profile.hbs",
|
2021-01-04 21:51:58 +01:00
|
|
|
"systems/ds4/templates/actor/partials/character-progression.hbs",
|
2020-12-28 20:38:02 +01:00
|
|
|
];
|
2020-12-23 16:52:20 +01:00
|
|
|
return loadTemplates(templatePaths);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* 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-12-30 01:03:06 +01:00
|
|
|
const toLocalize = [
|
|
|
|
"attackTypes",
|
|
|
|
"itemAvailabilities",
|
|
|
|
"itemTypes",
|
|
|
|
"armorTypes",
|
|
|
|
"armorTypesAbbr",
|
|
|
|
"armorMaterialTypes",
|
|
|
|
"armorMaterialTypesAbbr",
|
2020-12-30 00:35:18 +01:00
|
|
|
"armorMaterialTypes",
|
|
|
|
"attributes",
|
|
|
|
"traits",
|
|
|
|
"combatValues",
|
|
|
|
"baseInfo",
|
|
|
|
"progression",
|
2021-01-03 20:54:45 +01:00
|
|
|
"language",
|
|
|
|
"profile",
|
2020-12-30 01:03:06 +01:00
|
|
|
];
|
2020-12-23 16:52:20 +01:00
|
|
|
|
|
|
|
// Exclude some from sorting where the default order matters
|
2021-01-04 01:11:05 +01:00
|
|
|
const noSort = ["attributes", "traits", "combatValues"];
|
2020-12-23 16:52:20 +01:00
|
|
|
|
|
|
|
// Localize and sort CONFIG objects
|
2020-12-23 18:23:26 +01:00
|
|
|
for (const o of toLocalize) {
|
2020-12-23 16:52:20 +01:00
|
|
|
const localized = Object.entries(CONFIG.DS4[o]).map((e) => {
|
|
|
|
return [e[0], game.i18n.localize(e[1] as string)];
|
|
|
|
});
|
|
|
|
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;
|
|
|
|
}, {});
|
|
|
|
}
|
|
|
|
});
|