Fix mobile NPE when cloning Adventure creatures with card images disabled#10349
Fix mobile NPE when cloning Adventure creatures with card images disabled#10349MostCromulent wants to merge 1 commit intoCard-Forge:masterfrom
Conversation
When a clone (e.g. Superior Spider-Man) copies an Adventure creature, the CardView's AlternateState was null because getAlternateState() only checks original card states, not clone states. The mobile renderer then crashes calling getName() on the null state when rendering with card images disabled. Two fixes: CardView.updateState() falls back to the Secondary clone state, and CardImageRenderer falls back from the backup to the in-game card when the backup lacks the adventure state. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
hmn not sure why this isn't a problem on Desktop though - might be better if any fallback logic lived in the same places? @Hanmac |
AI analysis:
|
Fix mobile NPE when cloning Adventure creatures with card images disabled
Fixes #10036
Problem
When Superior Spider-Man copies an Adventure creature with card images disabled on mobile, the renderer crashes with a
NullPointerExceptiononCardStateView.getName().Root cause:
CardView.updateState()setsSecondary=true(correctly checking clone states) but setsAlternateState=null(becausegetAlternateState()only checks original states, not clone states). The mobile renderer assumes these are consistent.Fix
Two changes, both required:
CardView.updateState() — when
alternateStateis null but the card has a Secondary clone state, use it. This closes the inconsistency betweenSecondaryandAlternateStatein the view. Only triggers for clones of Adventure creatures; non-cloned Adventure cards already have both set correctly.CardImageRenderer.setTextBox() — when the backup card's alternate state is null, fall back to the in-game card. The backup is the clone's paper card (Spider-Man), which isn't an Adventure. The in-game card has the correct Adventure state from fix 1.
Neither fix alone is sufficient: fix 1 sets
card.getState(true)but the renderer reads from the backup; fix 2 falls back to the card but needs fix 1 for the card's state to be set.Note: workaround vs root cause
This is a targeted workaround. The underlying issue is that
Card.getAlternateState()/hasAlternateState()/getAlternateStateName()don't check clone states, whilegetState()/hasState()do. A root cause fix would make those three methods clone-aware:These methods are called from 89 sites across 25 files (game logic, AI, UI on both platforms, network), so changing what they return for cloned cards could have hard-to-predict side effects across clone scenarios (flip, transform, split, etc.). The workaround scopes the fix to exactly where the inconsistency causes a problem.
Testing
🤖 Generated with Claude Code