MageObjectReference discrepancy causing various bugged effects
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 940
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 160
Description
The following constructor for MageObjectReference doesn't seem to work right and has been the cause of various bugs (Mindlink Mech #9204, Ancient Imperiosaur #10237, Mighty Servant of Leuk-o #10315)
```
public MageObjectReference(Ability source, int modifier) {
this.sourceId = source.getSourceId();
this.zoneChangeCounter = source.getSourceObjectZoneChangeCounter() + modifier;
}
```
@theelk801 I'm not totally sure what's the root cause of the discrepancy or how to fix it. I'm guessing the issue is with `getSourceId()` but fundamentally this is calling different methods than the other MageObjectReference constructors and they apparently aren't equivalent when compared. This code is used in ~25 places. So far, each bugged effect has worked fine when switching to use the standard constructor instead:
```
public MageObjectReference(MageObject mageObject, Game game, int offset) {
if (mageObject == null) {
this.sourceId = null;
this.zoneChangeCounter = -1;
return;
}
this.sourceId = mageObject.getId();
this.zoneChangeCounter = mageObject.getZoneChangeCounter(game) + offset;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Read the MageObjectReference constructors and trace the Ability-based constructor's callers, especially the effects linked to #9204, #10237, and #10315. Compare its source ID and zone-change-counter behavior with the MageObject constructor, then verify that the affected effects no longer show the reported bugs across the roughly 25 call sites.
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
- Needs clarification
- Newbie friendliness
- 35/100