mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Extracteed PutCreatureOnBattlefieldEffect. Refactored 2 cards.
This commit is contained in:
parent
d5be1178b2
commit
50812d6a1c
3 changed files with 56 additions and 79 deletions
|
@ -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<ElvishPiper> {
|
|||
return new ElvishPiper(this);
|
||||
}
|
||||
}
|
||||
|
||||
class PutCreatureOnBattlefieldEffect extends OneShotEffect<PutCreatureOnBattlefieldEffect> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<QuicksilverAmulet> {
|
|||
}
|
||||
}
|
||||
|
||||
class PutCreatureOnBattlefieldEffect extends OneShotEffect<PutCreatureOnBattlefieldEffect> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<PutCreatureOnBattlefieldEffect> {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue