fix: variant render uses fragile track_name string mapping #149

Closed
opened 2026-04-08 00:23:52 +00:00 by cal · 1 comment
Owner

Problem

In _trigger_variant_renders() at logic_gameplay.py:4260-4261:

track = tier_up.get("track_name", "Batter")
card_type = "pitching" if track.lower() == "pitcher" else "batting"

This maps track names to card types via string check. If the API ever returns "Starting Pitcher", "SP", or any other variant, the mapping breaks silently and renders batting cards for pitchers. The default of "Batter" means any unexpected track name also gets treated as batting.

Fix

Use the track's card_type field (already available in refractor data as sp, rp, or batter) rather than the display-oriented track_name string.

Impact

Low effort fix. Prevents silent wrong-card-type renders.

## Problem In `_trigger_variant_renders()` at `logic_gameplay.py:4260-4261`: ```python track = tier_up.get("track_name", "Batter") card_type = "pitching" if track.lower() == "pitcher" else "batting" ``` This maps track names to card types via string check. If the API ever returns "Starting Pitcher", "SP", or any other variant, the mapping breaks silently and renders batting cards for pitchers. The default of "Batter" means any unexpected track name also gets treated as batting. ## Fix Use the track's `card_type` field (already available in refractor data as `sp`, `rp`, or `batter`) rather than the display-oriented `track_name` string. ## Impact Low effort fix. Prevents silent wrong-card-type renders.
Claude added the
ai-working
label 2026-04-08 03:31:20 +00:00
Collaborator

PR #153 opened: #153

Replaced track_name string matching with card_type field lookup (sp/rppitching, batterbatting). 2-line change in _trigger_variant_renders(). Test fixtures updated and assertions strengthened to verify the correct card type in the render URL.

PR #153 opened: https://git.manticorum.com/cal/paper-dynasty-discord/pulls/153 Replaced `track_name` string matching with `card_type` field lookup (`sp`/`rp` → `pitching`, `batter` → `batting`). 2-line change in `_trigger_variant_renders()`. Test fixtures updated and assertions strengthened to verify the correct card type in the render URL.
Claude added the
ai-pr-opened
label 2026-04-08 03:33:05 +00:00
cal closed this issue 2026-04-12 14:39:51 +00:00
Sign in to join this conversation.
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#149
No description provided.