diff --git a/Mage.Sets/src/mage/sets/conflux/MasterTransmuter.java b/Mage.Sets/src/mage/sets/conflux/MasterTransmuter.java index 98fb20c1ff8..fcae2dcac52 100644 --- a/Mage.Sets/src/mage/sets/conflux/MasterTransmuter.java +++ b/Mage.Sets/src/mage/sets/conflux/MasterTransmuter.java @@ -28,25 +28,19 @@ package mage.sets.conflux; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.ReturnToHandTargetPermanentCost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterControlledArtifactPermanent; -import mage.game.Game; -import mage.players.Player; -import mage.target.Target; -import mage.target.common.TargetCardInHand; import mage.target.common.TargetControlledPermanent; /** @@ -65,7 +59,7 @@ public class MasterTransmuter extends CardImpl { this.toughness = new MageInt(2); // {U}, {tap}, Return an artifact you control to its owner's hand: You may put an artifact card from your hand onto the battlefield. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MasterTransmuterEffect(), new ManaCostsImpl("{U}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(new FilterArtifactCard("an artifact card")), new ManaCostsImpl("{U}")); ability.addCost(new TapSourceCost()); ability.addCost(new ReturnToHandTargetPermanentCost(new TargetControlledPermanent(new FilterControlledArtifactPermanent("an artifact")))); this.addAbility(ability); @@ -81,38 +75,3 @@ public class MasterTransmuter extends CardImpl { return new MasterTransmuter(this); } } - -class MasterTransmuterEffect extends OneShotEffect { - - public MasterTransmuterEffect() { - super(Outcome.Benefit); - this.staticText = "You may put an artifact card from your hand onto the battlefield"; - } - - public MasterTransmuterEffect(final MasterTransmuterEffect effect) { - super(effect); - } - - @Override - public MasterTransmuterEffect copy() { - return new MasterTransmuterEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Target target = new TargetCardInHand(new FilterArtifactCard("an artifact card from your hand")); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.chooseUse(outcome, "Put an artifact from your hand to battlefield?", source, game) - && controller.chooseTarget(outcome, target, source, game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - } - } - } - - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/eventide/MindwrackLiege.java b/Mage.Sets/src/mage/sets/eventide/MindwrackLiege.java index eda9db62341..f0d5714b775 100644 --- a/Mage.Sets/src/mage/sets/eventide/MindwrackLiege.java +++ b/Mage.Sets/src/mage/sets/eventide/MindwrackLiege.java @@ -30,17 +30,14 @@ package mage.sets.eventide; import java.util.UUID; import mage.MageInt; import mage.ObjectColor; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect; import mage.abilities.effects.common.continuous.BoostAllEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; @@ -49,9 +46,6 @@ import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.ColorPredicate; import mage.filter.predicate.permanent.ControllerPredicate; -import mage.game.Game; -import mage.players.Player; -import mage.target.common.TargetCardInHand; /** * @@ -59,15 +53,17 @@ import mage.target.common.TargetCardInHand; */ public class MindwrackLiege extends CardImpl { - + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("blue creatures you control"); private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("red creatures you control"); + private static final FilterCreatureCard filter3 = new FilterCreatureCard("a blue or red creature card"); + static { filter.add(new ColorPredicate(ObjectColor.BLUE)); filter.add(new ControllerPredicate(TargetController.YOU)); - filter2.add(new ColorPredicate(ObjectColor.RED)); filter2.add(new ControllerPredicate(TargetController.YOU)); + filter3.add(Predicates.or(new ColorPredicate(ObjectColor.BLUE), new ColorPredicate(ObjectColor.RED))); } public MindwrackLiege(UUID ownerId) { @@ -80,13 +76,12 @@ public class MindwrackLiege extends CardImpl { // Other blue creatures you control get +1/+1. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, true))); - + // Other red creatures you control get +1/+1. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter2, true))); - + // {UR}{UR}{UR}{UR}: You may put a blue or red creature card from your hand onto the battlefield. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new MindwrackLiegeEffect(), new ManaCostsImpl("{U/R}{U/R}{U/R}{U/R}"))); - + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(filter3), new ManaCostsImpl("{U/R}{U/R}{U/R}{U/R}"))); } public MindwrackLiege(final MindwrackLiege card) { @@ -98,48 +93,3 @@ public class MindwrackLiege extends CardImpl { return new MindwrackLiege(this); } } - -class MindwrackLiegeEffect extends OneShotEffect { - - private static final String choiceText = "Put a blue or red creature card from your hand onto the battlefield?"; - - private static final FilterCreatureCard filter = new FilterCreatureCard("a blue or red creature card"); - - static { - filter.add(Predicates.or( - new ColorPredicate(ObjectColor.BLUE), - new ColorPredicate(ObjectColor.RED))); - } - - public MindwrackLiegeEffect() { - super(Outcome.PutCreatureInPlay); - this.staticText = "You may put a blue or red creature card from your hand onto the battlefield"; - } - - public MindwrackLiegeEffect(final MindwrackLiegeEffect effect) { - super(effect); - } - - @Override - public MindwrackLiegeEffect copy() { - return new MindwrackLiegeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) { - return false; - } - - TargetCardInHand target = new TargetCardInHand(filter); - if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId()); - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/urzassaga/GoblinLackey.java b/Mage.Sets/src/mage/sets/urzassaga/GoblinLackey.java index f4f44011f6f..282a8788916 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/GoblinLackey.java +++ b/Mage.Sets/src/mage/sets/urzassaga/GoblinLackey.java @@ -29,22 +29,13 @@ package mage.sets.urzassaga; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; +import mage.abilities.common.DealsDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.Zone; import mage.filter.common.FilterPermanentCard; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.players.Player; -import mage.target.common.TargetCardInHand; /** * @@ -52,6 +43,12 @@ import mage.target.common.TargetCardInHand; */ public class GoblinLackey extends CardImpl { + private static final FilterPermanentCard filter = new FilterPermanentCard("a Goblin permanent card"); + + static { + filter.add(new SubtypePredicate("Goblin")); + } + public GoblinLackey(UUID ownerId) { super(ownerId, 190, "Goblin Lackey", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{R}"); this.expansionSetCode = "USG"; @@ -61,7 +58,7 @@ public class GoblinLackey extends CardImpl { this.toughness = new MageInt(1); // Whenever Goblin Lackey deals damage to a player, you may put a Goblin permanent card from your hand onto the battlefield. - this.addAbility(new GoblinLackeyTriggeredAbility()); + this.addAbility(new DealsDamageToAPlayerTriggeredAbility(new PutPermanentOnBattlefieldEffect(filter), false)); } public GoblinLackey(final GoblinLackey card) { @@ -73,72 +70,3 @@ public class GoblinLackey extends CardImpl { return new GoblinLackey(this); } } - -class GoblinLackeyTriggeredAbility extends TriggeredAbilityImpl { - - public GoblinLackeyTriggeredAbility() { - super(Zone.BATTLEFIELD, new GoblinLackeyEffect(), true); - } - - public GoblinLackeyTriggeredAbility(final GoblinLackeyTriggeredAbility ability) { - super(ability); - } - - @Override - public GoblinLackeyTriggeredAbility copy() { - return new GoblinLackeyTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.DAMAGED_PLAYER; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - return event.getSourceId().equals(this.sourceId) - && game.getOpponents(this.getControllerId()).contains(event.getTargetId()); - } - - @Override - public String getRule() { - return "Whenever {this} deals damage to an opponent, you may put a Goblin permanent card from your hand onto the battlefield."; - } -} - -class GoblinLackeyEffect extends OneShotEffect { - - public GoblinLackeyEffect() { - super(Outcome.PutCreatureInPlay); - this.staticText = "you may put a Goblin permanent card from your hand onto the battlefield"; - } - - public GoblinLackeyEffect(final GoblinLackeyEffect effect) { - super(effect); - } - - @Override - public GoblinLackeyEffect copy() { - return new GoblinLackeyEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller == null) { - return false; - } - FilterPermanentCard filter = new FilterPermanentCard("Goblin permanent card from your hand"); - filter.add(new SubtypePredicate("Goblin")); - TargetCardInHand target = new TargetCardInHand(filter); - if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - } else { - return false; - } - } - return true; - } -} diff --git a/Mage.Sets/src/mage/sets/worldwake/StoneforgeMystic.java b/Mage.Sets/src/mage/sets/worldwake/StoneforgeMystic.java index 6d1f9a9bae8..3a87eb36ce0 100644 --- a/Mage.Sets/src/mage/sets/worldwake/StoneforgeMystic.java +++ b/Mage.Sets/src/mage/sets/worldwake/StoneforgeMystic.java @@ -1,16 +1,16 @@ /* * 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 @@ -20,7 +20,7 @@ * 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. @@ -35,26 +35,16 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.FilterCard; -import mage.filter.common.FilterArtifactCard; -import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.players.Player; -import mage.target.Target; -import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInLibrary; - - /** * * @author BetaSteward_at_googlemail.com @@ -64,7 +54,6 @@ public class StoneforgeMystic extends CardImpl { private static final FilterCard filter = new FilterCard("an Equipment card"); static { - filter.add(new CardTypePredicate(CardType.ARTIFACT)); filter.add(new SubtypePredicate("Equipment")); } @@ -82,7 +71,7 @@ public class StoneforgeMystic extends CardImpl { this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInHandEffect(target, true, true), true)); // {1}{W}, {T}: You may put an Equipment card from your hand onto the battlefield. - SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new StoneforgeMysticEffect(), new ManaCostsImpl("{1}{W}")); + SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(filter), new ManaCostsImpl("{1}{W}")); ability.addCost(new TapSourceCost()); this.addAbility(ability); } @@ -97,44 +86,3 @@ public class StoneforgeMystic extends CardImpl { } } - -class StoneforgeMysticEffect extends OneShotEffect { - - private static final FilterArtifactCard filter = new FilterArtifactCard("an Equipment card from your hand"); - - static { - filter.add(new SubtypePredicate("Equipment")); - } - - public StoneforgeMysticEffect() { - super(Outcome.Benefit); - this.staticText = "You may put an Equipment card from your hand onto the battlefield"; - } - - public StoneforgeMysticEffect(final StoneforgeMysticEffect effect) { - super(effect); - } - - @Override - public StoneforgeMysticEffect copy() { - return new StoneforgeMysticEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Target target = new TargetCardInHand(filter); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) - && controller.chooseUse(outcome, "Put an Equipment from your hand to battlefield?", source, game) - && controller.chooseTarget(outcome, target, source, game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); - } - } - return true; - } - return false; - } -}