mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Fixed a problem that not all effects of Smelt-Ward Gatekeeper's was resolved, because target was nor more legal after getting the control of target creature. Problem was cause by commit 80fc87a7f7
. Now both problems should be solved (hopefully).
This commit is contained in:
parent
db99909550
commit
ebb71b7dd7
2 changed files with 15 additions and 8 deletions
|
@ -298,24 +298,35 @@ public abstract class TargetImpl<T extends TargetImpl<T>> implements Target {
|
|||
@Override
|
||||
public boolean isLegal(Ability source, Game game) {
|
||||
//20101001 - 608.2b
|
||||
Set <UUID> illegalTargets = new HashSet<UUID>();
|
||||
int replacedTargets = 0;
|
||||
for (UUID targetId: targets.keySet()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null) {
|
||||
if (zoneChangeCounters.containsKey(targetId) && zoneChangeCounters.get(targetId) != card.getZoneChangeCounter()) {
|
||||
continue; // it's not legal so continue to have a look at other targeted cards
|
||||
illegalTargets.add(targetId);
|
||||
continue; // it's not legal so continue to have a look at other targeted objects
|
||||
}
|
||||
}
|
||||
if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, targetId, source.getId(), source.getControllerId()))) {
|
||||
replacedTargets++;
|
||||
continue;
|
||||
}
|
||||
if (canTarget(targetId, source, game)) {
|
||||
return true;
|
||||
if (!canTarget(targetId, source, game)) {
|
||||
illegalTargets.add(targetId);
|
||||
}
|
||||
}
|
||||
// remove illegal targets, needed to handle if only a subset of targets was illegal
|
||||
for (UUID targetId: illegalTargets) {
|
||||
targets.remove(targetId);
|
||||
}
|
||||
if (replacedTargets > 0 && replacedTargets == targets.size()) {
|
||||
return false;
|
||||
}
|
||||
if (minNumberOfTargets == 0 && targets.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return targets.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -44,16 +44,12 @@ public class FirstTargetPointer implements TargetPointer {
|
|||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<UUID>();
|
||||
if (source.getTargets().size() > 0) {
|
||||
Target currentTarget = source.getTargets().get(0);
|
||||
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||
Card card = game.getCard(targetId);
|
||||
if (card != null && zoneChangeCounter.containsKey(targetId)
|
||||
&& card.getZoneChangeCounter() != zoneChangeCounter.get(targetId)) {
|
||||
continue;
|
||||
}
|
||||
if (!currentTarget.canTarget(targetId, source, game)) {
|
||||
continue;
|
||||
}
|
||||
target.add(targetId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue