diff --git a/Mage.Sets/src/mage/cards/b/BarrowBlade.java b/Mage.Sets/src/mage/cards/b/BarrowBlade.java new file mode 100644 index 00000000000..547c9b141e1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BarrowBlade.java @@ -0,0 +1,47 @@ +package mage.cards.b; + +import java.util.UUID; + +import mage.abilities.common.BlocksOrBlockedAttachedTriggeredAbility; +import mage.abilities.common.BlocksOrBlockedByCreatureAttachedTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continuous.BoostEquippedEffect; +import mage.abilities.effects.common.continuous.LoseAllAbilitiesTargetEffect; +import mage.abilities.keyword.EquipAbility; +import mage.constants.*; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; + +/** + * @author TiagoMDG + */ +public final class BarrowBlade extends CardImpl { + + public BarrowBlade(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}"); + + this.subtype.add(SubType.EQUIPMENT); + + // Equipped creature gets +1/+1. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 1))); + + // Whenever equipped creature blocks or becomes blocked by a creature, that creature loses all abilities until end of turn. + this.addAbility(new BlocksOrBlockedByCreatureAttachedTriggeredAbility( + new LoseAllAbilitiesTargetEffect(Duration.EndOfTurn) + .setText("that creature loses all abilities " + + "until end of turn."), AttachmentType.EQUIPMENT, false)); + + + // Equip {1} + this.addAbility(new EquipAbility(1, true)); + } + + private BarrowBlade(final BarrowBlade card) { + super(card); + } + + @Override + public BarrowBlade copy() { + return new BarrowBlade(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/f/Ferocity.java b/Mage.Sets/src/mage/cards/f/Ferocity.java index b6e7b203707..6470a256a0e 100644 --- a/Mage.Sets/src/mage/cards/f/Ferocity.java +++ b/Mage.Sets/src/mage/cards/f/Ferocity.java @@ -1,12 +1,14 @@ package mage.cards.f; import java.util.UUID; + import mage.abilities.common.BlocksOrBlockedAttachedTriggeredAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; @@ -15,7 +17,6 @@ import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; /** - * * @author awjackson */ public final class Ferocity extends CardImpl { @@ -34,6 +35,7 @@ public final class Ferocity extends CardImpl { // Whenever enchanted creature blocks or becomes blocked, you may put a +1/+1 counter on it. this.addAbility(new BlocksOrBlockedAttachedTriggeredAbility( new AddCountersTargetEffect(CounterType.P1P1.createInstance()).setText("put a +1/+1 counter on it"), + AttachmentType.AURA, true )); } diff --git a/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java b/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java index fe16bfd81c2..42cd4fe0c62 100644 --- a/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java +++ b/Mage.Sets/src/mage/cards/g/GiftOfTheWoods.java @@ -8,6 +8,7 @@ import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; @@ -33,7 +34,9 @@ public final class GiftOfTheWoods extends CardImpl { this.addAbility(new EnchantAbility(auraTarget)); // Whenever enchanted creature blocks or becomes blocked, it gets +0/+3 until end of turn and you gain 1 life. - Ability ability = new BlocksOrBlockedAttachedTriggeredAbility(new BoostTargetEffect(0, 3).setText("it gets +0/+3 until end of turn")); + Ability ability = new BlocksOrBlockedAttachedTriggeredAbility(new BoostTargetEffect(0, 3) + .setText("it gets +0/+3 until end of turn"), AttachmentType.AURA); + ability.addEffect(new GainLifeEffect(1).concatBy("and")); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index a678183288a..fce445a1c84 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -29,6 +29,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Bag End Porter", 153, Rarity.COMMON, mage.cards.b.BagEndPorter.class)); cards.add(new SetCardInfo("Banish from Edoras", 1, Rarity.COMMON, mage.cards.b.BanishFromEdoras.class)); cards.add(new SetCardInfo("Barad-dur", 253, Rarity.RARE, mage.cards.b.BaradDur.class)); + cards.add(new SetCardInfo("Barrow-Blade", 237, Rarity.UNCOMMON, mage.cards.b.BarrowBlade.class)); cards.add(new SetCardInfo("Battle-Scarred Goblin", 115, Rarity.COMMON, mage.cards.b.BattleScarredGoblin.class)); cards.add(new SetCardInfo("Bilbo's Ring", 298, Rarity.RARE, mage.cards.b.BilbosRing.class)); cards.add(new SetCardInfo("Bilbo, Retired Burglar", 196, Rarity.UNCOMMON, mage.cards.b.BilboRetiredBurglar.class)); diff --git a/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedAttachedTriggeredAbility.java index 703125af55a..95232d43408 100644 --- a/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedAttachedTriggeredAbility.java @@ -2,6 +2,7 @@ package mage.abilities.common; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; +import mage.constants.AttachmentType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; @@ -13,16 +14,22 @@ import mage.target.targetpointer.FixedTarget; */ public class BlocksOrBlockedAttachedTriggeredAbility extends TriggeredAbilityImpl { - public BlocksOrBlockedAttachedTriggeredAbility(Effect effect) { - this(effect, false); + // Type of attachment: AURA or EQUIPMENT + private final AttachmentType attachmentType; + + public BlocksOrBlockedAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType) { + this(effect, attachmentType, false); } - public BlocksOrBlockedAttachedTriggeredAbility(Effect effect, boolean optional) { + + public BlocksOrBlockedAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean optional) { super(Zone.BATTLEFIELD, effect, optional); - setTriggerPhrase("Whenever enchanted creature blocks or becomes blocked, "); + setTriggerPhrase("Whenever " + attachmentType.verb().toLowerCase() + " creature blocks or becomes blocked, "); + this.attachmentType = attachmentType; } public BlocksOrBlockedAttachedTriggeredAbility(final BlocksOrBlockedAttachedTriggeredAbility ability) { super(ability); + this.attachmentType = ability.attachmentType; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedByCreatureAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedByCreatureAttachedTriggeredAbility.java new file mode 100644 index 00000000000..04d7aa53bf0 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/BlocksOrBlockedByCreatureAttachedTriggeredAbility.java @@ -0,0 +1,90 @@ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.AttachmentType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.targetpointer.FixedTarget; + +/** + * @author TiagoMDG + */ +public class BlocksOrBlockedByCreatureAttachedTriggeredAbility extends TriggeredAbilityImpl { + + // Type of attachment AURA or EQUIPMENT + private final AttachmentType attachmentType; + + // Controls if the effect should target the creature with the attachment or the blocking/blocked creature + private final boolean selfTarget; + + public BlocksOrBlockedByCreatureAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean selfTarget) { + this(effect, attachmentType, selfTarget, false); + } + + public BlocksOrBlockedByCreatureAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean selfTarget, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + setTriggerPhrase("Whenever " + attachmentType.verb().toLowerCase() + " creature blocks or becomes blocked, "); + this.attachmentType = attachmentType; + this.selfTarget = selfTarget; + } + + public BlocksOrBlockedByCreatureAttachedTriggeredAbility(final BlocksOrBlockedByCreatureAttachedTriggeredAbility ability) { + super(ability); + this.attachmentType = ability.attachmentType; + this.selfTarget = ability.selfTarget; + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.BLOCKER_DECLARED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + Permanent blockingCreature = game.getPermanent(event.getSourceId()); + Permanent blockedCreature = game.getPermanent(event.getTargetId()); + Permanent attachment = game.getPermanent(sourceId); + + if (attachment == null || blockingCreature == null || blockedCreature == null) { + return false; + } + + Permanent attachedCreature = game.getPermanent(attachment.getAttachedTo()); + + if (attachedCreature == null) { + return false; + } + + if (!selfTarget) { + if (blockedCreature.equals(attachedCreature)) { + getEffects().setTargetPointer(new FixedTarget(blockingCreature, game)); + return true; + } + + if (blockingCreature.equals(attachedCreature)) { + getEffects().setTargetPointer(new FixedTarget(blockedCreature, game)); + return true; + } + } else { + if (blockedCreature.equals(attachedCreature)) { + getEffects().setTargetPointer(new FixedTarget(blockedCreature, game)); + return true; + } + + if (blockingCreature.equals(attachedCreature)) { + getEffects().setTargetPointer(new FixedTarget(blockingCreature, game)); + return true; + } + } + return false; + } + + + @Override + public BlocksOrBlockedByCreatureAttachedTriggeredAbility copy() { + return new BlocksOrBlockedByCreatureAttachedTriggeredAbility(this); + } +}