diff --git a/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java b/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java index 2f8fdfa5f3..5889571fbd 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java +++ b/Mage.Sets/src/mage/sets/alarareborn/EnigmaSphinx.java @@ -34,7 +34,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.CascadeAbility; import mage.abilities.keyword.FlyingAbility; @@ -65,7 +65,7 @@ public class EnigmaSphinx extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // When Enigma Sphinx is put into your graveyard from the battlefield, put it into your library third from the top. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new EnigmaSphinxEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new EnigmaSphinxEffect())); // Cascade this.addAbility(new CascadeAbility()); diff --git a/Mage.Sets/src/mage/sets/apocalypse/LegacyWeapon.java b/Mage.Sets/src/mage/sets/apocalypse/LegacyWeapon.java index a035cba624..03019a03a4 100644 --- a/Mage.Sets/src/mage/sets/apocalypse/LegacyWeapon.java +++ b/Mage.Sets/src/mage/sets/apocalypse/LegacyWeapon.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.Zone; -import mage.abilities.common.PutIntoGraveFromAnywhereAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.ExileTargetEffect; @@ -57,7 +57,7 @@ public class LegacyWeapon extends CardImpl { ability.addTarget(new TargetPermanent()); this.addAbility(ability); // If Legacy Weapon would be put into a graveyard from anywhere, reveal Legacy Weapon and shuffle it into its owner's library instead. - this.addAbility(new PutIntoGraveFromAnywhereAbility(new RevealAndShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceAbility(new RevealAndShuffleIntoLibrarySourceEffect())); } public LegacyWeapon(final LegacyWeapon card) { diff --git a/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java b/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java index 2318137d54..29bffafa06 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/TamiyoTheMoonSage.java @@ -27,38 +27,38 @@ */ package mage.sets.avacynrestored; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.EntersBattlefieldAbility; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.GetEmblemEffect; +import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect; import mage.abilities.effects.common.continious.MaximumHandSizeControllerEffect.HandSizeModification; import mage.abilities.effects.common.counter.AddCountersSourceEffect; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.SetTargetPointer; +import mage.constants.TargetController; +import mage.constants.Zone; import mage.counters.CounterType; +import mage.filter.FilterCard; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; import mage.game.command.Emblem; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; import mage.target.Target; import mage.target.TargetPermanent; import mage.target.TargetPlayer; -import mage.target.targetpointer.FixedTarget; - -import java.util.UUID; - /** * @@ -130,65 +130,6 @@ class TappedCreaturesControlledByTargetCount implements DynamicValue { } } -class TamiyoTheMoonSageTriggeredAbility extends TriggeredAbilityImpl { - - public TamiyoTheMoonSageTriggeredAbility() { - super(Zone.COMMAND, new TamiyoTheMoonSageEffect(), true); - } - - public TamiyoTheMoonSageTriggeredAbility(final TamiyoTheMoonSageTriggeredAbility ability) { - super(ability); - } - - @Override - public TamiyoTheMoonSageTriggeredAbility copy() { - return new TamiyoTheMoonSageTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && !card.isCopy() && card.getOwnerId().equals(this.getControllerId())) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId())); - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a card is put into your graveyard from anywhere, you may return it to your hand."; - } -} - -class TamiyoTheMoonSageEffect extends OneShotEffect { - - public TamiyoTheMoonSageEffect() { - super(Outcome.ReturnToHand); - this.staticText = "return it to your hand"; - } - - public TamiyoTheMoonSageEffect(final TamiyoTheMoonSageEffect effect) { - super(effect); - } - - @Override - public TamiyoTheMoonSageEffect copy() { - return new TamiyoTheMoonSageEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Card card = game.getCard(this.targetPointer.getFirst(game, source)); - if (card != null) { - return card.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return false; - } -} - /** * Emblem with "You have no maximum hand size" and "Whenever a card is put into your graveyard from anywhere, you may return it to your hand." */ @@ -198,6 +139,9 @@ class TamiyoTheMoonSageEmblem extends Emblem { this.setName("EMBLEM: Tamiyo, the Moon Sage"); Ability ability = new SimpleStaticAbility(Zone.COMMAND, new MaximumHandSizeControllerEffect(Integer.MAX_VALUE, Duration.EndOfGame, HandSizeModification.SET)); this.getAbilities().add(ability); - this.getAbilities().add(new TamiyoTheMoonSageTriggeredAbility()); + Effect effect = new ReturnToHandTargetEffect(); + effect.setText("return it to your hand"); + this.getAbilities().add(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + Zone.COMMAND, effect, true, new FilterCard("a card"), TargetController.YOU, SetTargetPointer.CARD)); } } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GodsEyeGateToTheReikai.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GodsEyeGateToTheReikai.java index 5bba4bc90d..4dea48f8b7 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/GodsEyeGateToTheReikai.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/GodsEyeGateToTheReikai.java @@ -30,7 +30,7 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.mana.ColorlessManaAbility; import mage.cards.CardImpl; @@ -49,7 +49,7 @@ public class GodsEyeGateToTheReikai extends CardImpl { // {tap}: Add {1} to your mana pool. this.addAbility(new ColorlessManaAbility()); // When Gods' Eye, Gate to the Reikai is put into a graveyard from the battlefield, put a 1/1 colorless Spirit creature token onto the battlefield. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new CreateTokenEffect(new SpiritToken(), 1), false)); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new CreateTokenEffect(new SpiritToken(), 1), false)); } public GodsEyeGateToTheReikai(final GodsEyeGateToTheReikai card) { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/OathkeeperTakenosDaisho.java b/Mage.Sets/src/mage/sets/championsofkamigawa/OathkeeperTakenosDaisho.java index a81e684e11..37366b98ed 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/OathkeeperTakenosDaisho.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/OathkeeperTakenosDaisho.java @@ -30,7 +30,7 @@ package mage.sets.championsofkamigawa; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DiesAttachedTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.Condition; import mage.abilities.condition.common.EquippedMatchesFilterCondition; @@ -77,7 +77,7 @@ public class OathkeeperTakenosDaisho extends CardImpl { new OathkeeperEquippedMatchesFilterCondition(filter), "")); // When Oathkeeper, Takeno's Daisho is put into a graveyard from the battlefield, exile equipped creature. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ExileEquippedEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ExileEquippedEffect())); // Equip {2} this.addAbility(new EquipAbility( Outcome.BoostCreature, new ManaCostsImpl("{2}"))); } diff --git a/Mage.Sets/src/mage/sets/commander/VulturousZombie.java b/Mage.Sets/src/mage/sets/commander/VulturousZombie.java index dc7c0b61e5..97a5ff150b 100644 --- a/Mage.Sets/src/mage/sets/commander/VulturousZombie.java +++ b/Mage.Sets/src/mage/sets/commander/VulturousZombie.java @@ -29,18 +29,14 @@ package mage.sets.commander; import java.util.UUID; import mage.MageInt; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; +import mage.constants.TargetController; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; /** * @@ -64,8 +60,8 @@ public class VulturousZombie extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // Whenever a card is put into an opponent's graveyard from anywhere, put a +1/+1 counter on Vulturous Zombie. - this.addAbility(new VulturousZombieTriggeredAbility()); - + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false, TargetController.OPPONENT)); } public VulturousZombie(final VulturousZombie card) { @@ -77,36 +73,3 @@ public class VulturousZombie extends CardImpl { return new VulturousZombie(this); } } - -class VulturousZombieTriggeredAbility extends TriggeredAbilityImpl { - - public VulturousZombieTriggeredAbility() { - super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); - } - - public VulturousZombieTriggeredAbility(final VulturousZombieTriggeredAbility ability) { - super(ability); - } - - @Override - public VulturousZombieTriggeredAbility copy() { - return new VulturousZombieTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && !card.isCopy() - && game.getOpponents(controllerId).contains(card.getOwnerId())) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a card is put into an opponent's graveyard from anywhere, put a +1/+1 counter on {this}."; - } -} diff --git a/Mage.Sets/src/mage/sets/commander2013/DeadwoodTreefolk.java b/Mage.Sets/src/mage/sets/commander2013/DeadwoodTreefolk.java index 7e2dad1d35..d0b108b7d9 100644 --- a/Mage.Sets/src/mage/sets/commander2013/DeadwoodTreefolk.java +++ b/Mage.Sets/src/mage/sets/commander2013/DeadwoodTreefolk.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.common.EntersBattlefieldOrDiesSourceTriggeredAbility; +import mage.abilities.common.EntersOrLeavesTheBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.VanishingSacrificeAbility; @@ -42,7 +42,6 @@ import mage.constants.Rarity; import mage.counters.CounterType; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.AnotherCardPredicate; -import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.Target; import mage.target.common.TargetCardInYourGraveyard; @@ -73,7 +72,7 @@ public class DeadwoodTreefolk extends CardImpl { this.addAbility(new VanishingUpkeepAbility(3)); this.addAbility(new VanishingSacrificeAbility()); // When Deadwood Treefolk enters the battlefield or leaves the battlefield, return another target creature card from your graveyard to your hand. - ability = new EntersBattlefieldOrDiesSourceTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false); + ability = new EntersOrLeavesTheBattlefieldSourceTriggeredAbility(new ReturnFromGraveyardToHandTargetEffect(), false); Target target = new TargetCardInYourGraveyard(filter); ability.addTarget(target); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/sets/commander2014/CrownOfDoom.java b/Mage.Sets/src/mage/sets/commander2014/CrownOfDoom.java index eeef0d72f0..d4aaae6e1c 100644 --- a/Mage.Sets/src/mage/sets/commander2014/CrownOfDoom.java +++ b/Mage.Sets/src/mage/sets/commander2014/CrownOfDoom.java @@ -74,7 +74,7 @@ public class CrownOfDoom extends CardImpl { // Whenever a creature attacks you or a planeswalker you control, it gets +2/+0 until end of turn. Effect effect = new BoostTargetEffect(2,0,Duration.EndOfTurn); effect.setText("it gets +2/+0 until end of turn"); - this.addAbility(new AttacksAllTriggeredAbility(effect, false, new FilterCreaturePermanent(), SetTargetPointer.CREATURE, true)); + this.addAbility(new AttacksAllTriggeredAbility(effect, false, new FilterCreaturePermanent(), SetTargetPointer.PERMANENT, true)); // {2}: Target player other than Crown of Doom's owner gains control of it. Activate this ability only during your turn. Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD, new CrownOfDoomEffect(), new ManaCostsImpl("{2}"), MyTurnCondition.getInstance()); diff --git a/Mage.Sets/src/mage/sets/commander2014/FoolsDemise.java b/Mage.Sets/src/mage/sets/commander2014/FoolsDemise.java index 712c349f3c..a44ac16e96 100644 --- a/Mage.Sets/src/mage/sets/commander2014/FoolsDemise.java +++ b/Mage.Sets/src/mage/sets/commander2014/FoolsDemise.java @@ -30,7 +30,7 @@ package mage.sets.commander2014; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DiesAttachedTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlAttachedEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; @@ -66,7 +66,7 @@ public class FoolsDemise extends CardImpl { this.addAbility(new DiesAttachedTriggeredAbility(new ReturnToBattlefieldUnderYourControlAttachedEffect(), "enchanted creature")); // When Fool's Demise is put into a graveyard from the battlefield, return Fool's Demise to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public FoolsDemise(final FoolsDemise card) { diff --git a/Mage.Sets/src/mage/sets/conflux/Progenitus.java b/Mage.Sets/src/mage/sets/conflux/Progenitus.java index 46cb6f8fac..8649a5c896 100644 --- a/Mage.Sets/src/mage/sets/conflux/Progenitus.java +++ b/Mage.Sets/src/mage/sets/conflux/Progenitus.java @@ -30,7 +30,7 @@ package mage.sets.conflux; import java.util.UUID; import mage.MageInt; import mage.MageObject; -import mage.abilities.common.PutIntoGraveFromAnywhereAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceAbility; import mage.abilities.effects.common.RevealAndShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.ProtectionAbility; import mage.cards.CardImpl; @@ -69,7 +69,7 @@ public class Progenitus extends CardImpl { // Protection from everything this.addAbility(new ProgenitusProtectionAbility()); // If Progenitus would be put into a graveyard from anywhere, reveal Progenitus and shuffle it into its owner's library instead. - this.addAbility(new PutIntoGraveFromAnywhereAbility(new RevealAndShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceAbility(new RevealAndShuffleIntoLibrarySourceEffect())); } public Progenitus(final Progenitus card) { diff --git a/Mage.Sets/src/mage/sets/darkascension/LostInTheWoods.java b/Mage.Sets/src/mage/sets/darkascension/LostInTheWoods.java index 318344c7fc..a7a9b10583 100644 --- a/Mage.Sets/src/mage/sets/darkascension/LostInTheWoods.java +++ b/Mage.Sets/src/mage/sets/darkascension/LostInTheWoods.java @@ -59,7 +59,7 @@ public class LostInTheWoods extends CardImpl { this.color.setGreen(true); // Whenever a creature attacks you or a planeswalker you control, reveal the top card of your library. If it's a Forest card, remove that creature from combat. Then put the revealed card on the bottom of your library. - this.addAbility(new AttacksAllTriggeredAbility(new LostInTheWoodsEffect(), true, new FilterCreaturePermanent(), SetTargetPointer.CREATURE, true)); + this.addAbility(new AttacksAllTriggeredAbility(new LostInTheWoodsEffect(), true, new FilterCreaturePermanent(), SetTargetPointer.PERMANENT, true)); } public LostInTheWoods(final LostInTheWoods card) { diff --git a/Mage.Sets/src/mage/sets/darksteel/DarksteelColossus.java b/Mage.Sets/src/mage/sets/darksteel/DarksteelColossus.java index 3a7b06bee3..a1aaebe1d5 100644 --- a/Mage.Sets/src/mage/sets/darksteel/DarksteelColossus.java +++ b/Mage.Sets/src/mage/sets/darksteel/DarksteelColossus.java @@ -33,7 +33,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.common.PutIntoGraveFromAnywhereAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceAbility; import mage.abilities.effects.common.RevealAndShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.abilities.keyword.TrampleAbility; @@ -58,7 +58,7 @@ public class DarksteelColossus extends CardImpl { this.addAbility(IndestructibleAbility.getInstance()); // If Darksteel Colossus would be put into a graveyard from anywhere, reveal Darksteel Colossus and shuffle it into its owner's library instead. - this.addAbility(new PutIntoGraveFromAnywhereAbility(new RevealAndShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceAbility(new RevealAndShuffleIntoLibrarySourceEffect())); } public DarksteelColossus(final DarksteelColossus card) { diff --git a/Mage.Sets/src/mage/sets/darksteel/SunderingTitan.java b/Mage.Sets/src/mage/sets/darksteel/SunderingTitan.java index 8964ada7fc..40e1cc019e 100644 --- a/Mage.Sets/src/mage/sets/darksteel/SunderingTitan.java +++ b/Mage.Sets/src/mage/sets/darksteel/SunderingTitan.java @@ -33,6 +33,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.EntersOrLeavesTheBattlefieldSourceTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -62,8 +63,7 @@ public class SunderingTitan extends CardImpl { this.toughness = new MageInt(10); // When Sundering Titan enters the battlefield or leaves the battlefield, choose a land of each basic land type, then destroy those lands. - this.addAbility(new EntersBattlefieldTriggeredAbility(new SunderingTitanDestroyLandEffect(), false)); - this.addAbility(new LeavesBattlefieldTriggeredAbility(new SunderingTitanDestroyLandEffect(), false)); + this.addAbility(new EntersOrLeavesTheBattlefieldSourceTriggeredAbility(new SunderingTitanDestroyLandEffect(), false)); } public SunderingTitan(final SunderingTitan card) { diff --git a/Mage.Sets/src/mage/sets/gatecrash/LazavDimirMastermind.java b/Mage.Sets/src/mage/sets/gatecrash/LazavDimirMastermind.java index 73dc3a5e96..64e3dec417 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/LazavDimirMastermind.java +++ b/Mage.Sets/src/mage/sets/gatecrash/LazavDimirMastermind.java @@ -28,25 +28,23 @@ package mage.sets.gatecrash; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.keyword.HexproofAbility; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Layer; import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.SetTargetPointer; import mage.constants.SubLayer; +import mage.constants.TargetController; +import mage.filter.common.FilterCreatureCard; 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; /** @@ -70,7 +68,10 @@ public class LazavDimirMastermind extends CardImpl { this.addAbility(HexproofAbility.getInstance()); // Whenever a creature card is put into an opponent's graveyard from anywhere, you may have Lazav, Dimir Mastermind become a copy of that card except its name is still Lazav, Dimir Mastermind, it's legendary in addition to its other types, and it gains hexproof and this ability. - this.addAbility(new CreatureCardPutOpponentGraveyardTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new LazavDimirEffect(), true, + new FilterCreatureCard("a creature card"), + TargetController.OPPONENT, SetTargetPointer.CARD)); } public LazavDimirMastermind(final LazavDimirMastermind card) { @@ -83,45 +84,6 @@ public class LazavDimirMastermind extends CardImpl { } } -class CreatureCardPutOpponentGraveyardTriggeredAbility extends TriggeredAbilityImpl { - - public CreatureCardPutOpponentGraveyardTriggeredAbility() { - super(Zone.BATTLEFIELD, new LazavDimirEffect(), true); - } - - public CreatureCardPutOpponentGraveyardTriggeredAbility(final CreatureCardPutOpponentGraveyardTriggeredAbility ability) { - super(ability); - } - - @Override - public CreatureCardPutOpponentGraveyardTriggeredAbility copy() { - return new CreatureCardPutOpponentGraveyardTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.ZONE_CHANGE - && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card == null) { - return false; - } - if (game.getOpponents(controllerId).contains(event.getPlayerId()) - && card.getCardType().contains(CardType.CREATURE)) { - // store the card id to copy - game.getState().setValue(new StringBuilder("CardToCopy").append(getSourceId().toString()).toString(), card.getId()); - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a creature card is put into an opponent's graveyard from anywhere, you may have {this} become a copy of that card except its name is still {this}, it's legendary in addition to its other types, and it gains hexproof and this ability."; - } -} - class LazavDimirEffect extends ContinuousEffectImpl { protected UUID IdOfCopiedCard; @@ -129,6 +91,7 @@ class LazavDimirEffect extends ContinuousEffectImpl { public LazavDimirEffect() { super(Duration.WhileOnBattlefield, Layer.CopyEffects_1, SubLayer.NA, Outcome.BecomeCreature); + staticText = "have {this} become a copy of that card except its name is still {this}, it's legendary in addition to its other types, and it gains hexproof and this ability"; } public LazavDimirEffect(final LazavDimirEffect effect) { @@ -144,17 +107,13 @@ class LazavDimirEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - Object object = game.getState().getValue(new StringBuilder("CardToCopy").append(source.getSourceId().toString()).toString()); - Card card = null; - if (object instanceof UUID) { - card = game.getCard((UUID) object); - } + Card card = game.getCard(getTargetPointer().getFirst(game, source)); Permanent permanent = game.getPermanent(source.getSourceId()); if (card == null || permanent == null) { return false; } - if (IdOfCopiedCard == null || !IdOfCopiedCard.equals((UUID) object)) { - IdOfCopiedCard = (UUID) object; + if (IdOfCopiedCard == null || !IdOfCopiedCard.equals(card.getId())) { + IdOfCopiedCard = card.getId(); cardToCopy = card.copy(); cardToCopy.assignNewId(); } @@ -184,7 +143,10 @@ class LazavDimirEffect extends ContinuousEffectImpl { } permanent.removeAllAbilities(source.getSourceId(), game); permanent.addAbility(HexproofAbility.getInstance(), source.getSourceId(), game); - permanent.addAbility(new CreatureCardPutOpponentGraveyardTriggeredAbility(), source.getSourceId(), game); + permanent.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new LazavDimirEffect(), true, + new FilterCreatureCard("a creature card"), + TargetController.OPPONENT, SetTargetPointer.CARD), source.getSourceId(), game); for (Ability ability : cardToCopy.getAbilities()) { if (!permanent.getAbilities().contains(ability)) { diff --git a/Mage.Sets/src/mage/sets/guildpact/HatchingPlans.java b/Mage.Sets/src/mage/sets/guildpact/HatchingPlans.java index 188c0ec512..4e313b1a21 100644 --- a/Mage.Sets/src/mage/sets/guildpact/HatchingPlans.java +++ b/Mage.Sets/src/mage/sets/guildpact/HatchingPlans.java @@ -31,7 +31,7 @@ package mage.sets.guildpact; import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; @@ -45,7 +45,7 @@ public class HatchingPlans extends CardImpl { super(ownerId, 27, "Hatching Plans", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}"); this.expansionSetCode = "GPT"; this.color.setBlue(true); - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(3))); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DrawCardSourceControllerEffect(3))); } public HatchingPlans (final HatchingPlans card) { diff --git a/Mage.Sets/src/mage/sets/heroesvsmonsters/UndyingRage.java b/Mage.Sets/src/mage/sets/heroesvsmonsters/UndyingRage.java index ad8e784d2a..b5a7b53bbd 100644 --- a/Mage.Sets/src/mage/sets/heroesvsmonsters/UndyingRage.java +++ b/Mage.Sets/src/mage/sets/heroesvsmonsters/UndyingRage.java @@ -29,7 +29,7 @@ package mage.sets.heroesvsmonsters; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; @@ -75,7 +75,7 @@ public class UndyingRage extends CardImpl { this.addAbility(ability); // When Undying Rage is put into a graveyard from the battlefield, return Undying Rage to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public UndyingRage(final UndyingRage card) { diff --git a/Mage.Sets/src/mage/sets/lorwyn/Dread.java b/Mage.Sets/src/mage/sets/lorwyn/Dread.java index b46a8564ec..ef515938f9 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/Dread.java +++ b/Mage.Sets/src/mage/sets/lorwyn/Dread.java @@ -30,7 +30,7 @@ package mage.sets.lorwyn; import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; @@ -68,7 +68,7 @@ public class Dread extends CardImpl { this.addAbility(new DreadTriggeredAbility()); // When Dread is put into a graveyard from anywhere, shuffle it into its owner's library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); } public Dread(final Dread card) { diff --git a/Mage.Sets/src/mage/sets/lorwyn/Vigor.java b/Mage.Sets/src/mage/sets/lorwyn/Vigor.java index 09aef31419..e05719190d 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/Vigor.java +++ b/Mage.Sets/src/mage/sets/lorwyn/Vigor.java @@ -30,7 +30,7 @@ package mage.sets.lorwyn; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; @@ -69,7 +69,7 @@ public class Vigor extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VigorReplacementEffect())); // When Vigor is put into a graveyard from anywhere, shuffle it into its owner's library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); } public Vigor(final Vigor card) { diff --git a/Mage.Sets/src/mage/sets/mirage/IllicitAuction.java b/Mage.Sets/src/mage/sets/mirage/IllicitAuction.java index 6ba4e180bc..df76d10156 100644 --- a/Mage.Sets/src/mage/sets/mirage/IllicitAuction.java +++ b/Mage.Sets/src/mage/sets/mirage/IllicitAuction.java @@ -68,7 +68,7 @@ public class IllicitAuction extends CardImpl { } } -// effect is based on ExchangeControlTargetEffect +// effect is based on GainControlTargetEffect class IllicitAuctionEffect extends GainControlTargetEffect { public IllicitAuctionEffect() { @@ -87,20 +87,20 @@ class IllicitAuctionEffect extends GainControlTargetEffect { @Override public void init(Ability source, Game game) { + Player controller = game.getPlayer(source.getControllerId()); Permanent targetCreature = game.getPermanent(source.getFirstTarget()); - if (targetCreature != null) { + if (controller != null && targetCreature != null) { PlayerList playerList = game.getPlayerList().copy(); playerList.setCurrent(game.getActivePlayerId()); Player winner = game.getPlayer(game.getActivePlayerId()); int highBid = 0; - game.informPlayers(new StringBuilder(winner.getName()).append(" bet 0 lifes").toString()); + game.informPlayers(new StringBuilder(winner.getName()).append(" has bet 0 lifes").toString()); - Player currentPlayer = playerList.getNext(game); + Player currentPlayer = playerList.getNextInRange(controller, game); while (currentPlayer != winner) { - String text = new StringBuilder(winner.getName()).append(" bet ").append(highBid).append(" life") - .append(highBid > 1 ? "s" : "").append(". Top the bid?").toString(); - if (currentPlayer.chooseUse(Outcome.GainControl, text, game)) { + String text = winner.getName() + " has bet " + highBid + " life" + (highBid > 1 ? "s" : "") + ". Top the bid?"; + if (currentPlayer.chooseUse(Outcome.Detriment, text, game)) { int newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game); if (newBid > highBid) { highBid = newBid; @@ -109,15 +109,13 @@ class IllicitAuctionEffect extends GainControlTargetEffect { .append(newBid).append(" life").append(newBid > 1 ? "s" : "").toString()); } } - currentPlayer = playerList.getNext(game); + currentPlayer = playerList.getNextInRange(controller, game); } - game.informPlayers(new StringBuilder(winner.getName()).append(" won auction with a bid of ").append(highBid).append(" life") - .append(highBid > 1 ? "s" : "").toString()); + game.informPlayers(winner.getName() + " won the auction with a bid of " + highBid + " life" + (highBid > 1 ? "s" : "")); winner.loseLife(highBid, game); super.controllingPlayerId = winner.getId(); - } - + } super.init(source, game); } diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlightsteelColossus.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlightsteelColossus.java index 000867fb52..79013540b0 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/BlightsteelColossus.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/BlightsteelColossus.java @@ -33,7 +33,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.common.PutIntoGraveFromAnywhereAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceAbility; import mage.abilities.effects.common.RevealAndShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.abilities.keyword.InfectAbility; @@ -60,7 +60,7 @@ public class BlightsteelColossus extends CardImpl { this.addAbility(IndestructibleAbility.getInstance()); // If Blightsteel Colossus would be put into a graveyard from anywhere, reveal Blightsteel Colossus and shuffle it into its owner's library instead. - this.addAbility(new PutIntoGraveFromAnywhereAbility(new RevealAndShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceAbility(new RevealAndShuffleIntoLibrarySourceEffect())); } public BlightsteelColossus(final BlightsteelColossus card) { diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java index a06c16a25b..3b76c2cd31 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/IchorWellspring.java @@ -31,7 +31,7 @@ package mage.sets.mirrodinbesieged; import java.util.UUID; import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -48,7 +48,7 @@ public class IchorWellspring extends CardImpl { // When Ichor Wellspring enters the battlefield or is put into a graveyard from the battlefield, draw a card. this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DrawCardSourceControllerEffect(1))); } public IchorWellspring(final IchorWellspring card) { diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/SpineOfIshSah.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/SpineOfIshSah.java index 8b7f4f6f65..a74bf6039f 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/SpineOfIshSah.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/SpineOfIshSah.java @@ -32,7 +32,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; import mage.cards.CardImpl; @@ -54,7 +54,7 @@ public class SpineOfIshSah extends CardImpl { this.addAbility(ability); // When Spine of Ish Sah is put into a graveyard from the battlefield, return Spine of Ish Sah to its owner's hand - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public SpineOfIshSah(final SpineOfIshSah card) { diff --git a/Mage.Sets/src/mage/sets/morningtide/CountrysideCrusher.java b/Mage.Sets/src/mage/sets/morningtide/CountrysideCrusher.java index b4a3c9364d..98099465d2 100644 --- a/Mage.Sets/src/mage/sets/morningtide/CountrysideCrusher.java +++ b/Mage.Sets/src/mage/sets/morningtide/CountrysideCrusher.java @@ -34,8 +34,8 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.Card; @@ -45,9 +45,8 @@ import mage.cards.CardsImpl; import mage.constants.Outcome; import mage.constants.TargetController; import mage.counters.CounterType; +import mage.filter.common.FilterLandCard; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.players.Player; @@ -70,7 +69,11 @@ public class CountrysideCrusher extends CardImpl { // At the beginning of your upkeep, reveal the top card of your library. If it's a land card, put it into your graveyard and repeat this process. this.addAbility(new BeginningOfUpkeepTriggeredAbility(new CountrysideCrusherEffect(), TargetController.YOU, false)); // Whenever a land card is put into your graveyard from anywhere, put a +1/+1 counter on Countryside Crusher. - this.addAbility(new CountrysideCrusherTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new AddCountersSourceEffect(CounterType.P1P1.createInstance()), + false, new FilterLandCard("a land card"),TargetController.YOU + )); + } public CountrysideCrusher(final CountrysideCrusher card) { @@ -123,36 +126,3 @@ class CountrysideCrusherEffect extends OneShotEffect { return false; } } - - -class CountrysideCrusherTriggeredAbility extends TriggeredAbilityImpl { - - public CountrysideCrusherTriggeredAbility() { - super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false); - } - - public CountrysideCrusherTriggeredAbility(final CountrysideCrusherTriggeredAbility ability) { - super(ability); - } - - @Override - public CountrysideCrusherTriggeredAbility copy() { - return new CountrysideCrusherTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && card.getOwnerId().equals(this.getControllerId()) && card.getCardType().contains(CardType.LAND)) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a land card is put into your graveyard from anywhere, put a +1/+1 counter on {this}"; - } -} diff --git a/Mage.Sets/src/mage/sets/newphyrexia/GlisteningOil.java b/Mage.Sets/src/mage/sets/newphyrexia/GlisteningOil.java index b9f9c7ddae..37fb5da76d 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/GlisteningOil.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/GlisteningOil.java @@ -32,7 +32,7 @@ import java.util.UUID; import mage.constants.*; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; @@ -73,7 +73,7 @@ public class GlisteningOil extends CardImpl { this.addAbility(new BeginningOfUpkeepTriggeredAbility(new GlisteningOilEffect(), TargetController.YOU, false)); // When Glistening Oil is put into a graveyard from the battlefield, return Glistening Oil to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public GlisteningOil(final GlisteningOil card) { diff --git a/Mage.Sets/src/mage/sets/planarchaos/AvenRiftwatcher.java b/Mage.Sets/src/mage/sets/planarchaos/AvenRiftwatcher.java index 5369bab7c4..4aa47e885d 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/AvenRiftwatcher.java +++ b/Mage.Sets/src/mage/sets/planarchaos/AvenRiftwatcher.java @@ -32,6 +32,7 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.EntersOrLeavesTheBattlefieldSourceTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.GainLifeEffect; @@ -68,11 +69,9 @@ public class AvenRiftwatcher extends CardImpl { this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.TIME.createInstance(2)))); this.addAbility(new VanishingUpkeepAbility(2)); this.addAbility(new VanishingSacrificeAbility()); + // When Aven Riftwatcher enters the battlefield or leaves the battlefield, you gain 2 life. - Ability ability = new EntersBattlefieldTriggeredAbility(new GainLifeEffect(2), false); - this.addAbility(ability); - Ability ability2 = new LeavesBattlefieldTriggeredAbility(new GainLifeEffect(2), false); - this.addAbility(ability2); + this.addAbility(new EntersOrLeavesTheBattlefieldSourceTriggeredAbility(new GainLifeEffect(2), false)); } public AvenRiftwatcher(final AvenRiftwatcher card) { diff --git a/Mage.Sets/src/mage/sets/planarchaos/KeldonMarauders.java b/Mage.Sets/src/mage/sets/planarchaos/KeldonMarauders.java index 73341046a4..7f1b0c20a7 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/KeldonMarauders.java +++ b/Mage.Sets/src/mage/sets/planarchaos/KeldonMarauders.java @@ -33,7 +33,7 @@ import mage.constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.EntersOrLeavesTheBattlefieldSourceTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; @@ -63,15 +63,11 @@ public class KeldonMarauders extends CardImpl { this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.TIME.createInstance(2)))); this.addAbility(new VanishingUpkeepAbility(2)); this.addAbility(new VanishingSacrificeAbility()); + // When Keldon Marauders enters the battlefield or leaves the battlefield, it deals 1 damage to target player. - Ability ability = new EntersBattlefieldTriggeredAbility(new DamageTargetEffect(1), false); + Ability ability = new EntersOrLeavesTheBattlefieldSourceTriggeredAbility(new DamageTargetEffect(1), false); ability.addTarget(new TargetPlayer()); this.addAbility(ability); - Ability ability2 = new LeavesBattlefieldTriggeredAbility(new DamageTargetEffect(1), false); - ability2.addTarget(new TargetPlayer()); - this.addAbility(ability2); - - } public KeldonMarauders(final KeldonMarauders card) { diff --git a/Mage.Sets/src/mage/sets/ravnika/Terrarion.java b/Mage.Sets/src/mage/sets/ravnika/Terrarion.java index efb356e633..1bab798d49 100644 --- a/Mage.Sets/src/mage/sets/ravnika/Terrarion.java +++ b/Mage.Sets/src/mage/sets/ravnika/Terrarion.java @@ -30,7 +30,7 @@ package mage.sets.ravnika; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTappedAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; @@ -60,7 +60,7 @@ public class Terrarion extends CardImpl { ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); // When Terrarion is put into a graveyard from the battlefield, draw a card. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DrawCardSourceControllerEffect(1))); } public Terrarion(final Terrarion card) { diff --git a/Mage.Sets/src/mage/sets/returntoravnica/WorldspineWurm.java b/Mage.Sets/src/mage/sets/returntoravnica/WorldspineWurm.java index 96f0492f90..1a114d1eb8 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/WorldspineWurm.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/WorldspineWurm.java @@ -30,7 +30,7 @@ package mage.sets.returntoravnica; import java.util.UUID; import mage.MageInt; import mage.abilities.common.DiesTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.TrampleAbility; @@ -61,7 +61,7 @@ public class WorldspineWurm extends CardImpl { this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new WorldspineWurmToken(), 3))); // When Worldspine Wurm is put into a graveyard from anywhere, shuffle it into its owner's library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); } public WorldspineWurm(final WorldspineWurm card) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java index 7c023dbd84..c93267f37d 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/EmrakulTheAeonsTorn.java @@ -37,7 +37,7 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.CantCounterAbility; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.AnnihilatorAbility; import mage.abilities.keyword.FlyingAbility; @@ -81,7 +81,7 @@ public class EmrakulTheAeonsTorn extends CardImpl { this.addAbility(new ProtectionAbility(filter)); this.addAbility(new AnnihilatorAbility(6)); // When Emrakul is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new EmrakulTheAeonsTornEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new EmrakulTheAeonsTornEffect(), false)); } public EmrakulTheAeonsTorn(final EmrakulTheAeonsTorn card) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java index e5ea22bf72..ba3ef1ea22 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/KozilekButcherOfTruth.java @@ -37,7 +37,7 @@ import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.keyword.AnnihilatorAbility; @@ -62,7 +62,7 @@ public class KozilekButcherOfTruth extends CardImpl { this.toughness = new MageInt(12); this.addAbility(new KozilekButcherOfTruthOnCastAbility()); this.addAbility(new AnnihilatorAbility(4)); - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new KozilekButcherOfTruthEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new KozilekButcherOfTruthEffect(), false)); } public KozilekButcherOfTruth (final KozilekButcherOfTruth card) { diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java index 9539da4bd1..ec920cc213 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/UlamogTheInfiniteGyre.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.keyword.AnnihilatorAbility; @@ -72,7 +72,7 @@ public class UlamogTheInfiniteGyre extends CardImpl { // Indestructible this.addAbility(IndestructibleAbility.getInstance()); // When Ulamog is put into a graveyard from anywhere, its owner shuffles his or her graveyard into his or her library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new UlamogTheInfiniteGyreEnterGraveyardEffect(), false)); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new UlamogTheInfiniteGyreEnterGraveyardEffect(), false)); } public UlamogTheInfiniteGyre(final UlamogTheInfiniteGyre card) { diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/RallyTheHorde.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/RallyTheHorde.java index 3e8269abf1..f36aee1aee 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/RallyTheHorde.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/RallyTheHorde.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.CreateTokenTargetEffect; +import mage.abilities.effects.common.CreateTokenEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java index f373583bdb..afbd20c11b 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/PanicSpellbomb.java @@ -34,7 +34,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; @@ -62,7 +62,7 @@ public class PanicSpellbomb extends CardImpl { this.addAbility(ability); // When Panic Spellbomb is put into a graveyard from the battlefield, you may pay Red. If you do, draw a card. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{R}")), false)); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DoIfCostPaid(new DrawCardSourceControllerEffect(1), new ManaCostsImpl("{R}")), false)); } public PanicSpellbomb(final PanicSpellbomb card) { diff --git a/Mage.Sets/src/mage/sets/seventhedition/Compost.java b/Mage.Sets/src/mage/sets/seventhedition/Compost.java index 15d7b4f760..ebe6f04e53 100644 --- a/Mage.Sets/src/mage/sets/seventhedition/Compost.java +++ b/Mage.Sets/src/mage/sets/seventhedition/Compost.java @@ -28,17 +28,15 @@ package mage.sets.seventhedition; import java.util.UUID; -import mage.abilities.TriggeredAbilityImpl; +import mage.ObjectColor; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.events.ZoneChangeEvent; +import mage.constants.TargetController; +import mage.filter.FilterCard; +import mage.filter.predicate.mageobject.ColorPredicate; /** * @@ -46,6 +44,12 @@ import mage.game.events.ZoneChangeEvent; */ public class Compost extends CardImpl { + private static final FilterCard filter = new FilterCard("a black card"); + + static { + filter.add(new ColorPredicate(ObjectColor.BLACK)); + } + public Compost(UUID ownerId) { super(ownerId, 235, "Compost", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); this.expansionSetCode = "7ED"; @@ -53,7 +57,8 @@ public class Compost extends CardImpl { this.color.setGreen(true); // Whenever a black card is put into an opponent's graveyard from anywhere, you may draw a card. - this.addAbility(new CompostTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new DrawCardSourceControllerEffect(1), true, TargetController.OPPONENT)); } public Compost(final Compost card) { @@ -65,35 +70,3 @@ public class Compost extends CardImpl { return new Compost(this); } } - -class CompostTriggeredAbility extends TriggeredAbilityImpl { - - CompostTriggeredAbility() { - super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), true); - } - - CompostTriggeredAbility(final CompostTriggeredAbility ability) { - super(ability); - } - - @Override - public CompostTriggeredAbility copy() { - return new CompostTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && card.getColor().isBlack() && game.getOpponents(controllerId).contains(card.getOwnerId())) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a black card is put into an opponent's graveyard from anywhere, you may draw a card"; - } -} diff --git a/Mage.Sets/src/mage/sets/tenth/ChromaticStar.java b/Mage.Sets/src/mage/sets/tenth/ChromaticStar.java index 38d15439b3..266f3987ea 100644 --- a/Mage.Sets/src/mage/sets/tenth/ChromaticStar.java +++ b/Mage.Sets/src/mage/sets/tenth/ChromaticStar.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.GenericManaCost; @@ -52,7 +52,7 @@ public class ChromaticStar extends CardImpl { ability.addCost(new TapSourceCost()); ability.addCost(new SacrificeSourceCost()); this.addAbility(ability); - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardSourceControllerEffect(1))); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new DrawCardSourceControllerEffect(1))); } public ChromaticStar(final ChromaticStar card) { diff --git a/Mage.Sets/src/mage/sets/timespiral/AspectOfMongoose.java b/Mage.Sets/src/mage/sets/timespiral/AspectOfMongoose.java index b9a064f7d7..976c611748 100644 --- a/Mage.Sets/src/mage/sets/timespiral/AspectOfMongoose.java +++ b/Mage.Sets/src/mage/sets/timespiral/AspectOfMongoose.java @@ -29,7 +29,7 @@ package mage.sets.timespiral; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; @@ -70,7 +70,7 @@ public class AspectOfMongoose extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ShroudAbility.getInstance(), AttachmentType.AURA))); // When Aspect of Mongoose is put into a graveyard from the battlefield, return Aspect of Mongoose to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } diff --git a/Mage.Sets/src/mage/sets/timespiral/FlagstonesOfTrokair.java b/Mage.Sets/src/mage/sets/timespiral/FlagstonesOfTrokair.java index bf38275928..33b5ef80ef 100644 --- a/Mage.Sets/src/mage/sets/timespiral/FlagstonesOfTrokair.java +++ b/Mage.Sets/src/mage/sets/timespiral/FlagstonesOfTrokair.java @@ -28,7 +28,7 @@ package mage.sets.timespiral; import java.util.UUID; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.abilities.mana.WhiteManaAbility; import mage.cards.CardImpl; @@ -59,7 +59,7 @@ public class FlagstonesOfTrokair extends CardImpl { this.addAbility(new WhiteManaAbility()); // When Flagstones of Trokair is put into a graveyard from the battlefield, you may search your library for a Plains card and put it onto the battlefield tapped. If you do, shuffle your library. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true, true), true)); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), true, true), true)); } public FlagstonesOfTrokair(final FlagstonesOfTrokair card) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/Cessation.java b/Mage.Sets/src/mage/sets/urzaslegacy/Cessation.java index 47a2c11609..a7e938fbef 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/Cessation.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/Cessation.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.*; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.AttachEffect; @@ -65,7 +65,7 @@ public class Cessation extends CardImpl { //Enchanted creature can't attack. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAttachedEffect(AttachmentType.AURA))); //When Cessation is put into a graveyard from the battlefield, return Cessation to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public Cessation(final Cessation card) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/Rancor.java b/Mage.Sets/src/mage/sets/urzaslegacy/Rancor.java index d696807d62..84b8ee7b60 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/Rancor.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/Rancor.java @@ -29,7 +29,7 @@ package mage.sets.urzaslegacy; import mage.constants.*; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; @@ -71,7 +71,7 @@ public class Rancor extends CardImpl { this.addAbility(ability); // When Rancor is put into a graveyard from the battlefield, return Rancor to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public Rancor(final Rancor card) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/SleepersGuile.java b/Mage.Sets/src/mage/sets/urzaslegacy/SleepersGuile.java index 77bf796879..59aeb2d897 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/SleepersGuile.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/SleepersGuile.java @@ -34,7 +34,7 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; @@ -69,7 +69,7 @@ public class SleepersGuile extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FearAbility.getInstance(), AttachmentType.AURA))); // When Sleeper's Guile is put into a graveyard from the battlefield, return Sleeper's Guile to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public SleepersGuile(final SleepersGuile card) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/SlowMotion.java b/Mage.Sets/src/mage/sets/urzaslegacy/SlowMotion.java index 3593a25e68..73995b8b80 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/SlowMotion.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/SlowMotion.java @@ -33,7 +33,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.effects.OneShotEffect; @@ -73,7 +73,7 @@ public class SlowMotion extends CardImpl { this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeEquipedUnlessPaysEffect(new GenericManaCost(2)), TargetController.CONTROLLER_ATTACHED_TO, false )); // When Slow Motion is put into a graveyard from the battlefield, return Slow Motion to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public SlowMotion(final SlowMotion card) { diff --git a/Mage.Sets/src/mage/sets/urzaslegacy/Sluggishness.java b/Mage.Sets/src/mage/sets/urzaslegacy/Sluggishness.java index 1d17c6ca01..64595c8718 100644 --- a/Mage.Sets/src/mage/sets/urzaslegacy/Sluggishness.java +++ b/Mage.Sets/src/mage/sets/urzaslegacy/Sluggishness.java @@ -34,7 +34,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.combat.CantBlockAttachedEffect; @@ -69,7 +69,7 @@ public class Sluggishness extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBlockAttachedEffect(AttachmentType.AURA))); // When Sluggishness is put into a graveyard from the battlefield, return Sluggishness to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public Sluggishness(final Sluggishness card) { diff --git a/Mage.Sets/src/mage/sets/urzassaga/BrilliantHalo.java b/Mage.Sets/src/mage/sets/urzassaga/BrilliantHalo.java index d44930dbaa..cc60c7674d 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/BrilliantHalo.java +++ b/Mage.Sets/src/mage/sets/urzassaga/BrilliantHalo.java @@ -31,7 +31,7 @@ import java.util.UUID; import mage.constants.*; import mage.abilities.Ability; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.ReturnToHandSourceEffect; @@ -63,7 +63,7 @@ public class BrilliantHalo extends CardImpl { // Enchanted creature gets +1/+2. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 2, Duration.WhileOnBattlefield))); // When Brilliant Halo is put into a graveyard from the battlefield, return Brilliant Halo to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } public BrilliantHalo(final BrilliantHalo card) { diff --git a/Mage.Sets/src/mage/sets/urzassaga/EnergyField.java b/Mage.Sets/src/mage/sets/urzassaga/EnergyField.java index f06ba302ab..fddcd2a328 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/EnergyField.java +++ b/Mage.Sets/src/mage/sets/urzassaga/EnergyField.java @@ -29,19 +29,18 @@ package mage.sets.urzassaga; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.PreventionEffectImpl; import mage.abilities.effects.common.SacrificeSourceEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; +import mage.constants.TargetController; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; /** * @@ -58,7 +57,9 @@ public class EnergyField extends CardImpl { // Prevent all damage that would be dealt to you by sources you don't control. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EnergyFieldEffect())); // When a card is put into your graveyard from anywhere, sacrifice Energy Field. - this.addAbility(new PutIntoYourGraveyardTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new SacrificeSourceEffect(), false, TargetController.YOU)); + } public EnergyField(final EnergyField card) { @@ -114,38 +115,3 @@ class EnergyFieldEffect extends PreventionEffectImpl { return new EnergyFieldEffect(this); } } - -class PutIntoYourGraveyardTriggeredAbility extends TriggeredAbilityImpl { - - public PutIntoYourGraveyardTriggeredAbility() { - super(Zone.BATTLEFIELD, new SacrificeSourceEffect(), false); - } - - public PutIntoYourGraveyardTriggeredAbility(PutIntoYourGraveyardTriggeredAbility ability) { - super(ability); - } - - @Override - public PutIntoYourGraveyardTriggeredAbility copy() { - return new PutIntoYourGraveyardTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE) { - ZoneChangeEvent zEvent = (ZoneChangeEvent) event; - if (zEvent.getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && card.getOwnerId().equals(getControllerId())) { - return true; - } - } - } - return false; - } - - @Override - public String getRule() { - return "When a card is put into your graveyard from anywhere, " + super.getRule(); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/urzassaga/SerraAvatar.java b/Mage.Sets/src/mage/sets/urzassaga/SerraAvatar.java index 931962a30d..d6023d2e4c 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/SerraAvatar.java +++ b/Mage.Sets/src/mage/sets/urzassaga/SerraAvatar.java @@ -29,7 +29,7 @@ package mage.sets.urzassaga; import java.util.UUID; import mage.MageInt; -import mage.abilities.common.PutIntoGraveFromAnywhereTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromAnywhereSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.common.ControllerLifeCount; import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; @@ -59,7 +59,7 @@ public class SerraAvatar extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new ControllerLifeCount(), Duration.EndOfGame))); // When Serra Avatar is put into a graveyard from anywhere, shuffle it into its owner's library. - this.addAbility(new PutIntoGraveFromAnywhereTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); + this.addAbility(new PutIntoGraveFromAnywhereSourceTriggeredAbility(new ShuffleIntoLibrarySourceEffect())); } public SerraAvatar(final SerraAvatar card) { diff --git a/Mage.Sets/src/mage/sets/urzassaga/SpreadingAlgae.java b/Mage.Sets/src/mage/sets/urzassaga/SpreadingAlgae.java index 634f527038..ebfe789339 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/SpreadingAlgae.java +++ b/Mage.Sets/src/mage/sets/urzassaga/SpreadingAlgae.java @@ -33,7 +33,7 @@ import mage.constants.CardType; import mage.constants.Rarity; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility; +import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.DestroyTargetEffect; @@ -79,7 +79,7 @@ public class SpreadingAlgae extends CardImpl { this.addAbility(new SpreadingAlgaeTriggeredAbility(new DestroyTargetEffect())); // When Spreading Algae is put into a graveyard from the battlefield, return Spreading Algae to its owner's hand. - this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new ReturnToHandSourceEffect())); + this.addAbility(new PutIntoGraveFromBattlefieldSourceTriggeredAbility(new ReturnToHandSourceEffect())); } diff --git a/Mage.Sets/src/mage/sets/zendikar/BloodchiefAscension.java b/Mage.Sets/src/mage/sets/zendikar/BloodchiefAscension.java index 0bcd8a8263..b7c52f0a35 100644 --- a/Mage.Sets/src/mage/sets/zendikar/BloodchiefAscension.java +++ b/Mage.Sets/src/mage/sets/zendikar/BloodchiefAscension.java @@ -28,21 +28,26 @@ package mage.sets.zendikar; import java.util.UUID; +import mage.abilities.Ability; import mage.constants.CardType; import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.condition.Condition; import mage.abilities.condition.common.SourceHasCounterCondition; import mage.abilities.condition.common.OpponentLostLifeCondition; +import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.LoseLifeTargetEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.SetTargetPointer; import mage.counters.CounterType; +import mage.filter.FilterCard; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; @@ -68,7 +73,13 @@ public class BloodchiefAscension extends CardImpl { true)); // Whenever a card is put into an opponent's graveyard from anywhere, if Bloodchief Ascension has three or more quest counters on it, you may have that player lose 2 life. If you do, you gain 2 life. - this.addAbility(new BloodchiefAscensionTriggeredAbility()); + Ability ability = new ConditionalTriggeredAbility( + new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new LoseLifeTargetEffect(2), true, new FilterCard("a card"), TargetController.OPPONENT, SetTargetPointer.PLAYER), + new SourceHasCounterCondition(CounterType.QUEST, 3), + "Whenever a card is put into an opponent's graveyard from anywhere, if Bloodchief Ascension has three or more quest counters on it, you may have that player lose 2 life. If you do, you gain 2 life", true); + ability.addEffect(new GainLifeEffect(2)); + this.addAbility(ability); } @@ -81,47 +92,3 @@ public class BloodchiefAscension extends CardImpl { return new BloodchiefAscension(this); } } - -class BloodchiefAscensionTriggeredAbility extends TriggeredAbilityImpl { - - private Condition condition; - - public BloodchiefAscensionTriggeredAbility() { - super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2), true); - this.addEffect(new GainLifeEffect(2)); - condition = new SourceHasCounterCondition(CounterType.QUEST, 3); - } - - public BloodchiefAscensionTriggeredAbility(final BloodchiefAscensionTriggeredAbility ability) { - super(ability); - this.condition = ability.condition; - } - - @Override - public BloodchiefAscensionTriggeredAbility copy() { - return new BloodchiefAscensionTriggeredAbility(this); - } - - @Override - public boolean checkInterveningIfClause(Game game) { - return condition.apply(game, this); - } - - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && !card.isCopy() && game.getOpponents(controllerId).contains(card.getOwnerId())) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(card.getOwnerId())); - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a card is put into an opponent's graveyard from anywhere, if {this} has three or more quest counters on it, you may have that player lose 2 life. If you do, you gain 2 life."; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java b/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java index a2369f57bd..fdebd0fa2a 100644 --- a/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java +++ b/Mage.Sets/src/mage/sets/zendikar/QuestForAncientSecrets.java @@ -28,23 +28,21 @@ package mage.sets.zendikar; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; -import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.ZoneChangeEvent; import mage.players.Player; import mage.target.TargetPlayer; @@ -61,7 +59,9 @@ public class QuestForAncientSecrets extends CardImpl { this.color.setBlue(true); // Whenever a card is put into your graveyard from anywhere, you may put a quest counter on Quest for Ancient Secrets. - this.addAbility(new QuestForAncientSecretsTriggeredAbility()); + this.addAbility(new PutCardIntoGraveFromAnywhereAllTriggeredAbility( + new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true, TargetController.YOU)); + // Remove five quest counters from Quest for Ancient Secrets and sacrifice it: Target player shuffles his or her graveyard into his or her library. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new QuestForAncientSecretsEffect(), @@ -81,38 +81,6 @@ public class QuestForAncientSecrets extends CardImpl { } } -class QuestForAncientSecretsTriggeredAbility extends TriggeredAbilityImpl { - - public QuestForAncientSecretsTriggeredAbility() { - super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance()), true); - } - - public QuestForAncientSecretsTriggeredAbility(final QuestForAncientSecretsTriggeredAbility ability) { - super(ability); - } - - @Override - public QuestForAncientSecretsTriggeredAbility copy() { - return new QuestForAncientSecretsTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { - Card card = game.getCard(event.getTargetId()); - if (card != null && !card.isCopy() && card.getOwnerId().equals(this.getControllerId())) { - return true; - } - } - return false; - } - - @Override - public String getRule() { - return "Whenever a card is put into your graveyard from anywhere, you may put a quest counter on {this}"; - } -} - class QuestForAncientSecretsEffect extends OneShotEffect { public QuestForAncientSecretsEffect() { diff --git a/Mage/src/mage/abilities/common/AttacksAllTriggeredAbility.java b/Mage/src/mage/abilities/common/AttacksAllTriggeredAbility.java index 6cea620b3b..67e5086387 100644 --- a/Mage/src/mage/abilities/common/AttacksAllTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/AttacksAllTriggeredAbility.java @@ -90,7 +90,7 @@ public class AttacksAllTriggeredAbility extends TriggeredAbilityImpl { return false; } } - if (SetTargetPointer.CREATURE.equals(setTargetPointer)) { + if (SetTargetPointer.PERMANENT.equals(setTargetPointer)) { for (Effect effect: getEffects()) { effect.setTargetPointer(new FixedTarget(permanent.getId())); } diff --git a/Mage/src/mage/abilities/common/EntersOrLeavesTheBattlefieldSourceTriggeredAbility.java b/Mage/src/mage/abilities/common/EntersOrLeavesTheBattlefieldSourceTriggeredAbility.java new file mode 100644 index 0000000000..8635bf9bc0 --- /dev/null +++ b/Mage/src/mage/abilities/common/EntersOrLeavesTheBattlefieldSourceTriggeredAbility.java @@ -0,0 +1,77 @@ +/* + * 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.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.game.events.ZoneChangeEvent; + +/** + * + * @author LevelX2 + */ + +public class EntersOrLeavesTheBattlefieldSourceTriggeredAbility extends TriggeredAbilityImpl { + + public EntersOrLeavesTheBattlefieldSourceTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public EntersOrLeavesTheBattlefieldSourceTriggeredAbility(final EntersOrLeavesTheBattlefieldSourceTriggeredAbility ability) { + super(ability); + } + + @Override + public EntersOrLeavesTheBattlefieldSourceTriggeredAbility copy() { + return new EntersOrLeavesTheBattlefieldSourceTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD + && event.getTargetId().equals(getSourceId())) { + return true; + } + if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getFromZone().equals(Zone.BATTLEFIELD)) { + return true; + } + } + return false; + } + + @Override + public String getRule() { + return "When {this} enters the battlefield or leaves the battlefield, " + super.getRule(); + } +} diff --git a/Mage/src/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java b/Mage/src/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java new file mode 100644 index 0000000000..e0be9b7533 --- /dev/null +++ b/Mage/src/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java @@ -0,0 +1,129 @@ +/* + * 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.cards.Card; +import mage.constants.SetTargetPointer; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.other.OwnerPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author LevelX2 + */ + +public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAbilityImpl { + + private final FilterCard filter; + private final String ruleText; + private final SetTargetPointer setTargetPointer; + + public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Effect effect, boolean optional, TargetController targetController) { + this(effect, optional, new FilterCard("a card"), targetController); + } + + public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Effect effect, boolean optional, FilterCard filter, TargetController targetController) { + this(effect, optional, filter, targetController, SetTargetPointer.NONE); + } + + public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Effect effect, boolean optional, FilterCard filter, TargetController targetController, SetTargetPointer setTargetPointer) { + this(Zone.BATTLEFIELD, effect, optional, filter, targetController, setTargetPointer); + } + + public PutCardIntoGraveFromAnywhereAllTriggeredAbility(Zone zone, Effect effect, boolean optional, FilterCard filter, TargetController targetController, SetTargetPointer setTargetPointer) { + super(zone, effect, optional); + this.filter = filter.copy(); + this.setTargetPointer = setTargetPointer; + this.filter.add(new OwnerPredicate(targetController)); + StringBuilder sb = new StringBuilder("Whenever "); + sb.append(filter.getMessage()); + sb.append(" is put into "); + switch (targetController) { + case OPPONENT: + sb.append("an opponent's"); + break; + case YOU: + sb.append("your"); + break; + default: + sb.append("a"); + } + sb.append(" graveyard, "); + ruleText = sb.toString(); + + } + + public PutCardIntoGraveFromAnywhereAllTriggeredAbility(final PutCardIntoGraveFromAnywhereAllTriggeredAbility ability) { + super(ability); + this.filter = ability.filter; + this.ruleText = ability.ruleText; + this.setTargetPointer = ability.setTargetPointer; + } + + @Override + public PutCardIntoGraveFromAnywhereAllTriggeredAbility copy() { + return new PutCardIntoGraveFromAnywhereAllTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) { + Card card = game.getCard(event.getTargetId()); + if (card != null && filter.match(card, getSourceId(), getControllerId(), game)) { + switch (setTargetPointer) { + case CARD: + for (Effect effect: getEffects()) { + effect.setTargetPointer(new FixedTarget(card.getId())); + } + break; + case PLAYER: + for (Effect effect: getEffects()) { + effect.setTargetPointer(new FixedTarget(card.getOwnerId())); + } + break; + + } + return true; + } + } + return false; + } + + @Override + public String getRule() { + return ruleText + super.getRule(); + } +} diff --git a/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereAbility.java b/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java similarity index 90% rename from Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereAbility.java rename to Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java index 4449d8c07f..e581fbc2a5 100644 --- a/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereAbility.java +++ b/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceAbility.java @@ -48,23 +48,23 @@ import mage.players.Player; * * @author LevelX2 */ -public class PutIntoGraveFromAnywhereAbility extends SimpleStaticAbility { +public class PutIntoGraveFromAnywhereSourceAbility extends SimpleStaticAbility { - public PutIntoGraveFromAnywhereAbility(Effect baseEffect) { + public PutIntoGraveFromAnywhereSourceAbility(Effect baseEffect) { this(baseEffect, null, "", true, false); } - public PutIntoGraveFromAnywhereAbility(Effect baseEffect, Condition condition, String text, boolean selfScope, boolean optional) { + public PutIntoGraveFromAnywhereSourceAbility(Effect baseEffect, Condition condition, String text, boolean selfScope, boolean optional) { super(Zone.ALL, new PutIntoGraveFromAnywhereEffect(baseEffect, condition, text, selfScope, optional)); } - public PutIntoGraveFromAnywhereAbility(final PutIntoGraveFromAnywhereAbility ability) { + public PutIntoGraveFromAnywhereSourceAbility(final PutIntoGraveFromAnywhereSourceAbility ability) { super(ability); } @Override public SimpleStaticAbility copy() { - return new PutIntoGraveFromAnywhereAbility(this); + return new PutIntoGraveFromAnywhereSourceAbility(this); } @Override diff --git a/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceTriggeredAbility.java b/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceTriggeredAbility.java new file mode 100644 index 0000000000..96fae22b3b --- /dev/null +++ b/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereSourceTriggeredAbility.java @@ -0,0 +1,26 @@ +package mage.abilities.common; + +import mage.abilities.effects.Effect; +import mage.constants.Zone; + +/** + * @author Loki + */ +public class PutIntoGraveFromAnywhereSourceTriggeredAbility extends ZoneChangeTriggeredAbility { + public PutIntoGraveFromAnywhereSourceTriggeredAbility(Effect effect, boolean optional) { + super(Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from anywhere, ", optional); + } + + public PutIntoGraveFromAnywhereSourceTriggeredAbility(Effect effect) { + this(effect, false); + } + + public PutIntoGraveFromAnywhereSourceTriggeredAbility(final PutIntoGraveFromAnywhereSourceTriggeredAbility ability) { + super(ability); + } + + @Override + public PutIntoGraveFromAnywhereSourceTriggeredAbility copy() { + return new PutIntoGraveFromAnywhereSourceTriggeredAbility(this); + } +} diff --git a/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereTriggeredAbility.java b/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereTriggeredAbility.java deleted file mode 100644 index 367672b674..0000000000 --- a/Mage/src/mage/abilities/common/PutIntoGraveFromAnywhereTriggeredAbility.java +++ /dev/null @@ -1,26 +0,0 @@ -package mage.abilities.common; - -import mage.abilities.effects.Effect; -import mage.constants.Zone; - -/** - * @author Loki - */ -public class PutIntoGraveFromAnywhereTriggeredAbility extends ZoneChangeTriggeredAbility { - public PutIntoGraveFromAnywhereTriggeredAbility(Effect effect, boolean optional) { - super(Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from anywhere, ", optional); - } - - public PutIntoGraveFromAnywhereTriggeredAbility(Effect effect) { - this(effect, false); - } - - public PutIntoGraveFromAnywhereTriggeredAbility(final PutIntoGraveFromAnywhereTriggeredAbility ability) { - super(ability); - } - - @Override - public PutIntoGraveFromAnywhereTriggeredAbility copy() { - return new PutIntoGraveFromAnywhereTriggeredAbility(this); - } -} diff --git a/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldTriggeredAbility.java b/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldSourceTriggeredAbility.java similarity index 68% rename from Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldTriggeredAbility.java rename to Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldSourceTriggeredAbility.java index 100efd54fa..5e6533efc4 100644 --- a/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldTriggeredAbility.java +++ b/Mage/src/mage/abilities/common/PutIntoGraveFromBattlefieldSourceTriggeredAbility.java @@ -11,23 +11,23 @@ import mage.game.permanent.Permanent; /** * @author nantuko, loki */ -public class PutIntoGraveFromBattlefieldTriggeredAbility extends TriggeredAbilityImpl { +public class PutIntoGraveFromBattlefieldSourceTriggeredAbility extends TriggeredAbilityImpl { - public PutIntoGraveFromBattlefieldTriggeredAbility(Effect effect) { + public PutIntoGraveFromBattlefieldSourceTriggeredAbility(Effect effect) { this(effect, false); } - public PutIntoGraveFromBattlefieldTriggeredAbility(Effect effect, boolean optional) { + public PutIntoGraveFromBattlefieldSourceTriggeredAbility(Effect effect, boolean optional) { super(Zone.ALL, effect, optional); } - PutIntoGraveFromBattlefieldTriggeredAbility(PutIntoGraveFromBattlefieldTriggeredAbility ability) { + PutIntoGraveFromBattlefieldSourceTriggeredAbility(PutIntoGraveFromBattlefieldSourceTriggeredAbility ability) { super(ability); } @Override - public PutIntoGraveFromBattlefieldTriggeredAbility copy() { - return new PutIntoGraveFromBattlefieldTriggeredAbility(this); + public PutIntoGraveFromBattlefieldSourceTriggeredAbility copy() { + return new PutIntoGraveFromBattlefieldSourceTriggeredAbility(this); } @Override diff --git a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToHandEffect.java b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToHandEffect.java index f3ab060987..7dccfd5a67 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToHandEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnSourceFromGraveyardToHandEffect.java @@ -28,11 +28,11 @@ package mage.abilities.effects.common; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; +import mage.constants.Outcome; +import mage.constants.Zone; import mage.game.Game; import mage.players.Player; @@ -44,7 +44,7 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect { public ReturnSourceFromGraveyardToHandEffect() { super(Outcome.PutCreatureInPlay); - staticText = "Return {this} from your graveyard to your hand"; + staticText = "return {this} from your graveyard to your hand"; } public ReturnSourceFromGraveyardToHandEffect(final ReturnSourceFromGraveyardToHandEffect effect) { @@ -58,12 +58,10 @@ public class ReturnSourceFromGraveyardToHandEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Card card = player.getGraveyard().get(source.getSourceId(), game); + Player controller = game.getPlayer(source.getControllerId()); + Card card = controller.getGraveyard().get(source.getSourceId(), game); if (card != null) { - player.removeFromGraveyard(card, game); - card.moveToZone(Zone.HAND, source.getSourceId(), game, false); - return true; + return controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD); } return false; } diff --git a/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java b/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java index 777a36d509..4a9114b0d7 100644 --- a/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/ReturnToHandTargetEffect.java @@ -109,7 +109,7 @@ public class ReturnToHandTargetEffect extends OneShotEffect { return ""; } Target target = mode.getTargets().get(0); - StringBuilder sb = new StringBuilder("Return "); + StringBuilder sb = new StringBuilder("return "); if (target.getNumberOfTargets() == 0 && target.getMaxNumberOfTargets() > 0) { sb.append("up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ").append(target.getTargetName()).append(" to their owners' hand"); return sb.toString(); diff --git a/Mage/src/mage/abilities/effects/common/SacrificeSourceEffect.java b/Mage/src/mage/abilities/effects/common/SacrificeSourceEffect.java index 76c596dfe5..0b78c64aee 100644 --- a/Mage/src/mage/abilities/effects/common/SacrificeSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/SacrificeSourceEffect.java @@ -28,9 +28,9 @@ package mage.abilities.effects.common; -import mage.constants.Outcome; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; import mage.game.Game; import mage.game.permanent.Permanent; @@ -58,7 +58,11 @@ public class SacrificeSourceEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - return permanent.sacrifice(source.getSourceId(), game); + // you can only sacrifice a permanent you control + if (source.getControllerId().equals(permanent.getControllerId())) { + return permanent.sacrifice(source.getSourceId(), game); + } + return true; } return false; } diff --git a/Mage/src/mage/abilities/effects/common/continious/GainControlTargetEffect.java b/Mage/src/mage/abilities/effects/common/continious/GainControlTargetEffect.java index 23634cc7fe..79fcd0aa37 100644 --- a/Mage/src/mage/abilities/effects/common/continious/GainControlTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/GainControlTargetEffect.java @@ -95,6 +95,7 @@ public class GainControlTargetEffect extends ContinuousEffectImpl { if (this.controllingPlayerId == null && fixedControl) { this.controllingPlayerId = source.getControllerId(); } + super.init(source, game); } @Override diff --git a/Mage/src/mage/constants/SetTargetPointer.java b/Mage/src/mage/constants/SetTargetPointer.java index 89b9d4df55..6aeca5e026 100644 --- a/Mage/src/mage/constants/SetTargetPointer.java +++ b/Mage/src/mage/constants/SetTargetPointer.java @@ -33,5 +33,5 @@ package mage.constants; * @author LevelX2 */ public enum SetTargetPointer { - NONE, PLAYER, SPELL, CREATURE, PERMANENT; + NONE, PLAYER, SPELL, CARD, PERMANENT; } diff --git a/Mage/src/mage/watchers/common/CardsPutIntoGraveyardWatcher.java b/Mage/src/mage/watchers/common/CardsPutIntoGraveyardWatcher.java index 28cff22b70..78195be8c1 100644 --- a/Mage/src/mage/watchers/common/CardsPutIntoGraveyardWatcher.java +++ b/Mage/src/mage/watchers/common/CardsPutIntoGraveyardWatcher.java @@ -49,8 +49,8 @@ import mage.watchers.Watcher; */ public class CardsPutIntoGraveyardWatcher extends Watcher { - private final Map amountOfCardsThisTurn = new HashMap(); - private final Set cardsPutToGraveyardFromBattlefield = new HashSet(); + private final Map amountOfCardsThisTurn = new HashMap<>(); + private final Set cardsPutToGraveyardFromBattlefield = new HashSet<>(); public CardsPutIntoGraveyardWatcher() { @@ -75,7 +75,7 @@ public class CardsPutIntoGraveyardWatcher extends Watcher { if (playerId != null && game.getCard(event.getTargetId()) != null) { Integer amount = amountOfCardsThisTurn.get(playerId); if (amount == null) { - amount = new Integer(1); + amount = 1; } else { ++amount; } @@ -90,13 +90,13 @@ public class CardsPutIntoGraveyardWatcher extends Watcher { public int getAmountCardsPutToGraveyard(UUID playerId) { Integer amount = amountOfCardsThisTurn.get(playerId); if (amount != null) { - return amount.intValue(); + return amount; } return 0; } public Set getCardsPutToGraveyardFromBattlefield() { - Set cards = new HashSet(); + Set cards = new HashSet<>(); cards.addAll(cardsPutToGraveyardFromBattlefield); return cards; } diff --git a/Mage/src/mage/watchers/common/CreaturesDiedWatcher.java b/Mage/src/mage/watchers/common/CreaturesDiedWatcher.java new file mode 100644 index 0000000000..98a83fb057 --- /dev/null +++ b/Mage/src/mage/watchers/common/CreaturesDiedWatcher.java @@ -0,0 +1,75 @@ +/* + * 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.watchers.common; + +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.watchers.Watcher; + +/** + * + * @author LevelX2 + */ + +public class CreaturesDiedWatcher extends Watcher { + + private int amountOfCreaturesThatDied; + + public CreaturesDiedWatcher() { + super("CreaturesDiedWatcher", WatcherScope.GAME); + } + + public CreaturesDiedWatcher(final CreaturesDiedWatcher watcher) { + super(watcher); + this.amountOfCreaturesThatDied = watcher.amountOfCreaturesThatDied; + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent)event).isDiesEvent()) { + amountOfCreaturesThatDied++; + } + } + + @Override + public void reset() { + amountOfCreaturesThatDied = 0; + } + + public int getAmountOfCreaturesDiesThisTurn() { + return amountOfCreaturesThatDied; + } + + @Override + public CreaturesDiedWatcher copy() { + return new CreaturesDiedWatcher(this); + } + +}