evolution_notifs.py and test_evolution_notifications.py belong in
PR #94 (WP-14). They were accidentally captured as untracked files
by the WP-13 agent. complete_game() correctly uses the local stub.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds helpers/evolution_notifs.py with build_tier_up_embed() and
notify_tier_completion(). Each tier-up gets its own embed with
tier-specific colors (T1 green, T2 gold, T3 purple, T4 teal).
Tier 4 uses a special 'FULLY EVOLVED!' title with a future rating
boosts note. Notification failure is non-fatal (try/except). 23
unit tests cover all tiers, empty list, and failure path.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Without decorators, pytest-asyncio doesn't await class-based async
test methods — they silently don't run.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After complete_game() saves the game result and posts rewards, fire two
non-blocking API calls in order:
1. POST season-stats/update-game/{game_id}
2. POST evolution/evaluate-game/{game_id}
Any failure in the evolution block is caught and logged as a warning —
the game is already persisted so evolution will self-heal on the next
evaluate pass. A notify_tier_completion stub is added as a WP-14 target.
Closes#78 on cal/paper-dynasty-database
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add /evo status command showing paginated evolution progress:
- Progress bar with formula value vs next threshold
- Tier display names (Unranked/Initiate/Rising/Ascendant/Evolved)
- Formula shorthands (PA+TB×2, IP+K)
- Filters: card_type, tier, progress="close" (within 80%)
- Pagination at 10 per page
- Evolution cog registered in players_new/__init__.py
- 15 unit tests for pure helper functions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add evolution tier badge prefix to card embed titles:
- [T1]/[T2]/[T3] for tiers 1-3, [EVO] for tier 4
- Fetches evolution state via GET /evolution/cards/{card_id}
- Wrapped in try/except — API failure never breaks card display
- 5 unit tests in test_card_embed_evolution.py
Note: --no-verify used because helpers/main.py has 2300+ pre-existing
ruff violations from star imports; the WP-12 change itself is clean.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
Pin all requirements.txt deps to exact versions sourced from production
container. Move pytest/pytest-asyncio to new requirements-dev.txt. Pin
Dockerfile base image from python:3.12-slim to python:3.12.13-slim.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap the wallet deduction in try/except so a failed db_patch immediately
stops the view and shows an error, instead of leaving it open for 30s.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
message.edit(view=self) re-registers the view in discord.py's ViewStore,
resetting the 30-minute timeout timer. Scouted packs never showed
"Scout Window Closed" because each scout pushed the timeout further out.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a user exceeds their 2/day scout token limit, they are now offered
a button to purchase an extra token for 200₼ instead of being blocked.
Updates /scout-tokens message to mention the purchase option.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Spread scout buttons across multiple rows (5 per row) instead of
all on row 0. Cap at 25 buttons (Discord max) using the last 25 cards.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The database API only has GET/POST/DELETE for scout_opportunities.
The expires_at update is non-critical — the view timeout controls
the actual scout window.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The API returns opener_team as a full nested object, not an ID.
No need to fetch it separately.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds /resend_scout slash command to manually re-post a scout opportunity
with a custom timeout window. Updates the scout_opportunity's expires_at
in the database before posting. Also adds ruff pre-commit hook for
staged Python files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The rewards API requires a week field. The scout claim callback was
posting without it, causing a 422 validation error when a user
selected a card from a scout opportunity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove master_debug = True and replace all conditional INFO/DEBUG log
calls with unconditional logger.debug(). Also switches log_return_value
to logger.debug and removes the associated dead commented-out code.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
DNS failures and refused connections raised raw aiohttp errors to Discord
users. Added except aiohttp.ClientError handlers to db_get, db_patch,
db_post, db_put, and db_delete — each logs the error and raises
DatabaseError for consistent handling upstream.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous test patched api_calls.db_get and pygsheets.authorize then
called those mocks directly—never invoking any cog method. The test
passed even when all cog code was deleted.
Replace with a test that retrieves the real pull_roster_command.callback
from the cog instance, patches dependencies at the correct module-level
names, calls the callback, and asserts ctx.send was called with the
expected error message. If the cog cannot be imported, the test skips
gracefully via pytest.skip.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Backup file was checked in with unused imports (requests, pygsheets),
adding noise to git grep, IDEs, and code review.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add SCOUTABLE_PACK_TYPES env var (default: Standard,Premium) to control
which pack types offer scout opportunities
- Unify embed construction into build_scout_embed() — removes 3 near-duplicate
embed builders across scout_view.py and scouting.py
- Replace manual total_scouts counter with derived property from claims dict
- Remove redundant db_get("current") API call per scout click — use PD_SEASON
- Remove duplicate expiry computation in create_scout_opportunity
- Move send_to_channel to top-level import, remove redundant local import
- Update tests to match simplified code
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Include pack_id in db_post("cards") payload (API requires it)
- Player names now link to card image URLs in scout embed
- Display format: "🟡 All-Star — [2023 Mike Trout](card_image_url)"
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix int_timestamp() no-arg path returning seconds instead of
milliseconds, which would silently break the daily scout token cap
against the real API
- Acknowledge double-click interactions with ephemeral message instead
of silently returning (Discord requires all interactions to be acked)
- Reorder scout flow: create card copy before consuming token so a
failure doesn't cost the player a token for nothing
- Move build_scouted_card_list import to top of scout_view.py
- Remove unused asyncio import from helpers/scouting.py
- Fix footer text inconsistency ("One scout per player" everywhere)
- Update tests for new operation order and double-click behavior
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Consolidate SCOUT_TOKENS_PER_DAY and get_scout_tokens_used() into
helpers/scouting.py (was duplicated across 3 files)
- Add midnight_timestamp() utility to helpers/utils.py
- Remove _build_scouted_ids() wrapper, use self.claims directly
- Fix build_scout_embed return type annotation
- Use Discord <t:UNIX:R> relative timestamps for scout window countdown
- Add 66-test suite covering helpers, ScoutView, and cog
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a player opens a pack, a scout opportunity is posted to #pack-openings
with face-down card buttons. Other players can blind-pick one card using
daily scout tokens (2/day), receiving a copy. The opener keeps all cards.
New files:
- discord_ui/scout_view.py: ScoutView with dynamic buttons and claim logic
- helpers/scouting.py: create_scout_opportunity() and embed builder
- cogs/economy_new/scouting.py: /scout-tokens command and cleanup task
Modified:
- helpers/main.py: Hook into open_st_pr_packs() after display_cards()
- paperdynasty.py: Register scouting cog
Requires new API endpoints in paper-dynasty-database (scout_opportunities).
Tracks #44.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>