mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Fixed Ward countering wrong ability (fixes #8378)
This commit is contained in:
parent
bcac7bd47c
commit
aa96a4af86
1 changed files with 16 additions and 2 deletions
|
@ -8,6 +8,7 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.Target;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
@ -33,16 +34,29 @@ public class WardAbility extends TriggeredAbilityImpl {
|
|||
return event.getType() == GameEvent.EventType.TARGETED;
|
||||
}
|
||||
|
||||
private StackObject getTargetingObject(GameEvent event, Game game) {
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getId().equals(event.getSourceId()) || stackObject.getSourceId().equals(event.getSourceId())) {
|
||||
for (Target target : stackObject.getStackAbility().getTargets()) {
|
||||
if (target.contains(getSourceId())) {
|
||||
return stackObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!getSourceId().equals(event.getTargetId())) {
|
||||
return false;
|
||||
}
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
|
||||
StackObject stackObject = getTargetingObject(event, game);
|
||||
if (stackObject == null || !game.getOpponents(getControllerId()).contains(stackObject.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
getEffects().setTargetPointer(new FixedTarget(event.getSourceId(), game));
|
||||
getEffects().setTargetPointer(new FixedTarget(stackObject.getId(), game));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue