Move derived encounter flags into useEncounter() hook

Relocate isEmpty, hasCreatureCombatants, and canRollAllInitiative
from App.tsx into useEncounter(), reducing inline derivations in
the component (Phase 5 of App decomposition plan).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Lukas
2026-03-14 12:10:44 +01:00
parent 930301de71
commit 01f2bb3ff1
2 changed files with 14 additions and 8 deletions

View File

@@ -76,6 +76,9 @@ function useActionBarAnimation(combatantCount: number) {
export function App() {
const {
encounter,
isEmpty,
hasCreatureCombatants,
canRollAllInitiative,
advanceTurn,
retreatTurn,
addCombatant,
@@ -211,14 +214,6 @@ export function App() {
sidePanel.showCreature,
]);
const isEmpty = encounter.combatants.length === 0;
const hasCreatureCombatants = encounter.combatants.some(
(c) => c.creatureId != null,
);
const canRollAllInitiative = encounter.combatants.some(
(c) => c.creatureId != null && c.initiative == null,
);
return (
<div className="flex h-screen flex-col">
<div className="relative mx-auto flex w-full max-w-2xl flex-1 flex-col gap-3 px-4 min-h-0">