From 3d0cd99655e37956bb323a2fb5ba00b30971bf28 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Tue, 11 Aug 2020 08:25:43 -0500 Subject: [PATCH] - Refactor EnchantedCreatureBlockedTriggeredAbility to BecomesBlockedAttachedTriggeredAbility --- Mage.Sets/src/mage/cards/b/BestialFury.java | 4 +- .../src/mage/cards/i/Insubordination.java | 2 +- Mage.Sets/src/mage/cards/l/LaccolithRig.java | 4 +- ...ecomesBlockedAttachedTriggeredAbility.java | 52 +++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/common/BecomesBlockedAttachedTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/b/BestialFury.java b/Mage.Sets/src/mage/cards/b/BestialFury.java index 9cd023b430..fd3c4777a1 100644 --- a/Mage.Sets/src/mage/cards/b/BestialFury.java +++ b/Mage.Sets/src/mage/cards/b/BestialFury.java @@ -4,7 +4,7 @@ package mage.cards.b; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.EnchantedCreatureBlockedTriggeredAbility; +import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility; import mage.abilities.effects.common.AttachEffect; @@ -46,7 +46,7 @@ public final class BestialFury extends CardImpl { new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(new DrawCardSourceControllerEffect(1), Duration.OneUse)), false)); // Whenever enchanted creature becomes blocked, it gets +4/+0 and gains trample until end of turn. - Ability pumpAbility = new EnchantedCreatureBlockedTriggeredAbility(new BoostEnchantedEffect(4, 0, Duration.EndOfTurn), false); + Ability pumpAbility = new BecomesBlockedAttachedTriggeredAbility(new BoostEnchantedEffect(4, 0, Duration.EndOfTurn), false); pumpAbility.addEffect(new GainAbilityAttachedEffect(TrampleAbility.getInstance(), AttachmentType.AURA, Duration.EndOfTurn)); diff --git a/Mage.Sets/src/mage/cards/i/Insubordination.java b/Mage.Sets/src/mage/cards/i/Insubordination.java index 0ccf786040..7bfa687579 100644 --- a/Mage.Sets/src/mage/cards/i/Insubordination.java +++ b/Mage.Sets/src/mage/cards/i/Insubordination.java @@ -32,7 +32,7 @@ public final class Insubordination extends CardImpl { // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/l/LaccolithRig.java b/Mage.Sets/src/mage/cards/l/LaccolithRig.java index 13c6504fb9..8cbf63980d 100644 --- a/Mage.Sets/src/mage/cards/l/LaccolithRig.java +++ b/Mage.Sets/src/mage/cards/l/LaccolithRig.java @@ -3,7 +3,7 @@ package mage.cards.l; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.EnchantedCreatureBlockedTriggeredAbility; +import mage.abilities.common.BecomesBlockedAttachedTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; @@ -41,7 +41,7 @@ public final class LaccolithRig extends CardImpl { this.addAbility(ability); // Whenever enchanted creature becomes blocked, you may have it deal damage equal to its power to target creature. If you do, the first creature assigns no combat damage this turn. - Ability ability2 = new EnchantedCreatureBlockedTriggeredAbility(new LaccolithRigEffect(), true); + Ability ability2 = new BecomesBlockedAttachedTriggeredAbility(new LaccolithRigEffect(), true); ability2.addTarget(new TargetCreaturePermanent()); Effect effect = new GainAbilityTargetEffect(new SimpleStaticAbility(Zone.BATTLEFIELD, new AssignNoCombatDamageSourceEffect(Duration.Custom, true).setText("")), Duration.EndOfTurn, "If you do, the first creature assigns no combat damage this turn"); ability2.addEffect(effect); diff --git a/Mage/src/main/java/mage/abilities/common/BecomesBlockedAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesBlockedAttachedTriggeredAbility.java new file mode 100644 index 0000000000..4aa0aea4aa --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/BecomesBlockedAttachedTriggeredAbility.java @@ -0,0 +1,52 @@ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author L_J + */ +public class BecomesBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl { + + public BecomesBlockedAttachedTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public BecomesBlockedAttachedTriggeredAbility(final BecomesBlockedAttachedTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CREATURE_BLOCKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent equipment = game.getPermanent(sourceId); + if (equipment != null && equipment.getAttachedTo() != null) { + Permanent equipped = game.getPermanent(equipment.getAttachedTo()); + if (equipped.getId().equals(event.getTargetId())) { + getEffects().get(1).setTargetPointer(new FixedTarget(equipped, game)); + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever enchanted creature becomes blocked, " + super.getRule(); + } + + @Override + public BecomesBlockedAttachedTriggeredAbility copy() { + return new BecomesBlockedAttachedTriggeredAbility(this); + } +}