Merge branch 'restructure' into 'main'
Restructure See merge request dungeonslayers/ds4!215
This commit is contained in:
commit
ebb2421952
98 changed files with 152 additions and 163 deletions
|
@ -78,7 +78,7 @@
|
|||
"@seald-io/nedb": "3.1.0",
|
||||
"@swc/core": "1.3.14",
|
||||
"@types/fs-extra": "9.0.13",
|
||||
"@types/node": "16.18.3",
|
||||
"@types/node": "18.11.9",
|
||||
"@typescript-eslint/eslint-plugin": "5.42.0",
|
||||
"@typescript-eslint/parser": "5.42.0",
|
||||
"conventional-changelog-cli": "2.2.2",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import evaluateCheck from "../../src/rolls/check-evaluation";
|
||||
import { evaluateCheck } from "../../src/dice/check-evaluation";
|
||||
|
||||
describe("evaluateCheck with no dice", () => {
|
||||
it("should throw an error.", () => {
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { calculateSpellPrice } from "../../../src/item/spell/calculate-spell-price";
|
||||
import { calculateSpellPrice } from "../../../../src/documents/item/spell/calculate-spell-price";
|
||||
|
||||
import type { CooldownDuration, DS4SpellDataSourceData } from "../../../src/item/spell/spell-data-source";
|
||||
import type { CooldownDuration, DS4SpellDataSourceData } from "../../../../src/documents/item/spell/spell-data-source";
|
||||
|
||||
const defaultData: DS4SpellDataSourceData = {
|
||||
description: "",
|
|
@ -5,18 +5,17 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActiveEffect } from "../active-effect/active-effect";
|
||||
import { disableOverriddenFields } from "../apps/sheet-helpers";
|
||||
import { DS4 } from "../config";
|
||||
import { getCanvas, getGame } from "../helpers";
|
||||
import { getDS4Settings } from "../settings";
|
||||
import notifications from "../ui/notifications";
|
||||
import { enforce } from "../utils";
|
||||
import { isCheck } from "./actor-data-properties-base";
|
||||
import { DS4 } from "../../config";
|
||||
import { DS4ActiveEffect } from "../../documents/active-effect";
|
||||
import { isCheck } from "../../documents/actor/actor-data-properties-base";
|
||||
import { getDS4Settings } from "../../settings";
|
||||
import { notifications } from "../../ui/notifications";
|
||||
import { enforce, getCanvas, getGame } from "../../utils/utils";
|
||||
import { disableOverriddenFields } from "../sheet-helpers";
|
||||
|
||||
import type { ModifiableDataBaseTotal } from "../common/common-data";
|
||||
import type { DS4Settings } from "../settings";
|
||||
import type { DS4Item } from "../item/item";
|
||||
import type { ModifiableDataBaseTotal } from "../../documents/common/common-data";
|
||||
import type { DS4Settings } from "../../settings";
|
||||
import type { DS4Item } from "../../documents/item/item";
|
||||
|
||||
/**
|
||||
* The base sheet class for all {@link DS4Actor}s.
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActorSheet } from "../actor-sheet";
|
||||
import { DS4ActorSheet } from "./base-sheet";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Character Actors
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActorSheet } from "../actor-sheet";
|
||||
import { DS4ActorSheet } from "./base-sheet";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Creature Actors
|
|
@ -4,13 +4,12 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActiveEffect } from "../active-effect/active-effect";
|
||||
import { disableOverriddenFields } from "../apps/sheet-helpers";
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import notifications from "../ui/notifications";
|
||||
import { enforce } from "../utils";
|
||||
import { isDS4ItemDataTypePhysical } from "./item-data-source-base";
|
||||
import { DS4ActiveEffect } from "../documents/active-effect";
|
||||
import { isDS4ItemDataTypePhysical } from "../documents/item/item-data-source-base";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { enforce, getGame } from "../utils/utils";
|
||||
import { disableOverriddenFields } from "./sheet-helpers";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Items
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
export function disableOverriddenFields(
|
||||
form: HTMLElement | null,
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
export default function evaluateCheck(
|
||||
export function evaluateCheck(
|
||||
dice: number[],
|
||||
checkTargetNumber: number,
|
||||
{
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { DialogWithListeners } from "../apps/dialog-with-listeners";
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
/**
|
||||
* Provides default values for all arguments the `CheckFactory` expects.
|
|
@ -3,8 +3,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import evaluateCheck, { getRequiredNumberOfDice } from "./check-evaluation";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { evaluateCheck, getRequiredNumberOfDice } from "./check-evaluation";
|
||||
|
||||
/**
|
||||
* Implements DS4 Checks as an emulated "dice throw".
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { DS4Check } from "./check";
|
||||
|
||||
export class DS4Roll<D extends Record<string, unknown> = Record<string, unknown>> extends Roll<D> {
|
|
@ -3,10 +3,10 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { DS4Check } from "./check";
|
||||
|
||||
export default function registerSlayingDiceModifier(): void {
|
||||
export function registerSlayingDiceModifier(): void {
|
||||
PoolTerm.MODIFIERS.x = slay;
|
||||
}
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { mathEvaluator } from "../expression-evaluation/evaluator";
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
import type { DS4Actor } from "../actor/actor";
|
||||
import type { DS4Item } from "../item/item";
|
||||
import type { DS4Actor } from "./actor/actor";
|
||||
import type { DS4Item } from "./item/item";
|
||||
|
||||
declare global {
|
||||
interface DocumentClassConfig {
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4 } from "../config";
|
||||
import { DS4 } from "../../config";
|
||||
|
||||
import type { ModifiableDataBaseTotal, ResourceDataBaseTotalMax } from "../common/common-data";
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4 } from "../config";
|
||||
import { DS4 } from "../../config";
|
||||
|
||||
import type { ModifiableData, ModifiableDataBase, ResourceData } from "../common/common-data";
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActiveEffect } from "../active-effect/active-effect";
|
||||
import { DS4 } from "../config";
|
||||
import { mathEvaluator } from "../expression-evaluation/evaluator";
|
||||
import { getGame } from "../helpers";
|
||||
import logger from "../logger";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
import { DS4 } from "../../config";
|
||||
import { createCheckRoll } from "../../dice/check-factory";
|
||||
import { mathEvaluator } from "../../expression-evaluation/evaluator";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { getGame } from "../../utils/utils";
|
||||
import { DS4ActiveEffect } from "../active-effect";
|
||||
import { isAttribute, isTrait } from "./actor-data-source-base";
|
||||
|
||||
import type { ModifiableDataBaseTotal } from "../common/common-data";
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../../config";
|
||||
import type { DS4 } from "../../../config";
|
||||
import type { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
|
||||
|
||||
export interface DS4CreatureDataSource {
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../../utils/utils";
|
||||
import { DS4Actor } from "./actor";
|
||||
import { DS4Character } from "./character/character";
|
||||
import { DS4Creature } from "./creature/creature";
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "./helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
declare global {
|
||||
interface FlagConfig {
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../../config";
|
||||
import type { DS4 } from "../../../config";
|
||||
import type {
|
||||
DS4ItemDataSourceDataBase,
|
||||
DS4ItemDataSourceDataEquipable,
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../config";
|
||||
import type { DS4 } from "../../config";
|
||||
|
||||
export interface DS4ItemDataSourceDataBase {
|
||||
description: string;
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../config";
|
||||
import type { DS4 } from "../../config";
|
||||
import type { DS4AlphabetDataSource } from "./alphabet/alphabet-data-source";
|
||||
import type { DS4ArmorDataSource } from "./armor/armor-data-source";
|
||||
import type { DS4EquipmentDataSource } from "./equipment/equipment-data-source";
|
|
@ -3,8 +3,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActiveEffect } from "../active-effect/active-effect";
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../../utils/utils";
|
||||
import { DS4ActiveEffect } from "../active-effect";
|
||||
|
||||
import type { ItemType } from "./item-data-source";
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../../utils/utils";
|
||||
import { DS4Alphabet } from "./alphabet/alphabet";
|
||||
import { DS4Armor } from "./armor/armor";
|
||||
import { DS4Equipment } from "./equipment/equipment";
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../../config";
|
||||
import type { DS4 } from "../../../config";
|
||||
import type { DS4ItemDataSourceDataBase, DS4ItemDataSourceDataEquipable } from "../item-data-source-base";
|
||||
|
||||
export interface DS4SpellDataSource {
|
|
@ -2,9 +2,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../../helpers";
|
||||
import { createCheckRoll } from "../../rolls/check-factory";
|
||||
import notifications from "../../ui/notifications";
|
||||
import { createCheckRoll } from "../../../dice/check-factory";
|
||||
import { notifications } from "../../../ui/notifications";
|
||||
import { getGame } from "../../../utils/utils";
|
||||
import { DS4Item } from "../item";
|
||||
import { calculateSpellPrice } from "./calculate-spell-price";
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import type { DS4 } from "../../config";
|
||||
import type { DS4 } from "../../../config";
|
||||
import type {
|
||||
DS4ItemDataSourceDataBase,
|
||||
DS4ItemDataSourceDataEquipable,
|
|
@ -2,10 +2,10 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4 } from "../../config";
|
||||
import { getGame } from "../../helpers";
|
||||
import { createCheckRoll } from "../../rolls/check-factory";
|
||||
import notifications from "../../ui/notifications";
|
||||
import { DS4 } from "../../../config";
|
||||
import { createCheckRoll } from "../../../dice/check-factory";
|
||||
import { notifications } from "../../../ui/notifications";
|
||||
import { getGame } from "../../../utils/utils";
|
||||
import { DS4Item } from "../item";
|
||||
|
||||
import type { AttackType } from "./weapon-data-source";
|
|
@ -2,8 +2,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../utils/utils";
|
||||
import { DS4ActorProxy } from "./actor/proxy";
|
||||
import { getGame } from "./helpers";
|
||||
|
||||
let fallbackData: foundry.data.ActorData["data"] | undefined = undefined;
|
||||
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
import "../scss/ds4.scss";
|
||||
|
||||
import registerForHooks from "./hooks/hooks";
|
||||
import { registerForHooks } from "./hooks/hooks";
|
||||
|
||||
registerForHooks();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export default function registerHandlebarsHelpers(): void {
|
||||
export function registerHandlebarsHelpers(): void {
|
||||
Handlebars.registerHelper(helpers);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export default async function registerHandlebarsPartials(): Promise<void> {
|
||||
export async function registerHandlebarsPartials(): Promise<void> {
|
||||
const templatePaths = [
|
||||
"systems/ds4/templates/sheets/actor/components/actor-header.hbs",
|
||||
"systems/ds4/templates/sheets/actor/components/actor-progression.hbs",
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export function getCanvas(): Canvas {
|
||||
if (!(canvas instanceof Canvas) || !canvas.ready) {
|
||||
throw new Error(getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"));
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
|
||||
export function getGame(): Game {
|
||||
if (!(game instanceof Game)) {
|
||||
throw new Error("Game is not initialized yet."); // Cannot localize this as we would need to access game to do this.
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
export function getGameSafe(): Game | undefined {
|
||||
return game instanceof Game ? game : undefined;
|
||||
}
|
|
@ -2,13 +2,13 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import registerForHotbarDropHook from "./hotbar-drop";
|
||||
import registerForInitHook from "./init";
|
||||
import registerForReadyHook from "./ready";
|
||||
import registerForRenderHooks from "./render";
|
||||
import registerForSetupHook from "./setup";
|
||||
import { registerForHotbarDropHook } from "./hotbar-drop";
|
||||
import { registerForInitHook } from "./init";
|
||||
import { registerForReadyHook } from "./ready";
|
||||
import { registerForRenderHooks } from "./render";
|
||||
import { registerForSetupHook } from "./setup";
|
||||
|
||||
export default function registerForHooks(): void {
|
||||
export function registerForHooks(): void {
|
||||
registerForHotbarDropHook();
|
||||
registerForInitHook();
|
||||
registerForReadyHook();
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { isCheck } from "../actor/actor-data-properties-base";
|
||||
import { getGame } from "../helpers";
|
||||
import { DS4Item } from "../item/item";
|
||||
import { isCheck } from "../documents/actor/actor-data-properties-base";
|
||||
import { DS4Item } from "../documents/item/item";
|
||||
import { createRollCheckMacro } from "../macros/roll-check";
|
||||
import { createRollItemMacro } from "../macros/roll-item";
|
||||
import notifications from "../ui/notifications";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
export default function registerForHotbarDropHook(): void {
|
||||
export function registerForHotbarDropHook(): void {
|
||||
Hooks.on("hotbarDrop", async (hotbar: Hotbar, data: HotbarDropData, slot: string) => {
|
||||
switch (data.type) {
|
||||
case "Item": {
|
||||
|
|
|
@ -4,33 +4,33 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4ActiveEffect } from "../active-effect/active-effect";
|
||||
import { DS4ActiveEffectConfig } from "../active-effect/active-effect-config";
|
||||
import { DS4CharacterActorSheet } from "../actor/character/character-sheet";
|
||||
import { DS4CreatureActorSheet } from "../actor/creature/creature-sheet";
|
||||
import { DS4ActorProxy } from "../actor/proxy";
|
||||
import { DS4ChatMessage } from "../chat-message";
|
||||
import { DS4ActiveEffectConfig } from "../apps/active-effect-config";
|
||||
import { DS4CharacterActorSheet } from "../apps/actor/character-sheet";
|
||||
import { DS4CreatureActorSheet } from "../apps/actor/creature-sheet";
|
||||
import { DS4ItemSheet } from "../apps/item-sheet";
|
||||
import { DS4 } from "../config";
|
||||
import { preloadFonts } from "../fonts";
|
||||
import registerHandlebarsHelpers from "../handlebars/handlebars-helpers";
|
||||
import registerHandlebarsPartials from "../handlebars/handlebars-partials";
|
||||
import { getGame } from "../helpers";
|
||||
import { DS4ItemSheet } from "../item/item-sheet";
|
||||
import { DS4ItemProxy } from "../item/proxy";
|
||||
import logger from "../logger";
|
||||
import { DS4Check } from "../dice/check";
|
||||
import { createCheckRoll } from "../dice/check-factory";
|
||||
import { DS4Roll } from "../dice/roll";
|
||||
import { registerSlayingDiceModifier } from "../dice/slaying-dice-modifier";
|
||||
import { DS4ActiveEffect } from "../documents/active-effect";
|
||||
import { DS4ActorProxy } from "../documents/actor/proxy";
|
||||
import { DS4ChatMessage } from "../documents/chat-message";
|
||||
import { DS4ItemProxy } from "../documents/item/proxy";
|
||||
import { DS4TokenDocument } from "../documents/token-document";
|
||||
import { registerHandlebarsHelpers } from "../handlebars/handlebars-helpers";
|
||||
import { registerHandlebarsPartials } from "../handlebars/handlebars-partials";
|
||||
import { macros } from "../macros/macros";
|
||||
import { migration } from "../migrations";
|
||||
import { DS4Check } from "../rolls/check";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
import { DS4Roll } from "../rolls/roll";
|
||||
import registerSlayingDiceModifier from "../rolls/slaying-dice-modifier";
|
||||
import { migration } from "../migration/migration";
|
||||
import { registerSystemSettings } from "../settings";
|
||||
import { DS4TokenDocument } from "../token-document";
|
||||
import { preloadFonts } from "../ui/fonts";
|
||||
import { logger } from "../utils/logger";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
import type { DS4Actor } from "../actor/actor";
|
||||
import type { DS4Item } from "../item/item";
|
||||
import type { DS4Actor } from "../documents/actor/actor";
|
||||
import type { DS4Item } from "../documents/item/item";
|
||||
|
||||
export default function registerForInitHook(): void {
|
||||
export function registerForInitHook(): void {
|
||||
Hooks.once("init", init);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { migration } from "../migrations";
|
||||
import { migration } from "../migration/migration";
|
||||
|
||||
export default function registerForReadyHook(): void {
|
||||
export function registerForReadyHook(): void {
|
||||
Hooks.once("ready", () => {
|
||||
migration.migrate();
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* @remarks The render hooks of all classes in the class hierarchy are called, so e.g. for a {@link Dialog}, both the
|
||||
* "renderDialog" hook and the "renderApplication" hook are called (in this order).
|
||||
*/
|
||||
export default function registerForRenderHooks(): void {
|
||||
export function registerForRenderHooks(): void {
|
||||
["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hook) => {
|
||||
Hooks.on(hook, selectTargetInputOnFocus);
|
||||
});
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
export default function registerForSetupHooks(): void {
|
||||
export function registerForSetupHook(): void {
|
||||
Hooks.once("setup", () => {
|
||||
localizeAndSortConfigObjects();
|
||||
});
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getCanvas, getGame } from "../helpers";
|
||||
import { getCanvas, getGame } from "../utils/utils";
|
||||
|
||||
import type { DS4Actor } from "../actor/actor";
|
||||
import type { DS4Actor } from "../documents/actor/actor";
|
||||
|
||||
/**
|
||||
* Gets the currently active actor and token based on how {@link ChatMessage}
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import notifications from "../ui/notifications";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { getActiveActorAndToken } from "./helpers";
|
||||
|
||||
import type { Check } from "../actor/actor-data-properties-base";
|
||||
import type { Check } from "../documents/actor/actor-data-properties-base";
|
||||
/**
|
||||
* Creates a macro from a check drop.
|
||||
* Get an existing roll check macro if one exists, otherwise create a new one.
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import notifications from "../ui/notifications";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { getActiveActorAndToken } from "./helpers";
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "../helpers";
|
||||
import notifications from "../ui/notifications";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { getActiveActorAndToken } from "./helpers";
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
migrateScenes,
|
||||
} from "./migrationHelpers";
|
||||
|
||||
import type { DS4SpellDataSourceData } from "../item/spell/spell-data-source";
|
||||
import type { DS4SpellDataSourceData } from "../documents/item/spell/spell-data-source";
|
||||
|
||||
async function migrate(): Promise<void> {
|
||||
await migrateItems(getItemUpdateData);
|
|
@ -2,15 +2,15 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "./helpers";
|
||||
import logger from "./logger";
|
||||
import { migration as migration001 } from "./migrations/001";
|
||||
import { migration as migration002 } from "./migrations/002";
|
||||
import { migration as migration003 } from "./migrations/003";
|
||||
import { migration as migration004 } from "./migrations/004";
|
||||
import { migration as migration005 } from "./migrations/005";
|
||||
import { migration as migration006 } from "./migrations/006";
|
||||
import notifications from "./ui/notifications";
|
||||
import { notifications } from "../ui/notifications";
|
||||
import { logger } from "../utils/logger";
|
||||
import { getGame } from "../utils/utils";
|
||||
import { migration as migration001 } from "./001";
|
||||
import { migration as migration002 } from "./002";
|
||||
import { migration as migration003 } from "./003";
|
||||
import { migration as migration004 } from "./004";
|
||||
import { migration as migration005 } from "./005";
|
||||
import { migration as migration006 } from "./006";
|
||||
|
||||
async function migrate(): Promise<void> {
|
||||
if (!getGame().user?.isGM) {
|
|
@ -2,10 +2,10 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { DS4Actor } from "../actor/actor";
|
||||
import { getGame } from "../helpers";
|
||||
import { DS4Item } from "../item/item";
|
||||
import logger from "../logger";
|
||||
import { DS4Actor } from "../documents/actor/actor";
|
||||
import { DS4Item } from "../documents/item/item";
|
||||
import { logger } from "../utils/logger";
|
||||
import { getGame } from "../utils/utils";
|
||||
|
||||
type ItemUpdateDataGetter = (
|
||||
itemData: Partial<foundry.data.ItemData["_source"]>,
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGame } from "./helpers";
|
||||
import { getGame } from "./utils/utils";
|
||||
|
||||
export function registerSystemSettings(): void {
|
||||
const game = getGame();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import logger from "../logger";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
function getNotificationFunction(type: "info" | "warn" | "error") {
|
||||
return (message: string, { permanent = false, log = false }: { permanent?: boolean; log?: boolean } = {}): void => {
|
||||
|
@ -17,7 +17,7 @@ function getNotificationFunction(type: "info" | "warn" | "error") {
|
|||
};
|
||||
}
|
||||
|
||||
const notifications = {
|
||||
export const notifications = Object.freeze({
|
||||
info: getNotificationFunction("info"),
|
||||
warn: getNotificationFunction("warn"),
|
||||
error: getNotificationFunction("error"),
|
||||
|
@ -35,6 +35,4 @@ const notifications = {
|
|||
logger.getLoggingFunction(type)(message);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default notifications;
|
||||
});
|
||||
|
|
|
@ -13,12 +13,10 @@ const getLoggingFunction = (type: LogLevel = "info"): LoggingFunction => {
|
|||
return (...data: unknown[]) => log(loggingContext, loggingSeparator, ...data);
|
||||
};
|
||||
|
||||
const logger = Object.freeze({
|
||||
export const logger = Object.freeze({
|
||||
debug: getLoggingFunction("debug"),
|
||||
info: getLoggingFunction("info"),
|
||||
warn: getLoggingFunction("warning"),
|
||||
error: getLoggingFunction("error"),
|
||||
getLoggingFunction,
|
||||
});
|
||||
|
||||
export default logger;
|
|
@ -2,8 +2,6 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { getGameSafe } from "./helpers";
|
||||
|
||||
/**
|
||||
* Tests if the given `value` is truthy.
|
||||
*
|
||||
|
@ -22,3 +20,21 @@ export function enforce(value: unknown, message?: string | Error): asserts value
|
|||
throw message instanceof Error ? message : new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function getCanvas(): Canvas {
|
||||
if (!(canvas instanceof Canvas) || !canvas.ready) {
|
||||
throw new Error(getGame().i18n.localize("DS4.ErrorCanvasIsNotInitialized"));
|
||||
}
|
||||
return canvas;
|
||||
}
|
||||
|
||||
export function getGame(): Game {
|
||||
if (!(game instanceof Game)) {
|
||||
throw new Error("Game is not initialized yet.");
|
||||
}
|
||||
return game;
|
||||
}
|
||||
|
||||
export function getGameSafe(): Game | undefined {
|
||||
return game instanceof Game ? game : undefined;
|
||||
}
|
10
yarn.lock
10
yarn.lock
|
@ -1209,10 +1209,10 @@ __metadata:
|
|||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/node@npm:16.18.3":
|
||||
version: 16.18.3
|
||||
resolution: "@types/node@npm:16.18.3"
|
||||
checksum: 6b8ba2ea5d842f7986e366cb9184c54d273d492784dc62e08fd5afeae938d9b61aec6e4222d2541cd18f9b1412ba361bbcb3f4204fb003608af80a2a6af959f9
|
||||
"@types/node@npm:18.11.9":
|
||||
version: 18.11.9
|
||||
resolution: "@types/node@npm:18.11.9"
|
||||
checksum: cc0aae109e9b7adefc32eecb838d6fad931663bb06484b5e9cbbbf74865c721b03d16fd8d74ad90e31dbe093d956a7c2c306ba5429ba0c00f3f7505103d7a496
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
@ -2553,7 +2553,7 @@ __metadata:
|
|||
"@seald-io/nedb": 3.1.0
|
||||
"@swc/core": 1.3.14
|
||||
"@types/fs-extra": 9.0.13
|
||||
"@types/node": 16.18.3
|
||||
"@types/node": 18.11.9
|
||||
"@typescript-eslint/eslint-plugin": 5.42.0
|
||||
"@typescript-eslint/parser": 5.42.0
|
||||
conventional-changelog-cli: 2.2.2
|
||||
|
|
Loading…
Reference in a new issue