magefree / magefree/mage

Source abilities for continuous effects don't keep zone change counter current

Open
#8,706 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
2.4k
Forks
940
Avg merge
2d 12h
Merged PRs (30d)
160

Description

Continuous effects have a map which links them to their source ability, but the map is initialized at the start of the game and the source ability that they're mapped to doesn't change. This means that when applying a continuous effect, the zone change counter of its ability isn't actually current and is stuck at 0. This is different from activated or activated abilities which do stay current.

There seems to be a workaround for this in `AbilityImpl.getSourceObjectIfItStillExists(game)` which prevents some issues:
https://github.com/magefree/mage/blob/54203c16d3505dcfb55da5f861beea160ad66f17/Mage/src/main/java/mage/abilities/AbilityImpl.java#L1265-L1273

But anything that calls `source.getSourceObjectZoneChangeCounter()`, like for example `CardUtil.getExileZoneId`, will still get the wrong info.

I'd like to fix this but I'm not sure how to do so at the moment. For now, a usable workaround is calling `game.getState().getZoneChangeCounter(source.getSourceId())` instead of `source.getSourceObjectZoneChangeCounter()` inside of a continuous effect, which definitely works when the effect is only in one zone as other separate mechanisms guarantee that the object you get from `game.getObject` will be the source object. I do still think this is fixable though.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with AbilityImpl.getSourceObjectIfItStillExists(game) and CardUtil.getExileZoneId, then trace how continuous effects map to source abilities and how zone change counters are updated. Done means callers of source.getSourceObjectZoneChangeCounter() receive the current counter for continuous-effect sources without breaking the existing workaround behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.