Skip to content

fix(elf-x): apply mana reduction in the same turn as summon#394

Open
Shahrukh95 wants to merge 2 commits into
sindreslungaard:mainfrom
Shahrukh95:fix/elf-x-same-turn-mana-reduction
Open

fix(elf-x): apply mana reduction in the same turn as summon#394
Shahrukh95 wants to merge 2 commits into
sindreslungaard:mainfrom
Shahrukh95:fix/elf-x-same-turn-mana-reduction

Conversation

@Shahrukh95

Copy link
Copy Markdown

📝 Summary

Elf-X's mana reduction was not applying in the same turn it was summoned. The persistent effect was registered but not yet invoked when BroadcastState ran, so creatures in hand required their full cost. This is fixed by applying the discount immediately on InTheBattlezone before BroadcastState runs.

Additionally, in the dev environment, cards added mid-turn via /add or /init also did not receive the same-turn discount because they missed that turn's UntapStep, leaving cnd.Creature unset. This is fixed by running spawned cards through a synthetic UntapStep on creation.

Closes #379

🐞 Bugs Fixed

  • Elf-X mana reduction now applies in the same turn it is summoned
  • Cards added via /add or /init mid-turn now also receive the same-turn discount

🔧 Other Changes

  • sim/game/cards/dm02/tree_folk.go: Added an immediate applyDiscount() call inside the InTheBattlezone handler, before ApplyPersistentEffect. The discount logic is extracted into a local applyDiscount closure, used in both the InTheBattlezone handler and the persistent effect.
  • sim/game/match/match.go: After each SpawnCard, the new card's handlers are run with a synthetic UntapStep context. This is because cards spawned mid-turn via /add or /init miss that turn's UntapStep, so they lack cnd.Creature for the remainder of the turn. This caused same-turn discount to fail for those cards (next-turn worked fine since UntapStep would catch them).
  • sim/game/match/player.go: SpawnCard now returns *Card instead of nothing. This is to give spawnCardsToGivenZones in sim/game/match/match.go access to the newly created card for initialization.

✅ Checklist

Please confirm the following before submitting your PR:

  • I have read CONTRIBUTING.md
  • The changes has been tested locally
  • The PR does not contain an excessive amount of changes that could have been split up into multiple PRs

📸 Screenshots (if applicable)

No changes to the frontend

@sindreslungaard sindreslungaard left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, minor touch on the SpawnCard return value

Comment thread sim/game/match/player.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with Elf-X

3 participants