From a280cef87530b4bec0f0082b8e2a8cbc5ee003da Mon Sep 17 00:00:00 2001 From: Aaron Wood Date: Sun, 12 Apr 2026 01:19:45 -0400 Subject: [PATCH] feat: include conditions in character responses; add is_dead + conditions to Character type Enriches enrichCharacters() and the PATCH handler to fetch and return character_conditions rows, ensuring character:updated socket broadcasts carry up-to-date dying/condition state. Adds is_dead and conditions fields to the client Character interface. Co-Authored-By: Claude Sonnet 4.6 --- client/src/types.ts | 2 ++ server/src/routes/characters.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/types.ts b/client/src/types.ts index fe40c66..0b2477e 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -57,9 +57,11 @@ export interface Character { color: string; luck_token: number; torch_lit_at: string | null; + is_dead: boolean; stats: Stat[]; gear: Gear[]; talents: Talent[]; + conditions: Condition[]; } export interface GameItem { diff --git a/server/src/routes/characters.ts b/server/src/routes/characters.ts index 974c256..1897dff 100644 --- a/server/src/routes/characters.ts +++ b/server/src/routes/characters.ts @@ -63,12 +63,17 @@ async function enrichCharacters(characters: RowDataPacket[]) { "SELECT * FROM character_talents WHERE character_id = ?", [char.id] ); + const [conditions] = await db.execute( + "SELECT * FROM character_conditions WHERE character_id = ?", + [char.id] + ); return { ...char, overrides: parseJson(char.overrides), stats, gear: parseGear(gear), talents: parseTalents(talents), + conditions, }; }) ); @@ -216,10 +221,14 @@ router.patch("/:id", requireAuth, async (req, res) => { "SELECT * FROM characters WHERE id = ?", [id] ); - + const [conditions] = await db.execute( + "SELECT * FROM character_conditions WHERE character_id = ?", + [id] + ); const enriched = { ...rows[0], overrides: parseJson(rows[0].overrides), + conditions, }; const io: Server = req.app.get("io");