diff --git a/Mage.Sets/src/mage/sets/alarareborn/VedalkenGhoul.java b/Mage.Sets/src/mage/sets/alarareborn/VedalkenGhoul.java index ddd5bc56763..9c1ede5ca65 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/VedalkenGhoul.java +++ b/Mage.Sets/src/mage/sets/alarareborn/VedalkenGhoul.java @@ -29,17 +29,11 @@ package mage.sets.alarareborn; import java.util.UUID; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.abilities.common.BecomesBlockedTriggeredAbility; +import mage.abilities.effects.common.LoseLifeDefendingPlayerEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.target.targetpointer.FixedTarget; /** * @@ -53,13 +47,11 @@ public class VedalkenGhoul extends CardImpl { this.subtype.add("Vedalken"); this.subtype.add("Zombie"); - - this.power = new MageInt(1); this.toughness = new MageInt(1); // Whenever Vedalken Ghoul becomes blocked, defending player loses 4 life. - this.addAbility(new VedalkenGhoulTriggeredAbility()); + this.addAbility(new BecomesBlockedTriggeredAbility(new LoseLifeDefendingPlayerEffect(4, true), false)); } @@ -72,43 +64,3 @@ public class VedalkenGhoul extends CardImpl { return new VedalkenGhoul(this); } } - -class VedalkenGhoulTriggeredAbility extends TriggeredAbilityImpl { - - public VedalkenGhoulTriggeredAbility() { - super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(4), false); - } - - public VedalkenGhoulTriggeredAbility(final VedalkenGhoulTriggeredAbility ability) { - super(ability); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.CREATURE_BLOCKED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getTargetId().equals(this.getSourceId())) { - UUID defendingPlayer = game.getCombat().getDefenderId(this.getSourceId()); - if (defendingPlayer != null) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(defendingPlayer)); - } - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever {this} becomes blocked, defending player loses 4 life."; - } - - @Override - public VedalkenGhoulTriggeredAbility copy() { - return new VedalkenGhoulTriggeredAbility(this); - } -} diff --git a/Mage.Sets/src/mage/sets/battleforzendikar/SilentSkimmer.java b/Mage.Sets/src/mage/sets/battleforzendikar/SilentSkimmer.java index bd3526bc99b..6fd8d305112 100644 --- a/Mage.Sets/src/mage/sets/battleforzendikar/SilentSkimmer.java +++ b/Mage.Sets/src/mage/sets/battleforzendikar/SilentSkimmer.java @@ -31,13 +31,12 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksTriggeredAbility; -import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.abilities.effects.common.LoseLifeDefendingPlayerEffect; import mage.abilities.keyword.DevoidAbility; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.SetTargetPointer; /** * @@ -60,8 +59,7 @@ public class SilentSkimmer extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); // Whenever Silent Skimmer attacks, defending player loses 2 life. - this.addAbility(new AttacksTriggeredAbility(new LoseLifeTargetEffect(2), false, - "Whenever {this} attacks, defending player loses 2 life", SetTargetPointer.PLAYER)); + this.addAbility(new AttacksTriggeredAbility(new LoseLifeDefendingPlayerEffect(2, true), false)); } diff --git a/Mage.Sets/src/mage/sets/magic2015/LeechingSliver.java b/Mage.Sets/src/mage/sets/magic2015/LeechingSliver.java index 32bb2c61750..82221b1d0be 100644 --- a/Mage.Sets/src/mage/sets/magic2015/LeechingSliver.java +++ b/Mage.Sets/src/mage/sets/magic2015/LeechingSliver.java @@ -27,6 +27,7 @@ */ package mage.sets.magic2015; +import java.util.UUID; import mage.MageInt; import mage.abilities.common.AttacksCreatureYouControlTriggeredAbility; import mage.abilities.effects.common.LoseLifeDefendingPlayerEffect; @@ -36,8 +37,6 @@ import mage.constants.Rarity; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import java.util.UUID; - /** * @author noxx */ @@ -58,7 +57,7 @@ public class LeechingSliver extends CardImpl { this.toughness = new MageInt(1); // Whenever a Sliver you control attacks, defending player loses 1 life. - this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new LoseLifeDefendingPlayerEffect(1), false, filter)); + this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new LoseLifeDefendingPlayerEffect(1, true), false, filter, true)); } public LeechingSliver(final LeechingSliver card) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeDefendingPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeDefendingPlayerEffect.java index 5d7fbbe3f21..54d0a5fedfb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeDefendingPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeDefendingPlayerEffect.java @@ -1,16 +1,16 @@ /* * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR @@ -20,12 +20,11 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.effects.common; import mage.abilities.Ability; @@ -37,20 +36,25 @@ import mage.constants.Outcome; import mage.game.Game; import mage.players.Player; -import java.util.UUID; - /** * @author noxx */ public class LoseLifeDefendingPlayerEffect extends OneShotEffect { protected DynamicValue amount; + protected boolean attackerIsSource; - public LoseLifeDefendingPlayerEffect(int amount) { - this(new StaticValue(amount)); + /** + * + * @param amount + * @param attackerIsSource true if the source.getSourceId() contains the + * attacker false if attacker has to be taken from targetPointer + */ + public LoseLifeDefendingPlayerEffect(int amount, boolean attackerIsSource) { + this(new StaticValue(amount), attackerIsSource); } - public LoseLifeDefendingPlayerEffect(DynamicValue amount) { + public LoseLifeDefendingPlayerEffect(DynamicValue amount, boolean attackerIsSource) { super(Outcome.Damage); this.amount = amount; } @@ -58,6 +62,7 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect { public LoseLifeDefendingPlayerEffect(final LoseLifeDefendingPlayerEffect effect) { super(effect); this.amount = effect.amount.copy(); + this.attackerIsSource = effect.attackerIsSource; } @Override @@ -67,21 +72,21 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (UUID defenderId : game.getCombat().getDefenders()) { - Player defender = game.getPlayer(defenderId); - if (defender != null) { - defender.loseLife(amount.calculate(game, source, this), game); - } + Player defender = null; + if (attackerIsSource) { + defender = game.getPlayer(game.getCombat().getDefenderId(source.getSourceId())); + } else { + defender = game.getPlayer(game.getCombat().getDefenderId(getTargetPointer().getFirst(game, source))); + } + if (defender != null) { + defender.loseLife(amount.calculate(game, source, this), game); } return true; } @Override public String getText(Mode mode) { - StringBuilder sb = new StringBuilder("defending player loses "); - sb.append(amount); - sb.append(" life"); - return sb.toString(); + return "defending player loses " + amount + " life"; } }