magefree / magefree/mage

Refactor: usage of getSourceObjectZoneChangeCounter must be removed from triggers

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

Description

From https://github.com/magefree/mage/pull/12180#issuecomment-2542825963:

`Ability::getSourceObjectZoneChangeCounter ` doesn't work inside `checkTrigger` cause trigger's zcc sync later in the code -- after `checkTrigger` call. It must be replaced by `CardUtil.getActualSourceObjectZoneChangeCounter(game, source)`. Fix example: a970dc46c7124bf5586867c1bbcc8cbac13f7a5e

TODO:
* [ ] main: check ~190 usages of `getSourceObjectZoneChangeCounter` and replace it in triggers (one short effects are fine);
* [ ] optional: check same usages in continues/replacement effects -- maybe it's also affected and must be replaced;

Useful info, copied from https://github.com/magefree/mage/pull/12180#issuecomment-2078598002:

> Object zcc and ability zcc are little different things:
> * Objects use dynamic zcc. Objects moves between zones and increments own zcc (it allow to simulate new object due mtg rules, but keep all settings and related data for work);
> * Abilities use static zcc. Abilities do not “move” with object and have own lifecycle:
> - activated abilities “creates” on real usage (on activate);
> - static abilities “creates” on game start (or new continues effect creates);
>
> So ability zcc allow you to find out a moment of real ability’s usage (activating). And it actual for activated abilities only (use case example: trigger on etb, but source object left battlefield before resolve).
>
> If you use ability zcc from continues effect like your use case - it can contains wrong data (continues effect exists all time until discarded).

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the repository for the roughly 190 usages of getSourceObjectZoneChangeCounter and identify those in trigger checks. Compare affected code with CardUtil.getActualSourceObjectZoneChangeCounter(game, source), then review optional usages in continuous and replacement effects. Done means trigger usages are replaced and the remaining usage scope is accounted for.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
game-dev
Issue type
Refactor
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.