Update vtt types

This commit is contained in:
Johannes Loher 2021-07-07 19:22:35 +02:00
parent 623558dc78
commit c57960c153
24 changed files with 144 additions and 107 deletions

View file

@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT
import { isCheck } from "../actor/actor-data-properties";
import { getGame } from "../helpers";
import { DS4Item } from "../item/item";
import { createRollCheckMacro } from "../macros/roll-check";
import { createRollItemMacro } from "../macros/roll-item";
@ -13,13 +14,15 @@ export default function registerForHotbarDropHook(): void {
switch (data.type) {
case "Item": {
if (!isItemDropData(data) || !("data" in data)) {
return notifications.warn(game.i18n.localize("DS4.WarningMacrosCanOnlyBeCreatedForOwnedItems"));
return notifications.warn(
getGame().i18n.localize("DS4.WarningMacrosCanOnlyBeCreatedForOwnedItems"),
);
}
const itemData = data.data;
if (!DS4Item.rollableItemTypes.includes(itemData.type)) {
return notifications.warn(
game.i18n.format("DS4.WarningItemIsNotRollable", {
getGame().i18n.format("DS4.WarningItemIsNotRollable", {
name: itemData.name,
id: itemData._id,
type: itemData.type,
@ -30,7 +33,7 @@ export default function registerForHotbarDropHook(): void {
}
case "Check": {
if (!("data" in data) || typeof data.data !== "string" || !isCheck(data.data)) {
return notifications.warn(game.i18n.localize("DS4.WarningInvalidCheckDropped"));
return notifications.warn(getGame().i18n.localize("DS4.WarningInvalidCheckDropped"));
}
return createRollCheckMacro(data.data, slot);
}

View file

@ -10,6 +10,7 @@ import { DS4CreatureActorSheet } from "../actor/sheets/creature-sheet";
import { DS4 } from "../config";
import registerHandlebarsHelpers from "../handlebars/handlebars-helpers";
import registerHandlebarsPartials from "../handlebars/handlebars-partials";
import { getGame } from "../helpers";
import { DS4Item } from "../item/item";
import { DS4ItemSheet } from "../item/item-sheet";
import logger from "../logger";
@ -28,7 +29,7 @@ export default function registerForInitHook(): void {
async function init() {
logger.info(`Initializing the DS4 Game System\n${DS4.ASCII}`);
game.ds4 = {
getGame().ds4 = {
DS4Actor,
DS4Item,
DS4,

View file

@ -6,6 +6,7 @@
// SPDX-License-Identifier: MIT
import { DS4 } from "../config";
import { getGame } from "../helpers";
export default function registerForSetupHooks(): void {
Hooks.once("setup", () => {
@ -21,7 +22,7 @@ function localizeAndSortConfigObjects() {
const localizeObject = <T extends { [s: string]: string }>(obj: T, sort = true): T => {
const localized = Object.entries(obj).map(([key, value]) => {
return [key, game.i18n.localize(value)];
return [key, getGame().i18n.localize(value)];
});
if (sort) localized.sort((a, b) => a[1].localeCompare(b[1]));
return Object.fromEntries(localized);