refactor needed: target legality check depending on set of all targets
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 940
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 160
Description
Some targets care about a quality of the collection of targets, separately from restricting individual targets.
Example wordings to check: "with different", "controlled by different", "with total".
Example cards:
[[Deathbellow War Cry]] using `TargetCardWithDifferentNameInLibrary`
[[March from the Tomb]] with custom target using standard utility method from #12808
[[Run Away Together]] with custom target
Original implementation only overriding canTarget is not fully correct. Must also override possibleTargets.
But also, in some scenarios, it could be possible for the quality to change between targeting and resolution so that it is no longer valid. If that happens, the entire set of targets is illegal. See ruling on [[Nethroi, Apex of Death]]
> If the power of the target creature cards change while in your graveyard, most likely because one has a characteristic-defining ability that defines a * in its power, the total power of the creatures may become greater than 10. If this happens, the entire selection of targets is illegal and nothing is returned to the battlefield.
So to cover that edge case, must override `isLegal` as well and check the collective legality after the individual legality. May not matter for characteristics like mana value that can't change.
> Looks like an original problem in wrong target implementation -- it's try to simulate manual adding/removing ids instead all methods implementation like isLegal, etc.
I'll look at it later -- must be compatible with legality checking, human's select/deselect and AI targeting/simulations.
_Originally posted by JayDi85 in https://github.com/magefree/mage/issues/12806#issuecomment-2333221071_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the target implementations for Deathbellow War Cry, March from the Tomb, and Run Away Together, along with the standard utility method from #12808. Trace how canTarget, possibleTargets, and isLegal are used during human selection, resolution, and AI targeting. Done means collective target legality is enforced consistently, including when legality changes before resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- game-dev
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100