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;
|
color: string;
|
||||||
luck_token: number;
|
luck_token: number;
|
||||||
torch_lit_at: string | null;
|
torch_lit_at: string | null;
|
||||||
|
is_dead: boolean;
|
||||||
stats: Stat[];
|
stats: Stat[];
|
||||||
gear: Gear[];
|
gear: Gear[];
|
||||||
talents: Talent[];
|
talents: Talent[];
|
||||||
|
conditions: Condition[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GameItem {
|
export interface GameItem {
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,17 @@ async function enrichCharacters(characters: RowDataPacket[]) {
|
||||||
"SELECT * FROM character_talents WHERE character_id = ?",
|
"SELECT * FROM character_talents WHERE character_id = ?",
|
||||||
[char.id]
|
[char.id]
|
||||||
);
|
);
|
||||||
|
const [conditions] = await db.execute<RowDataPacket[]>(
|
||||||
|
"SELECT * FROM character_conditions WHERE character_id = ?",
|
||||||
|
[char.id]
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...char,
|
...char,
|
||||||
overrides: parseJson(char.overrides),
|
overrides: parseJson(char.overrides),
|
||||||
stats,
|
stats,
|
||||||
gear: parseGear(gear),
|
gear: parseGear(gear),
|
||||||
talents: parseTalents(talents),
|
talents: parseTalents(talents),
|
||||||
|
conditions,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
@ -216,10 +221,14 @@ router.patch("/:id", requireAuth, async (req, res) => {
|
||||||
"SELECT * FROM characters WHERE id = ?",
|
"SELECT * FROM characters WHERE id = ?",
|
||||||
[id]
|
[id]
|
||||||
);
|
);
|
||||||
|
const [conditions] = await db.execute<RowDataPacket[]>(
|
||||||
|
"SELECT * FROM character_conditions WHERE character_id = ?",
|
||||||
|
[id]
|
||||||
|
);
|
||||||
const enriched = {
|
const enriched = {
|
||||||
...rows[0],
|
...rows[0],
|
||||||
overrides: parseJson(rows[0].overrides),
|
overrides: parseJson(rows[0].overrides),
|
||||||
|
conditions,
|
||||||
};
|
};
|
||||||
|
|
||||||
const io: Server = req.app.get("io");
|
const io: Server = req.app.get("io");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue