From 7f13b7ba2626dad227419ea65124ec110e42b53a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 14 Sep 2014 23:54:44 +0200 Subject: [PATCH] [KTK] Taigam's Scheming - Fixed wrong handling and tooltip text. --- .../sets/khansoftarkir/TaigamsScheming.java | 81 ++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java b/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java index a3309928f9..63bb5495d3 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/TaigamsScheming.java @@ -27,14 +27,23 @@ */ package mage.sets.khansoftarkir; +import java.util.List; import java.util.UUID; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.common.LookLibraryAndPickControllerEffect; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +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.filter.FilterCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; /** * @@ -49,7 +58,7 @@ public class TaigamsScheming extends CardImpl { this.color.setBlue(true); // Look at the top five cards of your library. Put any number of them into your graveyard and the rest back on top of your library in any order - this.getSpellAbility().addEffect(new LookLibraryAndPickControllerEffect(new StaticValue(5) , false, new StaticValue(5), new FilterCard(), Zone.GRAVEYARD, true, false, true)); + this.getSpellAbility().addEffect(new TaigamsSchemingEffect()); } public TaigamsScheming(final TaigamsScheming card) { @@ -61,3 +70,69 @@ public class TaigamsScheming extends CardImpl { return new TaigamsScheming(this); } } + +class TaigamsSchemingEffect extends OneShotEffect { + + public TaigamsSchemingEffect() { + super(Outcome.Benefit); + this.staticText = "Look at the top five cards of your library. Put any number of them into your graveyard and the rest back on top of your library in any order"; + } + + public TaigamsSchemingEffect(final TaigamsSchemingEffect effect) { + super(effect); + } + + @Override + public TaigamsSchemingEffect copy() { + return new TaigamsSchemingEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + boolean topCardRevealed = controller.isTopCardRevealed(); + controller.setTopCardRevealed(false); + // get cards from top + Cards cards = new CardsImpl(); + int count = Math.min(controller.getLibrary().size(), 5); + if (count > 0) { + cards.addAll(controller.getLibrary().getTopCards(game, count)); + controller.lookAtCards(sourceObject.getLogName(), cards, game); + // pick cards going to graveyard + TargetCard target = new TargetCard(0,5, Zone.LIBRARY, new FilterCard("cards to put into your graveyard")); + if (controller.choose(Outcome.Detriment, cards, target, game)) { + for (UUID cardId : (List)target.getTargets()) { + Card card = cards.get(cardId, game); + if (card != null) { + cards.remove(card); + controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.LIBRARY); + } + } + } + // The rest goes back to library in any order + if (cards.size() > 0) { + game.informPlayers(controller.getName() + " puts " + cards.size() + " card" + (cards.size() ==1 ? "":"s") + " back to his or her library"); + target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put on your library (last chosen will be on top)")); + while (controller.isInGame() && cards.size() > 1) { + controller.choose(Outcome.Neutral, cards, target, game); + Card card = cards.get(target.getFirstTarget(), game); + if (card != null) { + cards.remove(card); + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } + target.clearChosen(); + } + if (cards.size() == 1) { + Card card = cards.get(cards.iterator().next(), game); + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } + } + } + controller.setTopCardRevealed(topCardRevealed); + return true; + } + return false; + } +}