18 lines
597 B
TypeScript
18 lines
597 B
TypeScript
import { useEffect } from "react";
|
|
import { useEncounterContext } from "../contexts/encounter-context.js";
|
|
import { useSidePanelContext } from "../contexts/side-panel-context.js";
|
|
|
|
export function useAutoStatBlock(): void {
|
|
const { encounter } = useEncounterContext();
|
|
const { panelView, updateCreature } = useSidePanelContext();
|
|
|
|
const activeCreatureId =
|
|
encounter.combatants[encounter.activeIndex]?.creatureId;
|
|
|
|
useEffect(() => {
|
|
if (activeCreatureId && panelView.mode === "creature") {
|
|
updateCreature(activeCreatureId);
|
|
}
|
|
}, [activeCreatureId, panelView.mode, updateCreature]);
|
|
}
|