Rename a few things

This commit is contained in:
Johannes Loher 2021-03-16 07:42:00 +01:00
parent 67d0253f66
commit 32fac517ad
7 changed files with 16 additions and 16 deletions

View file

@ -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.",

View file

@ -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.",

View file

@ -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();
});
/**

View file

@ -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();
}

View file

@ -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<string, unknown>, slot: string) => {
switch (data.type) {
case "Item": {
@ -21,7 +21,7 @@ export default function registerHotbarHook(): void {
}),
);
}
await createItemMacro(itemData, slot);
await createRollItemMacro(itemData, slot);
}
}
});

View file

@ -1,5 +1,5 @@
import { rollItemMacro } from "./item-macro";
import { rollItem } from "./roll-item-macro";
export const macros = {
rollItemMacro,
rollItem: rollItem,
};

View file

@ -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<void> {
const command = `game.ds4.macros.rollItemMacro("${itemData._id}");`;
export async function createRollItemMacro(itemData: DS4ItemData, slot: string): Promise<void> {
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<void> {
export async function rollItem(itemId: string): Promise<void> {
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) {