[FIX] References issue 282 - Fixes Phyrexian Arena, Punish Ignorance, Countersqual, Pyschic Barrier and adds LKI for spells that were countered.

This commit is contained in:
maurer.it 2011-10-17 20:28:43 -04:00
parent 7ef8070f6f
commit 515b718ad5
3 changed files with 29 additions and 10 deletions

View file

@ -29,10 +29,13 @@ package mage.abilities.effects.common;
import mage.Constants.Outcome;
import mage.Constants.Zone;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
/**
@ -61,13 +64,26 @@ public class LoseLifeControllerEffect extends OneShotEffect<LoseLifeControllerEf
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(source), Zone.BATTLEFIELD);
if (targetPermanent != null) {
Player controller = game.getPlayer(targetPermanent.getControllerId());
if (controller != null) {
controller.loseLife(amount, game);
return true;
}
Card targetCard = game.getLastKnownInformation(targetPointer.getFirst(source), Zone.BATTLEFIELD);
if ( targetCard != null ) {
Player controller = null;
//Handles interaction with that were on the battlefield permanents.
if ( targetCard instanceof Permanent ) {
Permanent targetPermanent = (Permanent)targetCard;
controller = game.getPlayer(targetPermanent.getControllerId());
}
//Handles interactign with spells that were on the stack.
else if ( targetCard instanceof Spell ) {
Spell targetSpell = (Spell)targetCard;
controller = game.getPlayer(targetSpell.getControllerId());
}
if ( controller != null ) {
controller.loseLife(amount, game);
return true;
}
}
return false;
}

View file

@ -38,6 +38,7 @@ import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffect;
import mage.cards.Card;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
@ -87,6 +88,9 @@ public class SpellStack extends Stack<StackObject> {
StackObject stackObject = getStackObject(objectId);
if (stackObject != null) {
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
if ( stackObject instanceof Spell ) {
game.rememberLKI(objectId, Zone.STACK, (Spell)stackObject);
}
this.remove(stackObject);
stackObject.counter(sourceId, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));