Some checks failed
Deploy to Production / test (push) Failing after 33s
- Rewrite AGENTS and README files to match the current app layout - Document API routes, trivia UI, and the active panel design language
33 lines
823 B
Markdown
33 lines
823 B
Markdown
# Trade module
|
|
|
|
## Model
|
|
|
|
- trade sessions are in-memory only
|
|
- sessions are keyed by Discord thread ID
|
|
- there is no persistence or restart recovery
|
|
|
|
## Main methods
|
|
|
|
- `createSession()`
|
|
- `getSession()`
|
|
- `endSession()`
|
|
- `updateMoney()`
|
|
- `addItem()`
|
|
- `removeItem()`
|
|
- `toggleLock()`
|
|
- `executeTrade()`
|
|
- `clearSessions()`
|
|
|
|
## Rules
|
|
|
|
- any change to money or items unlocks both participants
|
|
- `executeTrade()` requires both users to be locked
|
|
- money transfer goes through `economyService.modifyUserBalance()`
|
|
- item transfer goes through `inventoryService.removeItem()` and `addItem()`
|
|
- item transfers are also logged in `item_transactions`
|
|
|
|
## Notes
|
|
|
|
- `_sessions` is intentionally exposed for tests
|
|
- type definitions live under `bot/modules/trade/trade.types.ts`, while the service stays in `shared/modules/trade`
|