This repository has been archived on 2022-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
combatready_glass/combatreadythemes.ts

35 lines
981 B
TypeScript

import { registerLightMeter } from "./themes/light-meter/lightMeter";
export function getCanvas(): Canvas {
if (!(canvas instanceof Canvas) || !canvas.ready) {
throw new Error('Canvas Is Not Initialized');
}
return canvas;
}
export function getGame(): Game {
if (!(game instanceof Game)) {
throw new Error('Game Is Not Initialized');
}
return game;
}
export function getCombats(): CombatEncounters {
if (!(getGame().combats instanceof CombatEncounters)) {
throw new Error('CombatEncounters Is Not Initialized');
}
return <CombatEncounters>getGame().combats;
}
/**
* Ready hook
*/
Hooks.on("ready", function () {
//@ts-ignore
if (!(game.modules.get("combatready")?.active ?? false)) {
ui?.notifications?.notify('Please make sure you have the "Combat Ready!" module installed and enabled.', "error");
}
});
Hooks.on("combatready.ready", (CombatReadyAnimationTheme, CombatReadyTimer) => {
registerLightMeter(CombatReadyTimer);
});