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 <noreply@anthropic.com>
This commit is contained in:
parent
89a9e85a4b
commit
a280cef875
2 changed files with 12 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -63,12 +63,17 @@ async function enrichCharacters(characters: RowDataPacket[]) {
|
|||
"SELECT * FROM character_talents WHERE character_id = ?",
|
||||
[char.id]
|
||||
);
|
||||
const [conditions] = await db.execute<RowDataPacket[]>(
|
||||
"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<RowDataPacket[]>(
|
||||
"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");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue