Commit Graph

11 Commits

Author SHA1 Message Date
bridge
88cc7cd966 feat: add color to map avatar names 2026-01-11 18:54:34 +08:00
Zihao Xu
a1f08dd0ab feat: SQLite event storage with pagination and filtering
Implement SQLite-based event persistence as specified in sqlite-event-manager.md.

## Changes

### Backend
- **EventStorage** (`src/classes/event_storage.py`): New SQLite storage layer
  - Cursor-based pagination with compound cursor `{month_stamp}_{rowid}`
  - Avatar filtering (single and pair queries)
  - Major/minor event separation
  - Cleanup API with `keep_major` and `before_month_stamp` filters

- **EventManager** (`src/classes/event_manager.py`): Refactored to use SQLite
  - Delegates to EventStorage for persistence
  - Memory fallback mode for testing
  - New `get_events_paginated()` method

- **API** (`src/server/main.py`):
  - `GET /api/events` - Paginated event retrieval with filtering
  - `DELETE /api/events/cleanup` - User-triggered cleanup

### Frontend
- **EventPanel.vue**: Scroll-to-load pagination, dual-person filter UI
- **world.ts**: Event state management with pagination
- **game.ts**: New API client methods

### Testing
- 81 new tests for EventStorage, EventManager, and API
- Added `pytest-asyncio` and `httpx` to requirements.txt

## Known Issues: Save/Load is Currently Broken

After loading a saved game, the following issues occur:

1. **Wrong database used**: API returns events from the startup database instead
   of the loaded save's `_events.db` file
2. **Events from wrong time period**: Shows events from year 115 when loaded
   save is at year 114
3. **Pagination broken after load**: `has_more` returns `False` despite hundreds
   of events in the saved database
4. **Filter functionality broken**: Character selection filter stops working
   after loading a game

Root cause: `load_game.py` does not properly switch the EventManager's database
connection to the loaded save's events database.
2026-01-07 00:40:34 -08:00
Zihao Xu
fafe1b5997 feat: highlight avatar names with unique colors in event panel 2026-01-04 02:07:47 -08:00
bridge
198b652993 add event handler auto go down logic 2025-12-20 21:30:54 +08:00
bridge
3c586f936c add event handler auto go down logic 2025-12-20 21:25:57 +08:00
bridge
39f158bbe8 update death 2025-12-01 02:05:11 +08:00
bridge
4d245653a6 change order of events 2025-11-22 20:43:27 +08:00
bridge
d4e0fdacf3 refactor web code 2025-11-22 15:32:46 +08:00
bridge
077cb5978f update ai.txt 2025-11-22 01:41:34 +08:00
bridge
fcc67199ef refactor web 2025-11-21 01:52:53 +08:00
bridge
41d2103ffc refactor web 2025-11-21 01:38:41 +08:00