# Quest module

## Model

- quests are event-driven
- user progress is stored in `user_quests`
- completion is automatic once progress reaches the quest target

## Main methods

- `assignQuest()`
- `updateProgress()`
- `handleEvent()`
- `completeQuest()`
- `getUserQuests()`
- `getAvailableQuests()`
- `createQuest()`
- `getAllQuests()`
- `deleteQuest()`
- `updateQuest()`

## Rules

- max active quests comes from `gameSettingsService`
- `assignQuest()` uses `onConflictDoNothing()`
- `handleEvent()` matches either exact trigger names or `trigger:` prefixes, for example `ITEM_COLLECTED:42`
- rewards can include balance and XP and are paid inside the completion transaction

## Notes

- completed assignments remain in `user_quests`
- `EVENTS.QUEST.COMPLETED` is emitted for the bot/UI layer after reward distribution
