Refactor: ability's getSourceObjectZoneChangeCounter must be removed
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 940
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 160
Description
Original discussion: #13735
Ability remember the time of activation in own `sourceObjectZoneChangeCounter` field. It's used in some abilities logic to work with multiple object's zones (e.g. to process it on stack + battlefield or battlefield + graveyard) or to find the time of activation (see saddled and delayed triggers usage in #12154's discussion). It's not a real object's zcc and can be diff from it. Also it doesn't work with singleton abilities.
Devs mistakenly use it to find object's zcc. Also some helper methods use it like `getExileZone`.
TODO:
* move `getSourceObjectZoneChangeCounter()` from `Ability` to `AbilityImpl`, e.g. hide it from outside;
* replace all calls
* `source.getSourceObjectZoneChangeCounter()` -> `game.getState().getZoneChangeCounter(source.getSourceId());`
* `input.getSource().getSourceObjectZoneChangeCounter()` -> `input.getObject().getZoneChangeCounter(game);`
* `getSourceObjectIfItStillExists`
* `getSourceCardIfItStillExists`
* `getSourcePermanentIfItStillExists`
* make sure it's not break anything
* rename `sourceObjectZoneChangeCounter` to `activatedSourceObjectZoneChangeCounteror` or `startedObjectZoneChangeCounter`
Related issues that can be closed after refactor:
* #13137
* #8706
* #10479
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with Ability, AbilityImpl, and the named source-object helper methods, then search for every listed getSourceObjectZoneChangeCounter() call. Compare each use with the proposed object zone-change-counter lookup and review the related issues (#13137, #8706, and #10479); done means the old API is hidden or removed, callers use the appropriate replacement, and existing behavior is preserved.
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