8da834c5c1
Games now have a status/ended_reason pair. The DM can call the new end_game tool when the story reaches a real conclusion (victory, defeat, or a resolved one-shot), and the backend independently ends the game whenever a character's HP drops to 0 or below, regardless of whether the DM narrates it. The frontend shows a banner and a "Beendet" badge once a game ends. HP moves from the freeform combat_stats bag into dedicated current_hp/max_hp columns on Character, since reliably detecting 0 HP requires a real integer rather than parsing strings like "3/10" out of an LLM-authored key/value dict. Also fixed combat_stats to fully replace on each upsert instead of merging, matching its documented contract — the merge was leaving stale keys (old HP/TP text) behind after the model stopped sending them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
31 lines
626 B
Python
31 lines
626 B
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class GameCreate(BaseModel):
|
|
name: str
|
|
description: str = ""
|
|
|
|
|
|
class GameRead(BaseModel):
|
|
id: uuid.UUID
|
|
name: str
|
|
description: str
|
|
creator_id: uuid.UUID
|
|
creator_name: str
|
|
player_count: int
|
|
player_names: list[str]
|
|
participation_code: str | None # only populated for the creator
|
|
created_at: datetime
|
|
is_participant: bool
|
|
my_character_id: uuid.UUID | None
|
|
status: str
|
|
ended_reason: str | None
|
|
|
|
|
|
class GameJoin(BaseModel):
|
|
participation_code: str
|
|
character_id: uuid.UUID | None = None
|