Update vtt types
This commit is contained in:
parent
623558dc78
commit
c57960c153
24 changed files with 144 additions and 107 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
import { Check } from "../actor/actor-data-properties";
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import notifications from "../ui/notifications";
|
||||
import { getActiveActor } from "./helpers";
|
||||
|
||||
|
@ -15,13 +16,15 @@ import { getActiveActor } from "./helpers";
|
|||
*/
|
||||
export async function createRollCheckMacro(check: Check, slot: string): Promise<void> {
|
||||
const macro = await getOrCreateRollCheckMacro(check);
|
||||
game.user?.assignHotbarMacro(macro ?? null, slot);
|
||||
getGame().user?.assignHotbarMacro(macro ?? null, slot);
|
||||
}
|
||||
|
||||
async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefined> {
|
||||
const command = `game.ds4.macros.rollCheck("${check}");`;
|
||||
const command = `getGame().ds4.macros.rollCheck("${check}");`;
|
||||
|
||||
const existingMacro = game.macros?.find((m) => m.name === DS4.i18n.checks[check] && m.data.command === command);
|
||||
const existingMacro = getGame().macros?.find(
|
||||
(m) => m.name === DS4.i18n.checks[check] && m.data.command === command,
|
||||
);
|
||||
if (existingMacro) {
|
||||
return existingMacro;
|
||||
}
|
||||
|
@ -44,7 +47,7 @@ async function getOrCreateRollCheckMacro(check: Check): Promise<Macro | undefine
|
|||
export async function rollCheck(check: Check): Promise<void> {
|
||||
const actor = getActiveActor();
|
||||
if (!actor) {
|
||||
return notifications.warn(game.i18n.localize("DS4.WarningMustControlActorToUseRollCheckMacro"));
|
||||
return notifications.warn(getGame().i18n.localize("DS4.WarningMustControlActorToUseRollCheckMacro"));
|
||||
}
|
||||
|
||||
return actor.rollCheck(check).catch((e) => notifications.error(e, { log: true }));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue