fix: use money endpoint for scout token wallet deduction #90

Merged
cal merged 1 commits from fix/scout-token-deduction into main 2026-03-16 17:50:41 +00:00
Owner

Summary

  • Scout token purchase (200₼) was not deducting currency from the player's wallet
  • db_patch("teams", params=[("wallet", new_wallet)]) was silently ignored by the API — the wallet field is not mutable via generic PATCH params
  • Replaced with db_post(f'teams/{id}/money/-{SCOUT_TOKEN_COST}'), the dedicated money endpoint used by all other wallet mutations (marketplace purchases in selectors.py, daily check-ins in packs.py)

Test plan

  • All 26 passing scout view tests still pass (1 pre-existing failure unrelated to this change)
  • Manually verify scout token purchase deducts 200₼ from wallet in Discord

🤖 Generated with Claude Code

## Summary - Scout token purchase (200₼) was not deducting currency from the player's wallet - `db_patch("teams", params=[("wallet", new_wallet)])` was silently ignored by the API — the `wallet` field is not mutable via generic PATCH params - Replaced with `db_post(f'teams/{id}/money/-{SCOUT_TOKEN_COST}')`, the dedicated money endpoint used by all other wallet mutations (marketplace purchases in `selectors.py`, daily check-ins in `packs.py`) ## Test plan - [x] All 26 passing scout view tests still pass (1 pre-existing failure unrelated to this change) - [ ] Manually verify scout token purchase deducts 200₼ from wallet in Discord 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cal added 1 commit 2026-03-16 17:24:00 +00:00
fix: use money endpoint for scout token wallet deduction
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m24s
7e406f1a06
db_patch with wallet param was silently ignored by the API — wallet
mutations require the dedicated teams/{id}/money/{amount} endpoint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-16 17:45:48 +00:00
Claude reviewed 2026-03-16 17:46:47 +00:00
Claude left a comment
Collaborator

AI Code Review

Files Reviewed

  • discord_ui/scout_view.py (modified)

Findings

Correctness

  • Fix is correct. db_patch("teams", params=[("wallet", new_wallet)]) was silently ignored by the API since wallet is not mutable via generic PATCH params.
  • Replacement db_post(f'teams/{team["id"]}/money/-{SCOUT_TOKEN_COST}') uses the dedicated money endpoint, consistent with all other wallet mutations in the codebase: selectors.py (lines 372, 438), packs.py (line 218), economy.py (line 637), gameplay_queries.py (lines 1199–1200).
  • new_wallet local state update (self.scouter_team["wallet"] = new_wallet) is preserved and still correct — the parent view refreshes from buy_view.scouter_team after purchase, so the local dict must reflect the deducted balance.
  • db_patch cleanly removed from import — confirmed no other usages in the file.

Security

  • No issues. The negative amount (-{SCOUT_TOKEN_COST}) is a constant (200), not user-supplied input.

Style & Conventions

  • No issues. Matches the established f'teams/{id}/money/-{cost}' pattern exactly.

Suggestions

  • None.

Verdict: APPROVED

Minimal, correct fix. The dedicated money endpoint is the right approach and is already the established pattern for all wallet deductions in this codebase. Import cleanup is clean.


Automated review by Claude PR Reviewer — Gitea blocks self-approval, posting as COMMENT

## AI Code Review ### Files Reviewed - `discord_ui/scout_view.py` (modified) ### Findings #### Correctness - Fix is correct. `db_patch("teams", params=[("wallet", new_wallet)])` was silently ignored by the API since `wallet` is not mutable via generic PATCH params. - Replacement `db_post(f'teams/{team["id"]}/money/-{SCOUT_TOKEN_COST}')` uses the dedicated money endpoint, consistent with all other wallet mutations in the codebase: `selectors.py` (lines 372, 438), `packs.py` (line 218), `economy.py` (line 637), `gameplay_queries.py` (lines 1199–1200). - `new_wallet` local state update (`self.scouter_team["wallet"] = new_wallet`) is preserved and still correct — the parent view refreshes from `buy_view.scouter_team` after purchase, so the local dict must reflect the deducted balance. - `db_patch` cleanly removed from import — confirmed no other usages in the file. #### Security - No issues. The negative amount (`-{SCOUT_TOKEN_COST}`) is a constant (200), not user-supplied input. #### Style & Conventions - No issues. Matches the established `f'teams/{id}/money/-{cost}'` pattern exactly. #### Suggestions - None. ### Verdict: APPROVED Minimal, correct fix. The dedicated money endpoint is the right approach and is already the established pattern for all wallet deductions in this codebase. Import cleanup is clean. --- *Automated review by Claude PR Reviewer — Gitea blocks self-approval, posting as COMMENT*
cal merged commit 8da9157f3c into main 2026-03-16 17:50:41 +00:00
cal deleted branch fix/scout-token-deduction 2026-03-16 17:50:41 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#90
No description provided.