Commit Graph

97 Commits

Author SHA1 Message Date
bridge
488758764e fix pytest for new awaken avatars 2026-01-11 21:03:02 +08:00
bridge
58486f95e8 fix pytest bugs 2026-01-08 20:22:03 +08:00
Zihao Xu
06d1bed987 fix: integrate SQLite event storage into load/save system
- Fix load_game to use World.create_with_db() for SQLite event storage
- Add get_events_db_path() to compute event database path from save path
- Add JSON to SQLite migration for backward compatibility with old saves
- Close old EventManager before loading new save to prevent connection leaks
- Add events_db metadata to save file
- Add comprehensive tests for database switching bug and save/load cycle
2026-01-07 23:22:17 -08:00
Zihao Xu
a6b8198c3f Merge branch 'main' into xzhseh/sqlite-event-manager 2026-01-07 20:05:02 -08:00
bridge
b2a021bf8a rename item -> material & refactor buying action 2026-01-07 22:43:26 +08:00
Zihao Xu
37518342fc fix: prevent character age from exceeding realm lifespan on creation 2026-01-07 01:08:12 -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
bridge
e4ff312f58 fix action being executed 3 times bug 2026-01-06 23:41:21 +08:00
bridge
fbb32adbf6 refactor normalize and resolution 2026-01-06 22:13:47 +08:00
bridge
b60481c99c fix death bug 2026-01-06 21:23:06 +08:00
bridge
3f980d4593 fix a bug 2026-01-06 20:42:53 +08:00
bridge
8d7e11b021 add elixir 2026-01-05 23:04:55 +08:00
bridge
2a68f352bc add elixir 2026-01-05 22:26:16 +08:00
Zihao Xu
8c8e28264f fix: handle null action_params from LLM response
LLM sometimes returns null instead of {} for action_params when an
action doesn't require parameters (e.g., ["Cultivate", null]). This
caused AttributeError when calling .items() on None.

Changes:
- Add defensive check in ai.py to convert null to {}
- Update prompt to explicitly require {} instead of null
2026-01-05 01:36:50 -08:00
bridge
b74014f9f2 add emotion 2026-01-04 22:49:20 +08:00
bridge
5b5cd79cb5 add circulation manager 2026-01-03 22:15:25 +08:00
bridge
f499f63c50 update 2026-01-03 22:05:45 +08:00
bridge
7197dd1acb refactor equip 2025-12-31 23:18:47 +08:00
bridge
17ca0cbbce add misfortune 2025-12-30 23:09:29 +08:00
bridge
6a4059280a refactor death 2025-12-29 21:46:26 +08:00
bridge
6e380f1161 remove mp 2025-12-22 00:30:09 +08:00
bridge
162ea8efe2 refactor llm 2025-12-20 22:13:26 +08:00
bridge
e8489fcc25 fix bugs 2025-12-20 21:43:18 +08:00
bridge
3c586f936c add event handler auto go down logic 2025-12-20 21:25:57 +08:00
bridge
57c669be47 fix bugs 2025-12-20 21:16:09 +08:00
bridge
8fb81c3473 refactor relation add and cancel 2025-12-20 20:30:30 +08:00
bridge
3d117c2fb2 fix tile region = none bug 2025-12-20 19:26:53 +08:00
bridge
3ca5333246 fix save bugs 2025-12-15 00:12:21 +08:00
bridge
30a10bbb1c add pytest 2025-12-14 15:13:48 +08:00
bridge
6b0bf25699 fix pngs 2025-12-14 14:59:25 +08:00
bridge
a51f0a0ad2 add occupy action 2025-12-10 22:48:52 +08:00
bridge
5590b83487 add occupy action 2025-12-10 22:34:14 +08:00
bridge
303bffe413 decide only one avatar each time 2025-12-08 22:08:53 +08:00
bridge
31ab56251b refactor map 2025-12-02 23:00:09 +08:00
bridge
39f158bbe8 update death 2025-12-01 02:05:11 +08:00
bridge
1aaa4d4094 add relationship in front 2025-12-01 01:16:02 +08:00
bridge
a5d2b192fe update relationship 2025-12-01 01:03:10 +08:00
bridge
d7549d7d32 update celestial phenon 2025-11-29 13:30:06 +08:00
bridge
796f48315f refactor sect in vue 2025-11-27 21:46:42 +08:00
bridge
7980fc0705 add battle to death 2025-11-26 19:00:07 +08:00
bridge
bb8614407d refactor nickname 2025-11-26 15:22:48 +08:00
bridge
6c941c2393 refactor new avatar 2025-11-25 01:12:06 +08:00
bridge
8f3f095c27 refactor new avatars 2025-11-25 01:06:56 +08:00
bridge
ebd4f8be18 add new avatar button and func 2025-11-25 00:17:12 +08:00
bridge
5dc137837b update 2025-11-22 22:06:28 +08:00
bridge
befd158c46 fix bug 2025-11-22 20:56:41 +08:00
bridge
9634ace682 fix bug 2025-11-22 18:49:15 +08:00
bridge
5aaf6abcbb fix bug 2025-11-22 16:56:03 +08:00
bridge
d2cf568154 add long term objective 2025-11-19 00:04:38 +08:00
bridge
c1963beef2 add nickname 2025-11-18 01:23:43 +08:00