Merge pull request #5320 from m-d-an/master

FixedIonize
This commit is contained in:
theelk801 2018-09-19 18:02:05 -04:00 committed by GitHub
commit fe64f7d88d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,7 +9,9 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetSpell;
/** /**
* *
@ -21,6 +23,7 @@ public final class Ionize extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{R}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}{R}");
// Counter target spell. Ionize deals 2 damage to that spell's controller. // Counter target spell. Ionize deals 2 damage to that spell's controller.
this.getSpellAbility().addTarget(new TargetSpell());
this.getSpellAbility().addEffect(new IonizeEffect()); this.getSpellAbility().addEffect(new IonizeEffect());
} }
@ -53,11 +56,16 @@ class IonizeEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getControllerId(source.getSourceId())); boolean result = false;
new CounterTargetEffect().apply(game, source); Spell spell = game.getStack().getSpell(source.getFirstTarget());
if (player == null) { if (spell != null) {
return false; Player spellController = game.getPlayer(spell.getControllerId());
}
return player.damage(2, source.getSourceId(), game, false, true) > 0; result = game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
if (spellController != null) {
spellController.damage(2, source.getSourceId(), game, false, true);
}
}
return result;
} }
} }