* Some rework of play card effects.

This commit is contained in:
LevelX2 2015-11-26 17:06:50 +01:00
parent 780702be1b
commit eb6a5e7dcb
14 changed files with 201 additions and 240 deletions

View file

@ -113,7 +113,7 @@ class EmeriaShepherdReturnToHandTargetEffect extends OneShotEffect {
&& controller.chooseUse(Outcome.PutCardInPlay, "Put the card to battlefield instead?", source, game)) {
toZone = Zone.BATTLEFIELD;
}
return controller.moveCards(new CardsImpl(targetPointer.getTargets(game, source)), null, toZone, source, game);
return controller.moveCards(new CardsImpl(targetPointer.getTargets(game, source)), toZone, source, game);
}
}

View file

@ -109,11 +109,11 @@ class GuileReplacementEffect extends ReplacementEffectImpl {
Spell spell = game.getStack().getSpell(event.getTargetId());
Player controller = game.getPlayer(source.getControllerId());
if (spell != null && controller != null) {
controller.moveCards(spell, null, Zone.EXILED, source, game);
controller.moveCards(spell, Zone.EXILED, source, game);
if (!spell.isCopy()) {
Card spellCard = spell.getCard();
if (spellCard != null && controller.chooseUse(Outcome.PlayForFree, "Cast " + spellCard.getIdName() + " for free?", source, game)) {
controller.cast(spellCard.getSpellAbility(), game, true);
controller.playCard(spellCard, game, true, true);
}
return true;
}

View file

@ -33,9 +33,9 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -55,11 +55,11 @@ import mage.target.common.TargetCardInYourGraveyard;
public class HordeOfNotions extends CardImpl {
private final static FilterCard filter = new FilterCard("Elemental card from your graveyard");
static {
filter.add(new SubtypePredicate("Elemental"));
}
public HordeOfNotions(UUID ownerId) {
super(ownerId, 249, "Horde of Notions", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{W}{U}{B}{R}{G}");
this.expansionSetCode = "LRW";
@ -74,8 +74,8 @@ public class HordeOfNotions extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
// Haste
this.addAbility(HasteAbility.getInstance());
// {W}{U}{B}{R}{G}: You may play target Elemental card from your graveyard without paying its mana cost.
// {W}{U}{B}{R}{G}: You may play target Elemental card from your graveyard without paying its mana cost.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HordeOfNotionsEffect(), new ManaCostsImpl<>("{W}{U}{B}{R}{G}"));
ability.addTarget(new TargetCardInYourGraveyard(filter));
this.addAbility(ability);
@ -92,37 +92,28 @@ public class HordeOfNotions extends CardImpl {
}
class HordeOfNotionsEffect extends OneShotEffect {
public HordeOfNotionsEffect() {
super(Outcome.PlayForFree);
this.staticText = "You may play target Elemental card from your graveyard without paying its mana cost";
}
public HordeOfNotionsEffect(final HordeOfNotionsEffect effect) {
super(effect);
}
@Override
public HordeOfNotionsEffect copy() {
return new HordeOfNotionsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null ) {
// Probably there is no Elemental land, but who knows
if (card.getCardType().contains(CardType.LAND) && controller.canPlayLand() &&
controller.chooseUse(outcome, "Play " + card.getName() + " from your graveyard for free?", source, game)) {
controller.playLand(card, game);
} else {
if (card.getSpellAbility().canChooseTarget(game) &&
controller.chooseUse(outcome, "Play " + card.getName() + " from your graveyard for free?", source, game)) {
controller.cast(card.getSpellAbility(), game, true);
}
}
if (card != null && controller.chooseUse(outcome, "Play " + card.getName() + " from your graveyard for free?", source, game)) {
controller.playCard(card, game, true, true);
}
return true;
}

View file

@ -28,12 +28,8 @@
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.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
@ -46,6 +42,10 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
@ -100,33 +100,16 @@ class DjinnOfWishesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Djinn of Wishes", cards, game);
player.getLibrary().removeFromTop(game);
boolean used = false;
if (player.chooseUse(Outcome.PlayForFree, "Play " + card.getName() + " without paying its mana cost?", source, game)) {
if (card.getCardType().contains(CardType.LAND)) {
// If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn.
if (game.getActivePlayerId().equals(player.getId()) && player.canPlayLand()) {
used = true;
player.playLand(card, game);
}
} else {
used = true;
player.cast(card.getSpellAbility(), game, true);
}
}
if (!used) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null && controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
if (!controller.chooseUse(Outcome.PlayForFree, "Play " + card.getName() + " without paying its mana cost?", source, game)
|| !controller.playCard(card, game, true, true)) {
card.moveToZone(Zone.EXILED, source.getSourceId(), game, false);
}
return true;
}
return false;

View file

@ -55,10 +55,10 @@ public class LeafCrownedElder extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(5);
// Kinship - At the beginning of your upkeep, you may look at the top card of your library. If it shares a creature type with Leaf-Crowned Elder, you may reveal it.
// Kinship - At the beginning of your upkeep, you may look at the top card of your library. If it shares a creature type with Leaf-Crowned Elder, you may reveal it.
// If you do, you may play that card without paying its mana cost.
this.addAbility(new KinshipAbility(new LeafCrownedElderPlayEffect()));
}
public LeafCrownedElder(final LeafCrownedElder card) {
@ -84,18 +84,11 @@ class LeafCrownedElderPlayEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (player != null && card != null) {
if (player.chooseUse(Outcome.PlayForFree, "Play " + card.getName() + " without paying its mana cost?", source, game)) {
if (card.getCardType().contains(CardType.LAND)) {
// If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn.
if (game.getActivePlayerId().equals(player.getId()) && player.canPlayLand()) {
player.playLand(card, game);
}
} else {
player.cast(card.getSpellAbility(), game, true);
}
if (controller != null && card != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Play " + card.getIdName() + " without paying its mana cost?", source, game)) {
controller.playCard(card, game, true, true);
}
return true;
}

View file

@ -30,6 +30,7 @@ package mage.sets.shardsofalara;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
@ -56,11 +57,8 @@ public class BrilliantUltimatum extends CardImpl {
super(ownerId, 159, "Brilliant Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{W}{W}{U}{U}{U}{B}{B}");
this.expansionSetCode = "ALA";
// Exile the top five cards of your library. An opponent separates those cards into two piles. You may play any number of cards from one of those piles without paying their mana costs.
this.getSpellAbility().addEffect(new BrilliantUltimatumEffect());
this.getSpellAbility().addTarget(new TargetOpponent(true));
}
public BrilliantUltimatum(final BrilliantUltimatum card) {
@ -91,22 +89,19 @@ class BrilliantUltimatumEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
if (you == null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
Cards pile2 = new CardsImpl();
int max = Math.min(you.getLibrary().size(), 5);
for (int i = 0; i < max; i++) {
Card card = you.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToExile(source.getSourceId(), "Brilliant Ultimatum", source.getSourceId(), game);
pile2.add(card);
}
}
pile2.addAll(controller.getLibrary().getTopCards(game, 5));
controller.moveCardsToExile(pile2.getCards(game), source, game, true, source.getSourceId(), sourceObject.getIdName());
Player opponent = game.getPlayer(source.getFirstTarget());
TargetOpponent targetOpponent = new TargetOpponent(true);
targetOpponent.choose(outcome, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
if (opponent != null) {
TargetCard target = new TargetCard(0, pile2.size(), Zone.EXILED, new FilterCard("cards to put in the first pile"));
target.setRequired(false);
@ -123,55 +118,32 @@ class BrilliantUltimatumEffect extends OneShotEffect {
}
}
}
for (UUID cardID : pile1) {
Card card = pile1.get(cardID, game);
pileOne.add(card);
}
for (UUID cardId : pile2) {
Card card = pile2.get(cardId, game);
pileTwo.add(card);
}
you.revealCards("Pile 1 (Brilliant Ultimatum)", pile1, game);
you.revealCards("Pile 2 (Brilliant Ultimatum)", pile2, game);
boolean choice = you.choosePile(Outcome.PlayForFree, "Which pile (play for free)?", pileOne, pileTwo, game);
pileOne.addAll(pile1.getCards(game));
pileTwo.addAll(pile2.getCards(game));
controller.revealCards("Pile 1 - " + sourceObject.getIdName(), pile1, game);
controller.revealCards("Pile 2 - " + sourceObject.getIdName(), pile2, game);
boolean choice = controller.choosePile(Outcome.PlayForFree, "Which pile (play for free)?", pileOne, pileTwo, game);
String selectedPileName;
List<Card> selectedPileCards;
Cards selectedPile;
if (choice) {
game.informPlayer(you, you.getLogName() + " chose Pile 1.");
while (!pileOne.isEmpty() && you.chooseUse(Outcome.PlayForFree, "Do you want to play a card from Pile 1?", source, game)) {
TargetCard targetExiledCard = new TargetCard(Zone.EXILED, new FilterCard());
if (you.chooseTarget(Outcome.PlayForFree, pile1, targetExiledCard, source, game)) {
Card card = pile1.get(targetExiledCard.getFirstTarget(), game);
if (card != null) {
if (card.getCardType().contains(CardType.LAND)) {
you.playLand(card, game);
pileOne.remove(card);
pile1.remove(card);
} else {
you.cast(card.getSpellAbility(), game, true);
pileOne.remove(card);
pile1.remove(card);
}
}
}
}
selectedPileName = "pile 1";
selectedPileCards = pileOne;
selectedPile = pile1;
} else {
game.informPlayer(you, you.getLogName() + " chose Pile 2.");
while (!pileTwo.isEmpty() && you.chooseUse(Outcome.PlayForFree, "Do you want to play a card from Pile 2?", source, game)) {
TargetCard targetExiledCard = new TargetCard(Zone.EXILED, new FilterCard());
if (you.chooseTarget(Outcome.PlayForFree, pile2, targetExiledCard, source, game)) {
Card card = pile2.get(targetExiledCard.getFirstTarget(), game);
if (card != null) {
if (card.getCardType().contains(CardType.LAND)) {
you.playLand(card, game);
pileTwo.remove(card);
pile2.remove(card);
} else {
you.cast(card.getSpellAbility(), game, true);
pileTwo.remove(card);
pile2.remove(card);
}
}
selectedPileName = "pile 2";
selectedPileCards = pileTwo;
selectedPile = pile2;
}
game.informPlayers(controller.getLogName() + " chose " + selectedPileName + ".");
while (!selectedPileCards.isEmpty() && controller.chooseUse(Outcome.PlayForFree, "Do you want to play a card for free from " + selectedPileName + "?", source, game)) {
TargetCard targetExiledCard = new TargetCard(Zone.EXILED, new FilterCard());
if (controller.chooseTarget(Outcome.PlayForFree, selectedPile, targetExiledCard, source, game)) {
Card card = selectedPile.get(targetExiledCard.getFirstTarget(), game);
if (controller.playCard(card, game, true, true)) {
selectedPileCards.remove(card);
selectedPile.remove(card);
}
}
}