From 32fac517ad3c17d3e753c4ce6538c1230096e7a7 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 16 Mar 2021 07:42:00 +0100 Subject: [PATCH] Rename a few things --- src/lang/de.json | 2 +- src/lang/en.json | 2 +- src/module/ds4.ts | 4 ++-- src/module/hooks/hooks.ts | 6 +++--- src/module/hooks/hotbar-drop.ts | 6 +++--- src/module/macros/macros.ts | 4 ++-- src/module/macros/{item-macro.ts => roll-item-macro.ts} | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) rename src/module/macros/{item-macro.ts => roll-item-macro.ts} (85%) diff --git a/src/lang/de.json b/src/lang/de.json index 37e0236f..bf89e0fb 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -195,7 +195,7 @@ "DS4.ErrorUnexpectedAttackType": "Unerwartete Angriffsart '{actualType}', erwartete Angriffarten: {expectedTypes}", "DS4.ErrorCanvasIsNotInitialized": "Canvas ist noch nicht initialisiert.", "DS4.WarningItemMustBeEquippedToBeRolled": "Um für das Item '{name}' ({id}) vom Typ '{type}' zu würfeln, muss es ausgerüstet sein.", - "DS4.WarningMustControlActorToRollItemMacro": "Um ein Item Makro zu nutzen muss ein Aktor kontolliert werden.", + "DS4.WarningMustControlActorToUseRollItemMacro": "Um ein ein Item Würfel Makro zu nutzen muss ein Aktor kontolliert werden.", "DS4.WarningControlledActorDoesNotHaveItem": "Der kontrollierte Aktor '{actorName}' ({actorId}) hat kein Item mit der ID '{itemId}'.", "DS4.WarningItemIsNotRollable": "Für das Item '{name}' ({id}) vom Typ '{type}' kann nicht gewürfelt werden.", "DS4.WarningMacrosCanOnlyBeCreatedForOwnedItems": "Makros können nur für besessene Items angelegt werden.", diff --git a/src/lang/en.json b/src/lang/en.json index 7c9a511b..93011357 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -195,7 +195,7 @@ "DS4.ErrorUnexpectedAttackType": "Unexpected attack type '{actualType}', expected it to be one of: {expectedTypes}", "DS4.ErrorCanvasIsNotInitialized": "Canvas is not initialized yet.", "DS4.WarningItemMustBeEquippedToBeRolled": "To roll for item '{name}' ({id}) of type '{type}', it needs to be equipped.", - "DS4.WarningMustControlActorToRollItemMacro": "You must control an actor to be able to use an item macro.", + "DS4.WarningMustControlActorToUseRollItemMacro": "You must control an actor to be able to use a roll item macro.", "DS4.WarningControlledActorDoesNotHaveItem": "Your controlled actor '{actorName}' ({actorId}) does not have any item with the id '{itemId}'.", "DS4.WarningItemIsNotRollable": "Item '{name}' ({id}) of type '{type}' is not rollable.", "DS4.WarningMacrosCanOnlyBeCreatedForOwnedItems": "Macros can only be created for owned items.", diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 45619fc8..59904351 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -4,7 +4,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 registerHooks from "./hooks/hooks"; +import registerForHooks from "./hooks/hooks"; import { DS4Item } from "./item/item"; import { DS4ItemSheet } from "./item/item-sheet"; import { macros } from "./macros/macros"; @@ -53,7 +53,7 @@ Hooks.once("init", async () => { await registerHandlebarsPartials(); registerHandlebarsHelpers(); - registerHooks(); + registerForHooks(); }); /** diff --git a/src/module/hooks/hooks.ts b/src/module/hooks/hooks.ts index 3161b8f0..5b0da07c 100644 --- a/src/module/hooks/hooks.ts +++ b/src/module/hooks/hooks.ts @@ -1,5 +1,5 @@ -import registerHotbarHook from "./hotbar-drop"; +import registerForHotbarDropHook from "./hotbar-drop"; -export default function registerHooks(): void { - registerHotbarHook(); +export default function registerForHooks(): void { + registerForHotbarDropHook(); } diff --git a/src/module/hooks/hotbar-drop.ts b/src/module/hooks/hotbar-drop.ts index 9cd7b544..08657408 100644 --- a/src/module/hooks/hotbar-drop.ts +++ b/src/module/hooks/hotbar-drop.ts @@ -1,9 +1,9 @@ import { DS4Item } from "../item/item"; import { DS4ItemData } from "../item/item-data"; -import { createItemMacro } from "../macros/item-macro"; +import { createRollItemMacro } from "../macros/roll-item-macro"; import notifications from "../ui/notifications"; -export default function registerHotbarHook(): void { +export default function registerForHotbarDropHook(): void { Hooks.on("hotbarDrop", async (hotbar: Hotbar, data: { type: string } & Record, slot: string) => { switch (data.type) { case "Item": { @@ -21,7 +21,7 @@ export default function registerHotbarHook(): void { }), ); } - await createItemMacro(itemData, slot); + await createRollItemMacro(itemData, slot); } } }); diff --git a/src/module/macros/macros.ts b/src/module/macros/macros.ts index c4a13e3f..3b50c927 100644 --- a/src/module/macros/macros.ts +++ b/src/module/macros/macros.ts @@ -1,5 +1,5 @@ -import { rollItemMacro } from "./item-macro"; +import { rollItem } from "./roll-item-macro"; export const macros = { - rollItemMacro, + rollItem: rollItem, }; diff --git a/src/module/macros/item-macro.ts b/src/module/macros/roll-item-macro.ts similarity index 85% rename from src/module/macros/item-macro.ts rename to src/module/macros/roll-item-macro.ts index 0abc24f4..d321d45b 100644 --- a/src/module/macros/item-macro.ts +++ b/src/module/macros/roll-item-macro.ts @@ -9,8 +9,8 @@ import notifications from "../ui/notifications"; * @param itemData - The item data * @param slot - The hotbar slot to use */ -export async function createItemMacro(itemData: DS4ItemData, slot: string): Promise { - const command = `game.ds4.macros.rollItemMacro("${itemData._id}");`; +export async function createRollItemMacro(itemData: DS4ItemData, slot: string): Promise { + const command = `game.ds4.macros.rollItem("${itemData._id}");`; const macro = game.macros?.entities.find((m) => m.name === itemData.name && m.data.command === command) ?? (await Macro.create( @@ -30,14 +30,14 @@ export async function createItemMacro(itemData: DS4ItemData, slot: string): Prom * Execute the item macro for the given itemId. * @param itemId */ -export async function rollItemMacro(itemId: string): Promise { +export async function rollItem(itemId: string): Promise { const speaker = ChatMessage.getSpeaker(); const actor = (getCanvas().tokens.get(speaker.token ?? "")?.actor ?? game.actors?.get(speaker.actor ?? "")) as | DS4Actor | null | undefined; if (!actor) { - return notifications.warn(game.i18n.localize("DS4.WarningMustControlActorToRollItemMacro")); + return notifications.warn(game.i18n.localize("DS4.WarningMustControlActorToUseRollItemMacro")); } const item = actor.items?.get(itemId); if (!item) {