feat: implement stat system and StatsView

Introduces a comprehensive stat management system including:
- `/stat` command support (set, del, roll)
- `StatsView` component for displaying grouped stat tables
- Formula evaluation for derived stats (supporting arithmetic and
  functions)
- Stat definition parsing from YAML blocks
- Permission checking for stat modification based on roles
This commit is contained in:
2026-07-09 09:22:14 +08:00
parent 4faff9a391
commit 9747409a1f
9 changed files with 991 additions and 18 deletions
+7
View File
@@ -59,6 +59,12 @@ export interface JournalStreamState {
brokerUrl: string | null;
/** Active player list (keyed by player name) */
players: Record<string, { role: string }>;
/**
* Stat values set via /stat set/del/roll commands.
* Key: stat key (e.g. "strength", "alice:hp"). Value: string.
* Populated during hydration and live receipt via the stat type's reducer.
*/
stats: Record<string, string>;
}
export interface SessionMeta {
@@ -95,6 +101,7 @@ const [state, setState] = createStore<JournalStreamState>({
myRole: (persisted.myRole as "gm" | "player" | "observer") || "gm",
brokerUrl: persisted.brokerUrl,
players: {},
stats: {},
});
// Sync initial URL params if they came from localStorage (not URL)