diff --git a/Mage.Sets/src/mage/sets/alarareborn/ShieldOfTheRighteous.java b/Mage.Sets/src/mage/sets/alarareborn/ShieldOfTheRighteous.java index 9f77c7164ac..391bea9ce1c 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/ShieldOfTheRighteous.java +++ b/Mage.Sets/src/mage/sets/alarareborn/ShieldOfTheRighteous.java @@ -28,7 +28,7 @@ package mage.sets.alarareborn; import java.util.UUID; -import mage.abilities.common.BlocksAttachedTriggeredAbility; +import mage.abilities.common.BlocksCreatureAttachedTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.common.SkipNextUntapTargetEffect; @@ -63,7 +63,7 @@ public class ShieldOfTheRighteous extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(VigilanceAbility.getInstance(), AttachmentType.EQUIPMENT))); // Whenever equipped creature blocks a creature, that creature doesn't untap during its controller's next untap step. - this.addAbility(new BlocksAttachedTriggeredAbility(new SkipNextUntapTargetEffect("that creature"), "equipped", false, false, true)); + this.addAbility(new BlocksCreatureAttachedTriggeredAbility(new SkipNextUntapTargetEffect("that creature"), "equipped", false, false, true)); // Equip {2} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2), new TargetControlledCreaturePermanent())); diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KaijinOfTheVanishingTouch.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KaijinOfTheVanishingTouch.java index 9f06930ba5b..9756b94ef2d 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/KaijinOfTheVanishingTouch.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/KaijinOfTheVanishingTouch.java @@ -33,7 +33,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.BlocksTriggeredAbility; +import mage.abilities.common.BlocksCreatureTriggeredAbility; import mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; @@ -61,7 +61,7 @@ public class KaijinOfTheVanishingTouch extends CardImpl { this.addAbility(new AttacksTriggeredAbility(new CreateTokenEffect(new CatSoldierCreatureToken(), 1, false, true), false)); // Whenever Brimaz blocks a creature, put a 1/1 white Cat Soldier creature token with vigilance onto the battlefield blocking that creature. - this.addAbility(new BlocksTriggeredAbility(new BrimazKingOfOreskosEffect(), false, true)); + this.addAbility(new BlocksCreatureTriggeredAbility(new BrimazKingOfOreskosEffect(), false, true)); } public BrimazKingOfOreskos(final BrimazKingOfOreskos card) { diff --git a/Mage.Sets/src/mage/sets/conflux/Meglonoth.java b/Mage.Sets/src/mage/sets/conflux/Meglonoth.java index ed87130a4ba..d5545eacace 100644 --- a/Mage.Sets/src/mage/sets/conflux/Meglonoth.java +++ b/Mage.Sets/src/mage/sets/conflux/Meglonoth.java @@ -30,7 +30,7 @@ package mage.sets.conflux; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.BlocksTriggeredAbility; +import mage.abilities.common.BlocksCreatureTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.VigilanceAbility; import mage.abilities.keyword.TrampleAbility; @@ -65,7 +65,7 @@ public class Meglonoth extends CardImpl { this.addAbility(TrampleAbility.getInstance()); // Whenever Meglonoth blocks a creature, Meglonoth deals damage to that creature's controller equal to Meglonoth's power. - this.addAbility(new BlocksTriggeredAbility(new MeglonothEffect(), false, true)); + this.addAbility(new BlocksCreatureTriggeredAbility(new MeglonothEffect(), false, true)); } diff --git a/Mage.Sets/src/mage/sets/darkascension/FavorOfTheWoods.java b/Mage.Sets/src/mage/sets/darkascension/FavorOfTheWoods.java index bef3aee5e09..dbc7f47e6e5 100644 --- a/Mage.Sets/src/mage/sets/darkascension/FavorOfTheWoods.java +++ b/Mage.Sets/src/mage/sets/darkascension/FavorOfTheWoods.java @@ -61,7 +61,7 @@ public class FavorOfTheWoods extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); // Whenever enchanted creature blocks, you gain 3 life. - this.addAbility(new BlocksAttachedTriggeredAbility(new GainLifeEffect(3), "equipped", false)); + this.addAbility(new BlocksAttachedTriggeredAbility(new GainLifeEffect(3), "enchanted", false)); } public FavorOfTheWoods(final FavorOfTheWoods card) { diff --git a/Mage.Sets/src/mage/sets/magic2010/WallOfFrost.java b/Mage.Sets/src/mage/sets/magic2010/WallOfFrost.java index a0c1900d403..440f522f2be 100644 --- a/Mage.Sets/src/mage/sets/magic2010/WallOfFrost.java +++ b/Mage.Sets/src/mage/sets/magic2010/WallOfFrost.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.common.BlocksTriggeredAbility; +import mage.abilities.common.BlocksCreatureTriggeredAbility; import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.keyword.DefenderAbility; import mage.cards.CardImpl; @@ -51,7 +51,7 @@ public class WallOfFrost extends CardImpl { this.addAbility(DefenderAbility.getInstance()); // Whenever Wall of Frost blocks a creature, that creature doesn't untap during its controller's next untap step. - this.addAbility(new BlocksTriggeredAbility(new SkipNextUntapTargetEffect("that creature"), false, true)); + this.addAbility(new BlocksCreatureTriggeredAbility(new SkipNextUntapTargetEffect("that creature"), false, true)); } public WallOfFrost(final WallOfFrost card) { diff --git a/Mage.Sets/src/mage/sets/magic2011/GoldenglowMoth.java b/Mage.Sets/src/mage/sets/magic2011/GoldenglowMoth.java index 62c47d48581..481bc9204af 100644 --- a/Mage.Sets/src/mage/sets/magic2011/GoldenglowMoth.java +++ b/Mage.Sets/src/mage/sets/magic2011/GoldenglowMoth.java @@ -51,8 +51,10 @@ public class GoldenglowMoth extends CardImpl { this.color.setWhite(true); this.power = new MageInt(0); this.toughness = new MageInt(1); - + + // Flying this.addAbility(FlyingAbility.getInstance()); + // Whenever Goldenglow Moth blocks, you may gain 4 life. this.addAbility(new BlocksTriggeredAbility(new GainLifeEffect(4), true)); } diff --git a/Mage.Sets/src/mage/sets/magic2012/PrideGuardian.java b/Mage.Sets/src/mage/sets/magic2012/PrideGuardian.java index ec90b127abd..79153df3aa5 100644 --- a/Mage.Sets/src/mage/sets/magic2012/PrideGuardian.java +++ b/Mage.Sets/src/mage/sets/magic2012/PrideGuardian.java @@ -51,7 +51,9 @@ public class PrideGuardian extends CardImpl { this.color.setWhite(true); this.power = new MageInt(0); this.toughness = new MageInt(3); + this.addAbility(DefenderAbility.getInstance()); + // Whenever Pride Guardian blocks, you gain 3 life. this.addAbility(new BlocksTriggeredAbility(new GainLifeEffect(3), false)); } diff --git a/Mage.Sets/src/mage/sets/mirrodin/PsychicMembrane.java b/Mage.Sets/src/mage/sets/mirrodin/PsychicMembrane.java index 7c37b49bf63..df435d81cc2 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/PsychicMembrane.java +++ b/Mage.Sets/src/mage/sets/mirrodin/PsychicMembrane.java @@ -50,6 +50,8 @@ public class PsychicMembrane extends CardImpl { this.power = new MageInt(0); this.toughness = new MageInt(3); this.addAbility(DefenderAbility.getInstance()); + + // Whenever Psychic Membrane blocks, you may draw a card. this.addAbility(new BlocksTriggeredAbility(new DrawCardControllerEffect(1), true)); } diff --git a/Mage.Sets/src/mage/sets/tempest/EliteJavelineer.java b/Mage.Sets/src/mage/sets/tempest/EliteJavelineer.java index eeddf5ce191..f5cb33d8fc7 100644 --- a/Mage.Sets/src/mage/sets/tempest/EliteJavelineer.java +++ b/Mage.Sets/src/mage/sets/tempest/EliteJavelineer.java @@ -52,8 +52,10 @@ public class EliteJavelineer extends CardImpl { this.color.setWhite(true); this.power = new MageInt(2); this.toughness = new MageInt(2); + + // Whenever Elite Javelineer blocks, it deals 1 damage to target attacking creature. Ability ability = new BlocksTriggeredAbility(new DamageTargetEffect(1), false); - ability.addTarget(new TargetCreaturePermanent(new FilterAttackingCreature())); + ability.addTarget(new TargetCreaturePermanent(new FilterAttackingCreature(), true)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/tenth/LoyalSentry.java b/Mage.Sets/src/mage/sets/tenth/LoyalSentry.java index ad319796663..f0be593538b 100644 --- a/Mage.Sets/src/mage/sets/tenth/LoyalSentry.java +++ b/Mage.Sets/src/mage/sets/tenth/LoyalSentry.java @@ -34,7 +34,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.BlocksTriggeredAbility; +import mage.abilities.common.BlocksCreatureTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.constants.Outcome; @@ -57,7 +57,8 @@ public class LoyalSentry extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(1); - this.addAbility(new BlocksTriggeredAbility(new LoyalSentryEffect(), false, true)); + // When Loyal Sentry blocks a creature, destroy that creature and Loyal Sentry. + this.addAbility(new BlocksCreatureTriggeredAbility(new LoyalSentryEffect(), false, true)); } public LoyalSentry (final LoyalSentry card) { @@ -82,11 +83,11 @@ class LoyalSentryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent p = game.getPermanent(source.getFirstTarget()); - Permanent s = game.getPermanent(source.getSourceId()); + Permanent p = game.getPermanent(source.getFirstTarget()); if (p != null) { p.destroy(source.getSourceId(), game, false); } + Permanent s = game.getPermanent(source.getSourceId()); if (s != null) { s.destroy(source.getSourceId(), game, false); } @@ -98,4 +99,4 @@ class LoyalSentryEffect extends OneShotEffect { return new LoyalSentryEffect(this); } -} \ No newline at end of file +} diff --git a/Mage/src/mage/abilities/common/BlocksAttachedTriggeredAbility.java b/Mage/src/mage/abilities/common/BlocksAttachedTriggeredAbility.java index ba7e08a2965..01eb08d2301 100644 --- a/Mage/src/mage/abilities/common/BlocksAttachedTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/BlocksAttachedTriggeredAbility.java @@ -1,6 +1,29 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * 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 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * 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.common; @@ -10,37 +33,21 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.target.targetpointer.FixedTarget; /** * * @author garnold */ public class BlocksAttachedTriggeredAbility extends TriggeredAbilityImpl{ - private boolean setFixedTargetPointer; private String attachedDescription; - private boolean setFixedTargetPointerToBlocked; public BlocksAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) { - this(effect, attachedDescription, optional, false); - } - - public BlocksAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer) { super(Zone.BATTLEFIELD, effect, optional); - this.setFixedTargetPointer = setFixedTargetPointer; this.attachedDescription = attachedDescription; } - - public BlocksAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer, boolean setFixedTargetPointerToBlocked) { - super(Zone.BATTLEFIELD, effect, optional); - this.setFixedTargetPointer = setFixedTargetPointer; - this.attachedDescription = attachedDescription; - this.setFixedTargetPointerToBlocked = setFixedTargetPointerToBlocked; - } public BlocksAttachedTriggeredAbility(final BlocksAttachedTriggeredAbility ability) { super(ability); - this.setFixedTargetPointer = ability.setFixedTargetPointer; this.attachedDescription = ability.attachedDescription; } @@ -51,19 +58,9 @@ public class BlocksAttachedTriggeredAbility extends TriggeredAbilityImpl{ + private boolean setFixedTargetPointer; + private String attachedDescription; + private boolean setFixedTargetPointerToBlocked; + + public BlocksCreatureAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional) { + this(effect, attachedDescription, optional, false); + } + + public BlocksCreatureAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer) { + super(Zone.BATTLEFIELD, effect, optional); + this.setFixedTargetPointer = setFixedTargetPointer; + this.attachedDescription = attachedDescription; + } + + public BlocksCreatureAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean setFixedTargetPointer, boolean setFixedTargetPointerToBlocked) { + super(Zone.BATTLEFIELD, effect, optional); + this.setFixedTargetPointer = setFixedTargetPointer; + this.attachedDescription = attachedDescription; + this.setFixedTargetPointerToBlocked = setFixedTargetPointerToBlocked; + } + + public BlocksCreatureAttachedTriggeredAbility(final BlocksCreatureAttachedTriggeredAbility ability) { + super(ability); + this.setFixedTargetPointer = ability.setFixedTargetPointer; + this.attachedDescription = ability.attachedDescription; + } + + @Override + public BlocksCreatureAttachedTriggeredAbility copy() { + return new BlocksCreatureAttachedTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) { + Permanent p = game.getPermanent(event.getSourceId()); + if (p != null && p.getAttachments().contains(this.getSourceId())) { + if (setFixedTargetPointer) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getPlayerId())); + } + } + if (setFixedTargetPointerToBlocked) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + } + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever " + attachedDescription + " creature blocks a creature, " + super.getRule(); + } +} diff --git a/Mage/src/mage/abilities/common/BlocksCreatureTriggeredAbility.java b/Mage/src/mage/abilities/common/BlocksCreatureTriggeredAbility.java new file mode 100644 index 00000000000..3310cbb31ea --- /dev/null +++ b/Mage/src/mage/abilities/common/BlocksCreatureTriggeredAbility.java @@ -0,0 +1,82 @@ +/* + * 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 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * 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.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.game.events.GameEvent.EventType; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class BlocksCreatureTriggeredAbility extends TriggeredAbilityImpl { + + private boolean setTargetPointer; + + public BlocksCreatureTriggeredAbility(Effect effect, boolean optional) { + this(effect, optional, false); + } + + public BlocksCreatureTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { + super(Zone.BATTLEFIELD, effect, optional); + this.setTargetPointer = setTargetPointer; + } + + public BlocksCreatureTriggeredAbility(final BlocksCreatureTriggeredAbility ability) { + super(ability); + this.setTargetPointer = ability.setTargetPointer; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.BLOCKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { + if (setTargetPointer) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId())); + } + } + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever {this} blocks a creature, " + super.getRule(); + } + + @Override + public BlocksCreatureTriggeredAbility copy() { + return new BlocksCreatureTriggeredAbility(this); + } +} diff --git a/Mage/src/mage/abilities/common/BlocksTriggeredAbility.java b/Mage/src/mage/abilities/common/BlocksTriggeredAbility.java index 75aeba6e02f..008aec38c55 100644 --- a/Mage/src/mage/abilities/common/BlocksTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/BlocksTriggeredAbility.java @@ -33,7 +33,6 @@ import mage.abilities.effects.Effect; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; -import mage.target.targetpointer.FixedTarget; /** * @@ -41,7 +40,7 @@ import mage.target.targetpointer.FixedTarget; */ public class BlocksTriggeredAbility extends TriggeredAbilityImpl { - private boolean fixedTargetPointer; +// private boolean fixedTargetPointer; public BlocksTriggeredAbility(Effect effect, boolean optional) { this(effect, optional, false); @@ -49,22 +48,17 @@ public class BlocksTriggeredAbility extends TriggeredAbilityImpl