diff --git a/Mage.Sets/src/mage/sets/magic2010/ElvishPiper.java b/Mage.Sets/src/mage/sets/magic2010/ElvishPiper.java index 56e9370b0f..993afd1195 100644 --- a/Mage.Sets/src/mage/sets/magic2010/ElvishPiper.java +++ b/Mage.Sets/src/mage/sets/magic2010/ElvishPiper.java @@ -27,24 +27,20 @@ */ package mage.sets.magic2010; -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.PutCreatureOnBattlefieldEffect; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.common.FilterCreatureCard; -import mage.game.Game; -import mage.players.Player; import mage.target.common.TargetCardInHand; +import java.util.UUID; + /** * * @author North @@ -79,31 +75,3 @@ public class ElvishPiper extends CardImpl { return new ElvishPiper(this); } } - -class PutCreatureOnBattlefieldEffect extends OneShotEffect { - - public PutCreatureOnBattlefieldEffect() { - super(Outcome.PutCreatureInPlay); - this.staticText = "You may put a creature card from your hand into play"; - } - - public PutCreatureOnBattlefieldEffect(final PutCreatureOnBattlefieldEffect effect) { - super(effect); - } - - @Override - public PutCreatureOnBattlefieldEffect copy() { - return new PutCreatureOnBattlefieldEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Card card = game.getCard(source.getFirstTarget()); - Player player = game.getPlayer(card.getOwnerId()); - if (card != null && player != null) { - card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId()); - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/magic2012/QuicksilverAmulet.java b/Mage.Sets/src/mage/sets/magic2012/QuicksilverAmulet.java index e54f78606a..4c8e529492 100644 --- a/Mage.Sets/src/mage/sets/magic2012/QuicksilverAmulet.java +++ b/Mage.Sets/src/mage/sets/magic2012/QuicksilverAmulet.java @@ -27,22 +27,16 @@ */ package mage.sets.magic2012; -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.common.PutCreatureOnBattlefieldEffect; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.filter.common.FilterCreatureCard; -import mage.game.Game; -import mage.players.Player; -import mage.target.common.TargetCardInHand; + +import java.util.UUID; /** * @@ -72,39 +66,4 @@ public class QuicksilverAmulet extends CardImpl { } } -class PutCreatureOnBattlefieldEffect extends OneShotEffect { - private static final String choiceText = "Put a creature card from your hand onto the battlefield?"; - - public PutCreatureOnBattlefieldEffect() { - super(Outcome.PutCreatureInPlay); - this.staticText = "You may put a creature card from your hand onto the battlefield"; - } - - public PutCreatureOnBattlefieldEffect(final PutCreatureOnBattlefieldEffect effect) { - super(effect); - } - - @Override - public PutCreatureOnBattlefieldEffect copy() { - return new PutCreatureOnBattlefieldEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, game)) { - return false; - } - - TargetCardInHand target = new TargetCardInHand(new FilterCreatureCard()); - if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { - Card card = game.getCard(target.getFirstTarget()); - if (card != null) { - card.putOntoBattlefield(game, Zone.HAND, source.getId(), source.getControllerId()); - return true; - } - } - return false; - } -} diff --git a/Mage/src/mage/abilities/common/PutCreatureOnBattlefieldEffect.java b/Mage/src/mage/abilities/common/PutCreatureOnBattlefieldEffect.java new file mode 100644 index 0000000000..077e13f290 --- /dev/null +++ b/Mage/src/mage/abilities/common/PutCreatureOnBattlefieldEffect.java @@ -0,0 +1,50 @@ +package mage.abilities.common; + +import mage.Constants; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.filter.common.FilterCreatureCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInHand; + +/** + * @author magenoxx_at_gmail.com + */ +public class PutCreatureOnBattlefieldEffect extends OneShotEffect { + + private static final String choiceText = "Put a creature card from your hand onto the battlefield?"; + + public PutCreatureOnBattlefieldEffect() { + super(Constants.Outcome.PutCreatureInPlay); + this.staticText = "You may put a creature card from your hand onto the battlefield"; + } + + public PutCreatureOnBattlefieldEffect(final PutCreatureOnBattlefieldEffect effect) { + super(effect); + } + + @Override + public PutCreatureOnBattlefieldEffect copy() { + return new PutCreatureOnBattlefieldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || !player.chooseUse(Constants.Outcome.PutCreatureInPlay, choiceText, game)) { + return false; + } + + TargetCardInHand target = new TargetCardInHand(new FilterCreatureCard()); + if (player.choose(Constants.Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + card.putOntoBattlefield(game, Constants.Zone.HAND, source.getId(), source.getControllerId()); + return true; + } + } + return false; + } +} \ No newline at end of file