mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Generalize PutCreatureOnBattlefieldEffect -> PutPermanentOnBattlefieldEffect
This commit is contained in:
parent
e9a7257703
commit
3991ce08e5
5 changed files with 35 additions and 84 deletions
|
@ -32,7 +32,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect;
|
||||
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
|
@ -58,7 +58,7 @@ public class DragonArch extends CardImpl {
|
|||
this.expansionSetCode = "APC";
|
||||
|
||||
// {2}, {T}: You may put a multicolored creature card from your hand onto the battlefield.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutCreatureOnBattlefieldEffect(filter),
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutPermanentOnBattlefieldEffect(filter),
|
||||
new ManaCostsImpl("{2}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
|
|
@ -27,17 +27,18 @@
|
|||
*/
|
||||
package mage.sets.magic2010;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -56,7 +57,7 @@ public class ElvishPiper extends CardImpl {
|
|||
|
||||
// {G}, {tap}: You may put a creature card from your hand onto the battlefield.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PutCreatureOnBattlefieldEffect(),
|
||||
new PutPermanentOnBattlefieldEffect(new FilterCreatureCard("a creature card")),
|
||||
new ManaCostsImpl("{G}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
|
|
@ -30,11 +30,12 @@ package mage.sets.magic2012;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect;
|
||||
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class QuicksilverAmulet extends CardImpl {
|
|||
|
||||
// {4}, {tap}: You may put a creature card from your hand onto the battlefield.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PutCreatureOnBattlefieldEffect(),
|
||||
new PutPermanentOnBattlefieldEffect(new FilterCreatureCard("a creature card")),
|
||||
new ManaCostsImpl("{4}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
|
|
@ -34,24 +34,15 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
|
|||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.abilities.effects.common.PutCreatureOnBattlefieldEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.abilities.effects.common.PutPermanentOnBattlefieldEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -66,8 +57,10 @@ public class BelbesPortal extends CardImpl {
|
|||
// As Belbe's Portal enters the battlefield, choose a creature type.
|
||||
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.PutCreatureInPlay)));
|
||||
// {3}, {tap}: You may put a creature card of the chosen type from your hand onto the battlefield.
|
||||
SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new BelbesPortalPutCreatureOnBattlefieldEffect(),
|
||||
FilterCreatureCard filter = new FilterCreatureCard("a creature card of the chosen type");
|
||||
filter.add(new ChosenSubtypePredicate(this.getId()));
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
|
||||
new PutPermanentOnBattlefieldEffect(filter),
|
||||
new ManaCostsImpl("{3}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
@ -82,48 +75,3 @@ public class BelbesPortal extends CardImpl {
|
|||
return new BelbesPortal(this);
|
||||
}
|
||||
}
|
||||
|
||||
class BelbesPortalPutCreatureOnBattlefieldEffect extends OneShotEffect {
|
||||
BelbesPortalPutCreatureOnBattlefieldEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
staticText = "You may put a creature card of the chosen type from your hand onto the battlefield";
|
||||
}
|
||||
|
||||
BelbesPortalPutCreatureOnBattlefieldEffect(final BelbesPortalPutCreatureOnBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BelbesPortalPutCreatureOnBattlefieldEffect copy() {
|
||||
return new BelbesPortalPutCreatureOnBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
String subtype = (String) game.getState().getValue(permanent.getId() + "_type");
|
||||
if (subtype != null) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
String choiceText = "Put a " + subtype.toLowerCase() + " creature card from your hand onto the battlefield?";
|
||||
|
||||
if (player != null) {
|
||||
if (player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
|
||||
FilterCreatureCard creatureTypeFilter = new FilterCreatureCard();
|
||||
creatureTypeFilter.add(new SubtypePredicate(subtype));
|
||||
|
||||
TargetCardInHand target = new TargetCardInHand(creatureTypeFilter);
|
||||
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,8 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterPermanentCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
@ -14,34 +15,34 @@ import mage.target.common.TargetCardInHand;
|
|||
/**
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class PutCreatureOnBattlefieldEffect extends OneShotEffect {
|
||||
public class PutPermanentOnBattlefieldEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCreatureCard filter;
|
||||
private final FilterCard filter;
|
||||
|
||||
public PutCreatureOnBattlefieldEffect() {
|
||||
this(new FilterCreatureCard("a creature card"));
|
||||
public PutPermanentOnBattlefieldEffect() {
|
||||
this(new FilterPermanentCard("a permanent card"));
|
||||
}
|
||||
|
||||
public PutCreatureOnBattlefieldEffect(FilterCreatureCard filter) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
public PutPermanentOnBattlefieldEffect(FilterCard filter) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public PutCreatureOnBattlefieldEffect(final PutCreatureOnBattlefieldEffect effect) {
|
||||
public PutPermanentOnBattlefieldEffect(final PutPermanentOnBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PutCreatureOnBattlefieldEffect copy() {
|
||||
return new PutCreatureOnBattlefieldEffect(this);
|
||||
public PutPermanentOnBattlefieldEffect copy() {
|
||||
return new PutPermanentOnBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
String choiceText = "Put " + filter.getMessage() + " from your hand onto the battlefield?";
|
||||
if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
|
||||
if (player == null || !player.chooseUse(Outcome.PutCardInPlay, choiceText, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in a new issue