From 6979d2ce5ebb9ef31212596e44370b62e35c9a27 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 31 Aug 2015 17:07:43 +0200 Subject: [PATCH] * Momir Vig, Simic Visionary - Fixed, that the revealed card was wrongly moved to bottom of library if it's not creature instead of staying at top of library. --- .../dissension/MomirVigSimicVisionary.java | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/sets/dissension/MomirVigSimicVisionary.java b/Mage.Sets/src/mage/sets/dissension/MomirVigSimicVisionary.java index 0492eea149..8a23b3a442 100644 --- a/Mage.Sets/src/mage/sets/dissension/MomirVigSimicVisionary.java +++ b/Mage.Sets/src/mage/sets/dissension/MomirVigSimicVisionary.java @@ -27,20 +27,30 @@ */ package mage.sets.dissension; +import java.util.Set; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.ObjectColor; +import mage.abilities.Ability; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.effects.Effect; -import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.search.SearchLibraryPutOnLibraryEffect; +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.FilterSpell; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.ColorPredicate; +import mage.game.Game; +import mage.players.Player; import mage.target.common.TargetCardInLibrary; /** @@ -76,9 +86,7 @@ public class MomirVigSimicVisionary extends CardImpl { this.addAbility(new SpellCastControllerTriggeredAbility(effect, filter, true)); // Whenever you cast a blue creature spell, reveal the top card of your library. If it's a creature card, put that card into your hand. - Effect effect2 = new RevealLibraryPutIntoHandEffect(1, new FilterCreatureCard(), false); - effect2.setText("reveal the top card of your library. If it's a creature card, put that card into your hand"); - this.addAbility(new SpellCastControllerTriggeredAbility(effect2, filter2, false)); + this.addAbility(new SpellCastControllerTriggeredAbility(new MomirVigSimicVisionaryEffect(), filter2, false)); } @@ -91,3 +99,44 @@ public class MomirVigSimicVisionary extends CardImpl { return new MomirVigSimicVisionary(this); } } + +class MomirVigSimicVisionaryEffect extends OneShotEffect { + + public MomirVigSimicVisionaryEffect() { + super(Outcome.DrawCard); + this.staticText = "reveal the top card of your library. If it's a creature card, put that card into your hand"; + } + + public MomirVigSimicVisionaryEffect(final MomirVigSimicVisionaryEffect effect) { + super(effect); + } + + @Override + public MomirVigSimicVisionaryEffect copy() { + return new MomirVigSimicVisionaryEffect(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) { + return false; + } + + CardsImpl cards = new CardsImpl(); + cards.addAll(controller.getLibrary().getTopCards(game, 1)); + controller.revealCards(sourceObject.getIdName(), cards, game); + + Set cardsList = cards.getCards(game); + Cards cardsToHand = new CardsImpl(); + for (Card card : cardsList) { + if (card.getCardType().contains(CardType.CREATURE)) { + cardsToHand.add(card); + cards.remove(card); + } + } + controller.moveCards(cardsToHand, null, Zone.HAND, source, game); + return true; + } +}