1.5 KiB
1.5 KiB
2024-12-18 - Parse Card Data Robustness
Problem
The user reported issues with "placing cards onto the battlefield". Specifically, this manifested in two likely ways:
- Creature cards fading away instantly (dying to State-Based Actions) because their Power/Toughness was defaulted to 0/0.
- Cards resolving to the Graveyard instead of Battlefield because the
RulesEnginefailed to identify them as Permanents (emptytypesarray), defaulting to Instant/Sorcery behavior.
Root Cause
- Missing P/T Passing: The
server/index.tsfile was constructing the initial game state from deck cards but failing to explicitly copypowerandtoughnessproperties. - Missing Type Parsing: The
GameManager(andindex.ts) relied ontypeLinestring but did not parse it into thetypesarray which theRulesEnginestrictly checks forisPermanentlogic and invalid aura validation.
Solution
- Updated
GameManager.ts: Added robust parsing logic inaddCardToGame. Ifcard.typesis empty, it now parsescard.typeLine(e.g. splitting "Legendary Creature — Human") to populatetypes,supertypes, andsubtypesarrays. - Updated
server/index.ts: Modified all game initialization flows to explicitly passpowerandtoughnessfrom the source data togameManager.addCardToGame.
Outcome
Cards added to the game now have correct type metadata and base stats.
- Creatures resolve to the battlefield correctly (identified as Permanents).
- Creatures stay on the battlefield (Toughness > 0 prevents SBA death).