Skip to content

fix: restore compatibility with latest Slay the Spire 2 build - #121

Closed
mwijffelaars wants to merge 1 commit into
Gennadiyev:mainfrom
mwijffelaars:fix/sts2-api-compat
Closed

fix: restore compatibility with latest Slay the Spire 2 build#121
mwijffelaars wants to merge 1 commit into
Gennadiyev:mainfrom
mwijffelaars:fix/sts2-api-compat

Conversation

@mwijffelaars

Copy link
Copy Markdown

A recent Slay the Spire 2 update changed three game APIs the mod binds to directly. Because MonoMod JIT-compiles these methods, the missing members make whole methods fail to compile at runtime — combat state reads throw MissingMethodException on CombatManager.get_IsPlayPhase(), and the shop / card-target paths break the same way.

Symptom reported in the wild (combat):

Failed to read game state: Method not found: 'Boolean MegaCrit.Sts2.Core.Combat.CombatManager.get_IsPlayPhase()'.
  at STS2_MCP.McpMod.BuildBattleState(RunState runState, CombatRoom combatRoom)

Changes

  • CombatManager.IsPlayPhase was removed. Added an IsPlayPhaseCompat() helper that reconstructs "it's the player's interactive turn" from members that still exist (IsInProgress && !IsEnemyTurnStarted && !EndingPlayerTurnPhaseOne && !EndingPlayerTurnPhaseTwo) and routed all 7 references through it. It leans permissive on purpose — every action guard also checks PlayerActionsDisabled right after, which covers transient action locks.
  • player.Creature.CombatState now returns ICombatState rather than the concrete CombatState. Widened ResolveTarget()'s parameter to the interface; it only uses GetCreature()/Enemies, both present on ICombatState, and CombatState implements it, so all callers still bind.
  • MerchantRoom.Inventory was removed. Switched the two call sites to the new MerchantRoom.GetLocalInventory().

Verification

Built clean (0 warnings, 0 errors) against the current game assemblies, and verified in-game: combat state reads and shop both work again. The removed/renamed members were confirmed against the current sts2.dll via metadata inspection.

A recent game update changed three APIs the mod binds to directly.
Because MonoMod JIT-compiles these methods, the missing members make
whole methods fail to compile at runtime: combat state reads throw
MissingMethodException on CombatManager.get_IsPlayPhase(), and the
shop/target code paths break the same way.

- CombatManager.IsPlayPhase was removed. Add IsPlayPhaseCompat() which
  reconstructs "player's interactive turn" from members that still
  exist (IsInProgress && !IsEnemyTurnStarted && !EndingPlayerTurnPhaseOne
  && !EndingPlayerTurnPhaseTwo) and route all references through it.
- player.Creature.CombatState now returns ICombatState instead of the
  concrete CombatState; widen ResolveTarget() to take the interface (it
  only uses GetCreature()/Enemies, both on ICombatState).
- MerchantRoom.Inventory was removed; use MerchantRoom.GetLocalInventory()
  at the two call sites.

Builds clean against the current game assemblies and verified in-game
(combat state reads and shop).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mwijffelaars

Copy link
Copy Markdown
Author

Closing as a duplicate — I hadn't seen that #117, #116, and #110 already address the same v0.107.1 API breakage (IsPlayPhase / MerchantRoom.Inventory). Thanks, and apologies for the noise!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant