From 3e3957e3236e7cc2a4a4e33babb07991ba22eb82 Mon Sep 17 00:00:00 2001 From: North Date: Wed, 18 May 2011 20:27:15 +0300 Subject: [PATCH] Cards added Improved getRule for TriggeredAbilityImpl --- .../sets/magic2011/LeylineOfVitality.java | 43 +------ .../sets/mirrodinbesieged/NeurokCommando.java | 67 ++++++++++ .../mage/sets/riseoftheeldrazi/KilnFiend.java | 66 ++++++++++ .../sets/riseoftheeldrazi/SoulsAttendant.java | 108 ++++++++++++++++ .../sets/scarsofmirrodin/Thrummingbird.java | 41 +------ .../src/mage/sets/zendikar/BloodSeeker.java | 65 ++++++++++ .../mage/abilities/TriggeredAbilityImpl.java | 13 +- ...tureEntersBattlefieldTriggeredAbility.java | 115 ++++++++++++++++++ .../InstantOrSorceryCastTriggeredAbility.java | 79 ++++++++++++ 9 files changed, 520 insertions(+), 77 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/mirrodinbesieged/NeurokCommando.java create mode 100644 Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java create mode 100644 Mage.Sets/src/mage/sets/riseoftheeldrazi/SoulsAttendant.java create mode 100644 Mage.Sets/src/mage/sets/zendikar/BloodSeeker.java create mode 100644 Mage/src/mage/abilities/common/CreatureEntersBattlefieldTriggeredAbility.java create mode 100644 Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java diff --git a/Mage.Sets/src/mage/sets/magic2011/LeylineOfVitality.java b/Mage.Sets/src/mage/sets/magic2011/LeylineOfVitality.java index 6f605038ce..b7f33d2159 100644 --- a/Mage.Sets/src/mage/sets/magic2011/LeylineOfVitality.java +++ b/Mage.Sets/src/mage/sets/magic2011/LeylineOfVitality.java @@ -33,18 +33,13 @@ import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; import mage.Constants.Zone; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.CreatureEntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.continious.BoostControlledEffect; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.keyword.LeylineAbility; import mage.cards.CardImpl; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.events.ZoneChangeEvent; -import mage.game.permanent.Permanent; /** * @@ -58,7 +53,8 @@ public class LeylineOfVitality extends CardImpl { this.color.setGreen(true); this.addAbility(LeylineAbility.getInstance()); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(0, 1, Duration.WhileOnBattlefield, FilterCreaturePermanent.getDefault(), false))); - this.addAbility(new LeylineOfVitalityAbility()); + + this.addAbility(new CreatureEntersBattlefieldTriggeredAbility(new GainLifeEffect(1), true)); } public LeylineOfVitality(final LeylineOfVitality card) { @@ -76,36 +72,3 @@ public class LeylineOfVitality extends CardImpl { } } - -class LeylineOfVitalityAbility extends TriggeredAbilityImpl { - - public LeylineOfVitalityAbility() { - super(Zone.BATTLEFIELD, new GainLifeEffect(1), true); - } - - public LeylineOfVitalityAbility(final LeylineOfVitalityAbility ability) { - super(ability); - } - - @Override - public LeylineOfVitalityAbility copy() { - return new LeylineOfVitalityAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).getToZone() == Zone.BATTLEFIELD) { - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent.getCardType().contains(CardType.CREATURE) && permanent.getControllerId().equals(this.controllerId)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a creature enters the battlefield under your control, " + super.getRule(); - } - -} diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/NeurokCommando.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/NeurokCommando.java new file mode 100644 index 0000000000..a84509a945 --- /dev/null +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/NeurokCommando.java @@ -0,0 +1,67 @@ +/* + * 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.sets.mirrodinbesieged; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.abilities.keyword.ShroudAbility; +import mage.cards.CardImpl; + +/** + * + * @author North + */ +public class NeurokCommando extends CardImpl { + + public NeurokCommando(UUID ownerId) { + super(ownerId, 28, "Neurok Commando", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{1}{U}{U}"); + this.expansionSetCode = "MBS"; + this.subtype.add("Human"); + this.subtype.add("Rogue"); + + this.color.setBlue(true); + this.power = new MageInt(2); + this.toughness = new MageInt(1); + + this.addAbility(ShroudAbility.getInstance()); + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DrawCardControllerEffect(1), true)); + } + + public NeurokCommando(final NeurokCommando card) { + super(card); + } + + @Override + public NeurokCommando copy() { + return new NeurokCommando(this); + } +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java new file mode 100644 index 0000000000..c205451749 --- /dev/null +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KilnFiend.java @@ -0,0 +1,66 @@ +/* + * 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.sets.riseoftheeldrazi; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.InstantOrSorceryCastTriggeredAbility; +import mage.abilities.effects.common.continious.BoostSourceEffect; +import mage.cards.CardImpl; + +/** + * + * @author North + */ +public class KilnFiend extends CardImpl { + + public KilnFiend(UUID ownerId) { + super(ownerId, 153, "Kiln Fiend", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{R}"); + this.expansionSetCode = "ROE"; + this.subtype.add("Elemental"); + this.subtype.add("Beast"); + + this.color.setRed(true); + this.power = new MageInt(1); + this.toughness = new MageInt(2); + + this.addAbility(new InstantOrSorceryCastTriggeredAbility(new BoostSourceEffect(3, 0, Duration.EndOfTurn), false)); + } + + public KilnFiend(final KilnFiend card) { + super(card); + } + + @Override + public KilnFiend copy() { + return new KilnFiend(this); + } +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/SoulsAttendant.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SoulsAttendant.java new file mode 100644 index 0000000000..dce2eb0869 --- /dev/null +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/SoulsAttendant.java @@ -0,0 +1,108 @@ +/* + * 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.sets.riseoftheeldrazi; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.events.ZoneChangeEvent; + +/** + * + * @author North + */ +public class SoulsAttendant extends CardImpl { + + public SoulsAttendant(UUID ownerId) { + super(ownerId, 44, "Soul's Attendant", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{W}"); + this.expansionSetCode = "ROE"; + this.subtype.add("Human"); + this.subtype.add("Cleric"); + + this.color.setWhite(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + this.addAbility(new AnotherCreatureEntersBattlefieldTriggeredAbility(new GainLifeEffect(1), true)); + } + + public SoulsAttendant(final SoulsAttendant card) { + super(card); + } + + @Override + public SoulsAttendant copy() { + return new SoulsAttendant(this); + } +} + +class AnotherCreatureEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl { + + public AnotherCreatureEntersBattlefieldTriggeredAbility(Effect effect) { + this(effect, false); + } + + public AnotherCreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public AnotherCreatureEntersBattlefieldTriggeredAbility(AnotherCreatureEntersBattlefieldTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getToZone() == Zone.BATTLEFIELD && zEvent.getTarget().getCardType().contains(Constants.CardType.CREATURE)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever another creature enters the battlefield, " + super.getRule(); + } + + @Override + public AnotherCreatureEntersBattlefieldTriggeredAbility copy() { + return new AnotherCreatureEntersBattlefieldTriggeredAbility(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/Thrummingbird.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/Thrummingbird.java index fa5ca925eb..3c192a0d0e 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/Thrummingbird.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/Thrummingbird.java @@ -30,21 +30,16 @@ package mage.sets.scarsofmirrodin; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.effects.common.counter.ProliferateEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.events.DamagedPlayerEvent; -import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; /** - * @author Loki, nantuko + * @author Loki, nantuko, North */ public class Thrummingbird extends CardImpl { @@ -53,11 +48,13 @@ public class Thrummingbird extends CardImpl { this.expansionSetCode = "SOM"; this.subtype.add("Bird"); this.subtype.add("Horror"); + this.color.setBlue(true); this.power = new MageInt(1); this.toughness = new MageInt(1); + this.addAbility(FlyingAbility.getInstance()); - this.addAbility(new ThrummingbirdTriggeredAbility()); + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ProliferateEffect(), false)); } public Thrummingbird(final Thrummingbird card) { @@ -69,31 +66,3 @@ public class Thrummingbird extends CardImpl { return new Thrummingbird(this); } } - -class ThrummingbirdTriggeredAbility extends TriggeredAbilityImpl { - ThrummingbirdTriggeredAbility() { - super(Constants.Zone.BATTLEFIELD, new ProliferateEffect()); - } - - ThrummingbirdTriggeredAbility(final ThrummingbirdTriggeredAbility ability) { - super(ability); - } - - @Override - public ThrummingbirdTriggeredAbility copy() { - return new ThrummingbirdTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event instanceof DamagedPlayerEvent) { - DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; - Permanent p = game.getPermanent(event.getSourceId()); - if (damageEvent.isCombatDamage() && p != null && p.getId().equals(this.getSourceId())) { - return true; - } - } - return false; - - } -} diff --git a/Mage.Sets/src/mage/sets/zendikar/BloodSeeker.java b/Mage.Sets/src/mage/sets/zendikar/BloodSeeker.java new file mode 100644 index 0000000000..65a09c846e --- /dev/null +++ b/Mage.Sets/src/mage/sets/zendikar/BloodSeeker.java @@ -0,0 +1,65 @@ +/* + * 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.sets.zendikar; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.common.CreatureEntersBattlefieldTriggeredAbility; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.cards.CardImpl; + +/** + * + * @author North + */ +public class BloodSeeker extends CardImpl { + + public BloodSeeker(UUID ownerId) { + super(ownerId, 80, "Blood Seeker", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}"); + this.expansionSetCode = "ZEN"; + this.subtype.add("Vampire"); + this.subtype.add("Shaman"); + + this.color.setBlack(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + this.addAbility(new CreatureEntersBattlefieldTriggeredAbility(new LoseLifeTargetEffect(1), true, true)); + } + + public BloodSeeker(final BloodSeeker card) { + super(card); + } + + @Override + public BloodSeeker copy() { + return new BloodSeeker(this); + } +} diff --git a/Mage/src/mage/abilities/TriggeredAbilityImpl.java b/Mage/src/mage/abilities/TriggeredAbilityImpl.java index 612feb9ff5..744d94305d 100644 --- a/Mage/src/mage/abilities/TriggeredAbilityImpl.java +++ b/Mage/src/mage/abilities/TriggeredAbilityImpl.java @@ -100,6 +100,17 @@ public abstract class TriggeredAbilityImpl> ex @Override public String getRule() { - return (optional ? "you may " : "") + super.getRule(true); + String superRule = super.getRule(true); + StringBuilder sb = new StringBuilder(); + if (optional) { + sb.append("you may "); + } + if (!this.getTargets().isEmpty()) { + sb.append("have "); + } + sb.append(superRule.substring(0, 1).toLowerCase()); + sb.append(superRule.substring(1)); + + return sb.toString(); } } diff --git a/Mage/src/mage/abilities/common/CreatureEntersBattlefieldTriggeredAbility.java b/Mage/src/mage/abilities/common/CreatureEntersBattlefieldTriggeredAbility.java new file mode 100644 index 0000000000..b68fb76033 --- /dev/null +++ b/Mage/src/mage/abilities/common/CreatureEntersBattlefieldTriggeredAbility.java @@ -0,0 +1,115 @@ +/* + * 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.CardType; +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.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPlayer; + +/** + * + * @author North + */ +public class CreatureEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl { + + private boolean opponentController; + + /** + * optional = false
+ * opponentController = false + * + * @param effect + */ + public CreatureEntersBattlefieldTriggeredAbility(Effect effect) { + this(effect, false, false); + } + + /** + * opponentController = false + * + * @param effect + * @param optional + */ + public CreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + opponentController = false; + } + + /** + * + * @param effect + * @param optional + * @param opponentController + */ + public CreatureEntersBattlefieldTriggeredAbility(Effect effect, boolean optional, boolean opponentController) { + super(Zone.BATTLEFIELD, effect, optional); + this.opponentController = opponentController; + this.addTarget(new TargetPlayer()); + } + + public CreatureEntersBattlefieldTriggeredAbility(CreatureEntersBattlefieldTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.ZONE_CHANGE) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD + && permanent.getCardType().contains(CardType.CREATURE) + && (permanent.getControllerId().equals(this.controllerId) ^ opponentController)) { + if (opponentController) { + this.getTargets().get(0).add(permanent.getControllerId(), game); + } else { + this.getTargets().remove(0); + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever a creature enters the battlefield under " + + (opponentController ? "an opponent's control, " : "your control, ") + + super.getRule(); + } + + @Override + public CreatureEntersBattlefieldTriggeredAbility copy() { + return new CreatureEntersBattlefieldTriggeredAbility(this); + } +} diff --git a/Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java b/Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java new file mode 100644 index 0000000000..33a58782e9 --- /dev/null +++ b/Mage/src/mage/abilities/common/InstantOrSorceryCastTriggeredAbility.java @@ -0,0 +1,79 @@ +/* + * 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.CardType; +import mage.Constants.Zone; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.cards.Card; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.target.TargetSpell; + +/** + * + * @author North + */ +public class InstantOrSorceryCastTriggeredAbility extends TriggeredAbilityImpl { + + public InstantOrSorceryCastTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public InstantOrSorceryCastTriggeredAbility(final InstantOrSorceryCastTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.CAST_SPELL) { + Card card = game.getCard(event.getSourceId()); + if (card.getOwnerId().equals(this.getControllerId()) + && (card.getCardType().contains(CardType.SORCERY) + || card.getCardType().contains(CardType.INSTANT))) { + TargetSpell target = new TargetSpell(); + target.add(event.getSourceId(), game); + this.addTarget(target); + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever you cast an instant or sorcery spell, " + super.getRule(); + } + + @Override + public InstantOrSorceryCastTriggeredAbility copy() { + return new InstantOrSorceryCastTriggeredAbility(this); + } +}