claude-home/paper-dynasty/scout-token-wallet-fix.md
Cal Corum aafe527d51
All checks were successful
Reindex Knowledge Base / reindex (push) Successful in 5s
docs: add Major Domo and Paper Dynasty release notes and card evolution PRD
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 22:29:18 -05:00

50 lines
1.9 KiB
Markdown

---
title: "Fix: Scout Token Purchase Not Deducting Currency"
description: "Changelog for PR #90 — scout token buy flow was silently failing to deduct 200₼ due to using db_patch instead of the dedicated money endpoint."
domain: development
type: troubleshooting
tags:
- paper-dynasty
- discord
- troubleshooting
- python
---
# Fix: Scout Token Purchase Not Deducting Currency
**PR**: #90`fix/scout-token-deduction`
**Merged**: 2026-03-16
**File**: `discord_ui/scout_view.py`
## Bug
When a player exhausted their 2 free daily scout tokens and purchased an extra one for 200₼, the token was granted and the card was scouted, but the wallet balance was never reduced. Players could buy unlimited scout tokens for free.
## Root Cause
`BuyScoutTokenView.buy_button` used `db_patch("teams", params=[("wallet", new_wallet)])` to set the wallet directly. The Paper Dynasty API does not support mutating the `wallet` field via generic PATCH query params — the request returned 200 but silently ignored the parameter.
## Fix
Replaced with the dedicated money endpoint used by all other wallet mutations:
```python
# Before (broken — silently ignored by API)
await db_patch("teams", object_id=team["id"], params=[("wallet", new_wallet)])
# After (correct)
await db_post(f'teams/{team["id"]}/money/-{SCOUT_TOKEN_COST}')
```
Removed unused `db_patch` import from the file.
## Key Pattern: Wallet Mutations
The Paper Dynasty API requires dedicated endpoints for wallet changes. Never use `db_patch` with a `wallet` param.
| Operation | Pattern | Example |
|-----------|---------|---------|
| Add money | `db_post(f'teams/{id}/money/{amount}')` | Daily check-in (`packs.py:218`) |
| Deduct money | `db_post(f'teams/{id}/money/-{amount}')` | Card purchases (`selectors.py:372`) |
| Atomic buy | `db_get(f'teams/{id}/buy/players', params=[...])` | Marketplace (`marketplace.py:82`) |