diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java new file mode 100644 index 0000000000..e8a9f89e3c --- /dev/null +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HeartlessHidetsugu.java @@ -0,0 +1,107 @@ +/* + * 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.betrayersofkamigawa; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author LevelX2 + */ +public class HeartlessHidetsugu extends CardImpl { + + public HeartlessHidetsugu(UUID ownerId) { + super(ownerId, 107, "Heartless Hidetsugu", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{R}{R}"); + this.expansionSetCode = "BOK"; + this.supertype.add("Legendary"); + this.subtype.add("Ogre"); + this.subtype.add("Shaman"); + + this.color.setRed(true); + this.power = new MageInt(4); + this.toughness = new MageInt(3); + + // {tap}: Heartless Hidetsugu deals damage to each player equal to half that player's life total, rounded down. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new HeartlessHidetsuguDamageEffect(), new TapSourceCost())); + + } + + public HeartlessHidetsugu(final HeartlessHidetsugu card) { + super(card); + } + + @Override + public HeartlessHidetsugu copy() { + return new HeartlessHidetsugu(this); + } +} + +class HeartlessHidetsuguDamageEffect extends OneShotEffect { + + public HeartlessHidetsuguDamageEffect() { + super(Outcome.Detriment); + this.staticText = "{this} deals damage to each player equal to half that player's life total, rounded down"; + } + + public HeartlessHidetsuguDamageEffect(final HeartlessHidetsuguDamageEffect effect) { + super(effect); + } + + @Override + public HeartlessHidetsuguDamageEffect copy() { + return new HeartlessHidetsuguDamageEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + for (UUID playerId : controller.getInRange()) { + Player player = game.getPlayer(playerId); + if (player != null) { + int damage = player.getLife() / 2; + player.damage(damage, source.getSourceId(), game, false, true); + } + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/HundredTalonStrike.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HundredTalonStrike.java new file mode 100644 index 0000000000..826d31c5ad --- /dev/null +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/HundredTalonStrike.java @@ -0,0 +1,86 @@ +/* + * 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.betrayersofkamigawa; + +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continious.BoostTargetEffect; +import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.keyword.FirstStrikeAbility; +import mage.abilities.keyword.SpliceOntoArcaneAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ColorPredicate; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.target.common.TargetControlledCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class HundredTalonStrike extends CardImpl { + + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped white creature you control"); + static { + filter.add(Predicates.not(new TappedPredicate())); + filter.add(new ColorPredicate(ObjectColor.WHITE)); + } + + public HundredTalonStrike(UUID ownerId) { + super(ownerId, 8, "Hundred-Talon Strike", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}"); + this.expansionSetCode = "BOK"; + this.subtype.add("Arcane"); + + this.color.setWhite(true); + + // Target creature gets +1/+0 and gains first strike until end of turn. + Effect effect = new BoostTargetEffect(1,0, Duration.EndOfTurn); + effect.setText("Target creature gets +1/+0"); + this.getSpellAbility().addEffect(effect); + effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn); + effect.setText("and gains first strike until end of turn"); + this.getSpellAbility().addEffect(effect); + // Splice onto Arcane-Tap an untapped white creature you control. + this.addAbility(new SpliceOntoArcaneAbility(new TapTargetCost(new TargetControlledCreaturePermanent(1,1,filter,false,true)))); + } + + public HundredTalonStrike(final HundredTalonStrike card) { + super(card); + } + + @Override + public HundredTalonStrike copy() { + return new HundredTalonStrike(this); + } +} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/InTheWebOfWar.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/InTheWebOfWar.java new file mode 100644 index 0000000000..3fcd290be2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/InTheWebOfWar.java @@ -0,0 +1,76 @@ +/* + * 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.betrayersofkamigawa; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continious.BoostTargetEffect; +import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; + +/** + * + * @author LevelX2 + */ +public class InTheWebOfWar extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a creature"); + + public InTheWebOfWar(UUID ownerId) { + super(ownerId, 108, "In the Web of War", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}{R}"); + this.expansionSetCode = "BOK"; + + this.color.setRed(true); + + // Whenever a creature enters the battlefield under your control, it gets +2/+0 and gains haste until end of turn. + Effect effect = new BoostTargetEffect(2,0, Duration.EndOfTurn); + effect.setText("it gets +2/+0"); + Ability ability = new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filter, false, true, null); + effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); + effect.setText("and gains haste until end of turn"); + ability.addEffect(effect); + this.addAbility(ability); + } + + public InTheWebOfWar(final InTheWebOfWar card) { + super(card); + } + + @Override + public InTheWebOfWar copy() { + return new InTheWebOfWar(this); + } +} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/OgreRecluse.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/OgreRecluse.java new file mode 100644 index 0000000000..35eb3adac2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/OgreRecluse.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.betrayersofkamigawa; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.SpellCastAllTriggeredAbility; +import mage.abilities.effects.common.TapSourceEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; + +/** + * + * @author LevelX2 + */ +public class OgreRecluse extends CardImpl { + + public OgreRecluse(UUID ownerId) { + super(ownerId, 113, "Ogre Recluse", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{R}"); + this.expansionSetCode = "BOK"; + this.subtype.add("Ogre"); + this.subtype.add("Warrior"); + + this.color.setRed(true); + this.power = new MageInt(5); + this.toughness = new MageInt(4); + + // Whenever a player casts a spell, tap Ogre Recluse. + this.addAbility(new SpellCastAllTriggeredAbility(new TapSourceEffect(), false)); + } + + public OgreRecluse(final OgreRecluse card) { + super(card); + } + + @Override + public OgreRecluse copy() { + return new OgreRecluse(this); + } +} diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/YomijiWhoBarsTheWay.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/YomijiWhoBarsTheWay.java new file mode 100644 index 0000000000..37d9fb1c93 --- /dev/null +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/YomijiWhoBarsTheWay.java @@ -0,0 +1,78 @@ +/* + * 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.betrayersofkamigawa; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.PutIntoGraveFromBattlefieldAllTriggeredAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SupertypePredicate; +import mage.filter.predicate.permanent.AnotherPredicate; + +/** + * + * @author LevelX2 + */ +public class YomijiWhoBarsTheWay extends CardImpl { + + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("a legendary permanent other than Yomiji, Who Bars the Way"); + static { + filter.add(new AnotherPredicate()); + filter.add(new SupertypePredicate("Legendary")); + } + + public YomijiWhoBarsTheWay(UUID ownerId) { + super(ownerId, 30, "Yomiji, Who Bars the Way", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{5}{W}{W}"); + this.expansionSetCode = "BOK"; + this.supertype.add("Legendary"); + this.subtype.add("Spirit"); + + this.color.setWhite(true); + this.power = new MageInt(4); + this.toughness = new MageInt(4); + + // Whenever a legendary permanent other than Yomiji, Who Bars the Way is put into a graveyard from the battlefield, return that card to its owner's hand. + Effect effect = new ReturnToHandTargetEffect(); + effect.setText("return that card to its owner's hand"); + this.addAbility(new PutIntoGraveFromBattlefieldAllTriggeredAbility(effect, false, filter, true)); + } + + public YomijiWhoBarsTheWay(final YomijiWhoBarsTheWay card) { + super(card); + } + + @Override + public YomijiWhoBarsTheWay copy() { + return new YomijiWhoBarsTheWay(this); + } +} diff --git a/Mage/src/mage/abilities/common/EntersBattlefieldControlledTriggeredAbility.java b/Mage/src/mage/abilities/common/EntersBattlefieldControlledTriggeredAbility.java index ceb90a2ff0..598c5134e1 100644 --- a/Mage/src/mage/abilities/common/EntersBattlefieldControlledTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/EntersBattlefieldControlledTriggeredAbility.java @@ -64,7 +64,11 @@ public class EntersBattlefieldControlledTriggeredAbility extends EntersBattlefie } public EntersBattlefieldControlledTriggeredAbility(Zone zone, Effect effect, FilterPermanent filter, boolean optional, String rule) { - super(zone, effect, filter, optional, rule, true); + this(zone, effect, filter, optional, false, rule); + } + + public EntersBattlefieldControlledTriggeredAbility(Zone zone, Effect effect, FilterPermanent filter, boolean optional, boolean setTargetPointer, String rule) { + super(zone, effect, filter, optional, setTargetPointer, rule, true); } public EntersBattlefieldControlledTriggeredAbility(EntersBattlefieldControlledTriggeredAbility ability) { diff --git a/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java b/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java new file mode 100644 index 0000000000..a88a8cf7b1 --- /dev/null +++ b/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldAllTriggeredAbility.java @@ -0,0 +1,89 @@ +/* + * 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.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +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.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ +public class PutIntoGraveFromBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl { + + private FilterPermanent filter; + private boolean setTargetPointer; + + public PutIntoGraveFromBattlefieldAllTriggeredAbility(Effect effect, boolean optional, FilterPermanent filter, boolean setTargetPointer) { + super(Zone.BATTLEFIELD, effect, optional); + this.filter = filter; + } + + public PutIntoGraveFromBattlefieldAllTriggeredAbility(final PutIntoGraveFromBattlefieldAllTriggeredAbility ability) { + super(ability); + this.filter = ability.filter; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == EventType.ZONE_CHANGE) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + if (zEvent.getFromZone() == Zone.BATTLEFIELD + && zEvent.getToZone() == Zone.GRAVEYARD) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (filter.match(permanent, game)) { + if (setTargetPointer) { + for (Effect effect :this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getSourceId())); + } + } + return true; + } + } + } + return false; + } + + @Override + public String getRule() { + return new StringBuilder("Whenever ").append(filter.getMessage()).append(" is put into a graveyard from the battlefield, ").append(super.getRule()).toString(); + } + + @Override + public PutIntoGraveFromBattlefieldAllTriggeredAbility copy() { + return new PutIntoGraveFromBattlefieldAllTriggeredAbility(this); + } +}