Implement the 023-clear-encounter feature that adds a clear encounter button with confirmation dialog to remove all combatants and reset round/turn counters, with the cleared state persisting across page refreshes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,16 @@ export function loadEncounter(): Encounter | null {
|
||||
if (typeof obj.roundNumber !== "number") return null;
|
||||
|
||||
const combatants = obj.combatants as unknown[];
|
||||
|
||||
// Handle empty encounter (cleared state) directly — createEncounter rejects empty arrays
|
||||
if (combatants.length === 0) {
|
||||
return {
|
||||
combatants: [],
|
||||
activeIndex: 0,
|
||||
roundNumber: 1,
|
||||
};
|
||||
}
|
||||
|
||||
for (const c of combatants) {
|
||||
if (typeof c !== "object" || c === null || Array.isArray(c)) return null;
|
||||
const entry = c as Record<string, unknown>;
|
||||
|
||||
Reference in New Issue
Block a user