From 635e70e77eb00eec6bca1b22401f4d7ac5298344 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Sun, 2 Jan 2022 14:54:56 -0500 Subject: [PATCH] Deleted two duplicate Ability classes --- .../src/mage/cards/k/KangeeSkyWarden.java | 4 +- ...locksOrBecomesBlockedTriggeredAbility.java | 95 ------------------- .../common/BlocksTriggeredAbility.java | 67 ------------- 3 files changed, 2 insertions(+), 164 deletions(-) delete mode 100644 Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java delete mode 100644 Mage/src/main/java/mage/abilities/common/BlocksTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/k/KangeeSkyWarden.java b/Mage.Sets/src/mage/cards/k/KangeeSkyWarden.java index 3670d02910..b20702eae6 100644 --- a/Mage.Sets/src/mage/cards/k/KangeeSkyWarden.java +++ b/Mage.Sets/src/mage/cards/k/KangeeSkyWarden.java @@ -2,7 +2,7 @@ package mage.cards.k; import mage.MageInt; import mage.abilities.common.AttacksTriggeredAbility; -import mage.abilities.common.BlocksTriggeredAbility; +import mage.abilities.common.BlocksSourceTriggeredAbility; import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.VigilanceAbility; @@ -60,7 +60,7 @@ public final class KangeeSkyWarden extends CardImpl { ), false)); // Whenever Kangee blocks, blocking creatures with flying get +0/+2 until end of turn. - this.addAbility(new BlocksTriggeredAbility(new BoostAllEffect( + this.addAbility(new BlocksSourceTriggeredAbility(new BoostAllEffect( 0, 2, Duration.EndOfTurn, filter2, false ), false)); } diff --git a/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java deleted file mode 100644 index b592d1c08b..0000000000 --- a/Mage/src/main/java/mage/abilities/common/BlocksOrBecomesBlockedTriggeredAbility.java +++ /dev/null @@ -1,95 +0,0 @@ - -package mage.abilities.common; - -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.filter.StaticFilters; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; -import mage.target.targetpointer.FixedTarget; - -/** - * @author North, Loki - */ -public class BlocksOrBecomesBlockedTriggeredAbility extends TriggeredAbilityImpl { - - protected FilterPermanent filter; - protected String rule; - protected boolean setTargetPointer; - - public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, boolean optional) { - this(effect, StaticFilters.FILTER_PERMANENT_CREATURE, optional, null, true); - } - - public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional) { - this(effect, filter, optional, null, true); - } - - public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional, String rule) { - this(effect, filter, optional, rule, true); - } - - public BlocksOrBecomesBlockedTriggeredAbility(Effect effect, FilterPermanent filter, boolean optional, String rule, boolean setTargetPointer) { - super(Zone.BATTLEFIELD, effect, optional); - this.filter = filter; - this.rule = rule; - this.setTargetPointer = setTargetPointer; - } - - public BlocksOrBecomesBlockedTriggeredAbility(final BlocksOrBecomesBlockedTriggeredAbility ability) { - super(ability); - this.filter = ability.filter; - this.rule = ability.rule; - this.setTargetPointer = ability.setTargetPointer; - - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.BLOCKER_DECLARED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.getSourceId())) { - Permanent blocked = game.getPermanent(event.getTargetId()); - if (filter.match(blocked, game)) { - if (setTargetPointer) { - this.getEffects().setTargetPointer(new FixedTarget(blocked, game)); - } - return true; - } - } - if (event.getTargetId().equals(this.getSourceId())) { - Permanent blocker = game.getPermanent(event.getSourceId()); - if (filter.match(blocker, game)) { - if (setTargetPointer) { - this.getEffects().setTargetPointer(new FixedTarget(blocker, game)); - } - return true; - } - } - return false; - } - - @Override - public String getRule() { - if (rule != null) { - return rule; - } - return super.getRule(); - } - - @Override - public String getTriggerPhrase() { - return "Whenever {this} blocks or becomes blocked" + (setTargetPointer ? " by a " + filter.getMessage() : "") + ", "; - } - - @Override - public BlocksOrBecomesBlockedTriggeredAbility copy() { - return new BlocksOrBecomesBlockedTriggeredAbility(this); - } -} diff --git a/Mage/src/main/java/mage/abilities/common/BlocksTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BlocksTriggeredAbility.java deleted file mode 100644 index 780daf5bbe..0000000000 --- a/Mage/src/main/java/mage/abilities/common/BlocksTriggeredAbility.java +++ /dev/null @@ -1,67 +0,0 @@ - -package mage.abilities.common; - -import mage.constants.Zone; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.target.targetpointer.FixedTarget; - -/** - * - * @author North - */ -public class BlocksTriggeredAbility extends TriggeredAbilityImpl { - - private boolean setTargetPointer; - private boolean once = false; - - public BlocksTriggeredAbility(Effect effect, boolean optional) { - this(effect, optional, false); - } - - public BlocksTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { - this(effect, optional, setTargetPointer, false); - } - - public BlocksTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer, boolean once) { - super(Zone.BATTLEFIELD, effect, optional); - this.setTargetPointer = setTargetPointer; - this.once = once; - } - - public BlocksTriggeredAbility(final BlocksTriggeredAbility ability) { - super(ability); - this.setTargetPointer = ability.setTargetPointer; - this.once = ability.once; - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.BLOCKER_DECLARED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.getSourceId())) { - if (setTargetPointer) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); - } - } - return true; - } - return false; - } - - @Override - public String getTriggerPhrase() { - return "When" + (once ? "" : "ever") + " {this} blocks" + (setTargetPointer ? " a creature, " : ", ") ; - } - - @Override - public BlocksTriggeredAbility copy() { - return new BlocksTriggeredAbility(this); - } -}