* Summoning Trap - Fixed a bug that the trap condition was never true.

This commit is contained in:
LevelX2 2016-03-21 10:23:58 +01:00
parent 339fccd262
commit 3441b9d216

View file

@ -48,6 +48,7 @@ import mage.filter.common.FilterCreatureCard;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
@ -92,7 +93,7 @@ class SummoningTrapCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatchers().get("CardsPutIntoGraveyardWatcher"); SummoningTrapWatcher watcher = (SummoningTrapWatcher) game.getState().getWatchers().get("CreatureSpellCountered");
return watcher != null && watcher.creatureSpellOfPlayerWasCountered(source.getControllerId()); return watcher != null && watcher.creatureSpellOfPlayerWasCountered(source.getControllerId());
} }
@ -123,19 +124,20 @@ class SummoningTrapWatcher extends Watcher {
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == EventType.COUNTERED) { if (event.getType() == EventType.COUNTERED) {
StackObject stackObject = game.getStack().getStackObject(event.getTargetId()); StackObject conteredSpell = game.getStack().getStackObject(event.getTargetId());
if (stackObject == null) { if (conteredSpell == null) {
stackObject = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK); conteredSpell = (StackObject) game.getLastKnownInformation(event.getTargetId(), Zone.STACK);
} }
if (stackObject != null if (conteredSpell != null
&& !players.contains(stackObject.getControllerId()) && conteredSpell instanceof Spell
&& stackObject.getCardType().contains(CardType.CREATURE)) { && !players.contains(conteredSpell.getControllerId())
StackObject counterObject = game.getStack().getStackObject(event.getSourceId()); && conteredSpell.getCardType().contains(CardType.CREATURE)) {
if (counterObject == null) { StackObject counteringStackObject = game.getStack().getStackObject(event.getSourceId());
counterObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK); if (counteringStackObject == null) {
counteringStackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
} }
if (counterObject != null && game.getOpponents(stackObject.getControllerId()).contains(counterObject.getControllerId())) { if (counteringStackObject != null && game.getOpponents(conteredSpell.getControllerId()).contains(counteringStackObject.getControllerId())) {
players.add(stackObject.getControllerId()); players.add(conteredSpell.getControllerId());
} }
} }