From daff690af3492223847a1568e885fae677c9fd41 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 8 Feb 2014 14:14:31 +0100 Subject: [PATCH] * Garruk, Caller of Beasts - Fixed that target for second ability was chosen before resolution. --- .../mage/sets/innistrad/SnapcasterMage.java | 3 +- .../sets/magic2014/GarrukCallerOfBeasts.java | 57 +++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/sets/innistrad/SnapcasterMage.java b/Mage.Sets/src/mage/sets/innistrad/SnapcasterMage.java index 38a5899e28..d83530063e 100644 --- a/Mage.Sets/src/mage/sets/innistrad/SnapcasterMage.java +++ b/Mage.Sets/src/mage/sets/innistrad/SnapcasterMage.java @@ -107,12 +107,13 @@ class SnapcasterMageEffect extends ContinuousEffectImpl { public SnapcasterMageEffect copy() { return new SnapcasterMageEffect(this); } + @Override public void init(Ability source, Game game) { Card card = game.getCard(targetPointer.getFirst(game, source)); MageObject sourceObject = game.getObject(source.getSourceId()); if (card != null && sourceObject != null) { - game.informPlayers(new StringBuilder(sourceObject.getName()).append(" gained Flashback to ").append(card.getName()).toString()); + game.informPlayers(new StringBuilder(sourceObject.getName()).append(" gives Flashback to ").append(card.getName()).toString()); } } diff --git a/Mage.Sets/src/mage/sets/magic2014/GarrukCallerOfBeasts.java b/Mage.Sets/src/mage/sets/magic2014/GarrukCallerOfBeasts.java index b4c07e1fb0..35753bd2c2 100644 --- a/Mage.Sets/src/mage/sets/magic2014/GarrukCallerOfBeasts.java +++ b/Mage.Sets/src/mage/sets/magic2014/GarrukCallerOfBeasts.java @@ -34,24 +34,27 @@ import mage.abilities.LoyaltyAbility; import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.SpellCastControllerTriggeredAbility; import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GetEmblemEffect; import mage.abilities.effects.common.PutOntoBattlefieldTargetEffect; import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; +import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; -import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.FilterSpell; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; import mage.game.command.Emblem; +import mage.players.Player; +import mage.target.Target; import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInLibrary; @@ -79,9 +82,7 @@ public class GarrukCallerOfBeasts extends CardImpl { this.addAbility(new LoyaltyAbility(new RevealLibraryPutIntoHandEffect(5, new FilterCreatureCard("all creature cards"),true), 1)); // -3: You may put a green creature card from your hand onto the battlefield. - LoyaltyAbility ability2 = new LoyaltyAbility(new PutOntoBattlefieldTargetEffect(false), -3); - ability2.addTarget(new TargetCardInHand(filterGreenCreature)); - this.addAbility(ability2); + this.addAbility(new LoyaltyAbility(new GarrukCallerOfBeastsPutOntoBattlefieldEffect(), -3)); // -7: You get an emblem with "Whenever you cast a creature spell, you may search your library for a creature card, put it onto the battlefield, then shuffle your library."); this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new GarrukCallerOfBeastsEmblem()), -7)); @@ -113,3 +114,49 @@ class GarrukCallerOfBeastsEmblem extends Emblem { this.getAbilities().add(ability); } } + +class GarrukCallerOfBeastsPutOntoBattlefieldEffect extends OneShotEffect { + + private static final FilterCreatureCard filterGreenCreature = new FilterCreatureCard("a green creature card from your hand"); + + static { + filterGreenCreature.add(new ColorPredicate(ObjectColor.GREEN)); + } + + public GarrukCallerOfBeastsPutOntoBattlefieldEffect() { + super(Outcome.PutCreatureInPlay); + this.staticText = "You may put a green creature card from your hand onto the battlefield"; + } + + public GarrukCallerOfBeastsPutOntoBattlefieldEffect(final GarrukCallerOfBeastsPutOntoBattlefieldEffect effect) { + super(effect); + } + + @Override + public GarrukCallerOfBeastsPutOntoBattlefieldEffect copy() { + return new GarrukCallerOfBeastsPutOntoBattlefieldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + if (controller.getHand().count(filterGreenCreature, game) > 0) { + + if (controller.chooseUse(Outcome.PutCreatureInPlay, + "Put a green creature card onto the battlefield?", game)) { + Target target = new TargetCardInHand(filterGreenCreature); + target.setRequired(true); + if (controller.chooseTarget(outcome, target, source, game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId()); + } + } + } + } + return true; + } + return false; + } +}