paper-dynasty-database/app
Cal Corum 264c7dc73c feat(WP-10): pack opening hook — evolution_card_state initialization
Closes #75.

New file app/services/evolution_init.py:
- _determine_card_type(player): pure fn mapping pos_1 to 'batter'/'sp'/'rp'
- initialize_card_evolution(player_id, team_id, card_type): get_or_create
  EvolutionCardState with current_tier=0, current_value=0.0, fully_evolved=False
- Safe failure: all exceptions caught and logged, never raises
- Idempotent: duplicate calls for same (player_id, team_id) are no-ops
  and do NOT reset existing evolution progress

Modified app/routers_v2/cards.py:
- Add WP-10 hook after Card.bulk_create in the POST endpoint
- For each card posted, call _determine_card_type + initialize_card_evolution
- Wrapped in try/except so evolution failures cannot block pack opening
- Fix pre-existing lint violations (unused lc_id, bare f-string, unused e)

New file tests/test_evolution_init.py (16 tests, all passing):
- Unit: track assignment for batter / SP / RP / CP positions
- Integration: first card creates state with zeroed fields
- Integration: duplicate card is a no-op (progress not reset)
- Integration: different players on same team get separate states
- Integration: card_type routes to correct EvolutionTrack
- Integration: missing track returns None gracefully

Fix tests/test_evolution_models.py: correct PlayerSeasonStats import/usage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 13:41:05 -05:00
..
models refactor: split PlayerSeasonStats into BattingSeasonStats and PitchingSeasonStats 2026-03-17 09:43:22 -05:00
routers_v2 feat(WP-10): pack opening hook — evolution_card_state initialization 2026-03-18 13:41:05 -05:00
seed fix: address PR review findings 2026-03-17 21:38:12 -05:00
services feat(WP-10): pack opening hook — evolution_card_state initialization 2026-03-18 13:41:05 -05:00
__init__.py Initial Commit with /current 2023-09-13 14:44:26 -05:00
card_creation.py Update card_creation.py 2024-02-24 21:36:44 -06:00
db_engine.py feat(WP-01): add evolution Peewee models 2026-03-17 19:32:03 -05:00
db_helpers.py Fix PostgreSQL upsert column names and CSV null handling 2026-01-30 17:28:40 -06:00
dependencies.py fix: use constant-time comparison for bearer token validation (#8) 2026-03-05 03:43:59 +00:00
main.py Merge main into next-release 2026-03-17 13:53:46 -05:00
player_scouting.py Update player_scouting.py 2023-09-24 19:00:21 -05:00