From a78a0c47a93c2ef0cff95c11b22d2f01e841c1ad Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 28 Dec 2012 17:32:08 +0100 Subject: [PATCH] Fixed bug of Reflecting Pool, used common Ability in Lurking Predator. --- .../mage/sets/magic2010/LurkingPredators.java | 35 +----- .../src/mage/sets/tempest/ReflectingPool.java | 100 +++++++++--------- 2 files changed, 52 insertions(+), 83 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2010/LurkingPredators.java b/Mage.Sets/src/mage/sets/magic2010/LurkingPredators.java index 813626e835b..88c3dd2cea6 100644 --- a/Mage.Sets/src/mage/sets/magic2010/LurkingPredators.java +++ b/Mage.Sets/src/mage/sets/magic2010/LurkingPredators.java @@ -33,15 +33,13 @@ import mage.Constants.Outcome; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.common.OpponentCastsSpellTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; /** @@ -57,7 +55,7 @@ public class LurkingPredators extends CardImpl { this.color.setGreen(true); // Whenever an opponent casts a spell, reveal the top card of your library. If it's a creature card, put it onto the battlefield. Otherwise, you may put that card on the bottom of your library. - this.addAbility(new LurkingPredatorsTriggeredAbility()); + this.addAbility(new OpponentCastsSpellTriggeredAbility(new LurkingPredatorsEffect(), false)); } public LurkingPredators(final LurkingPredators card) { @@ -70,35 +68,6 @@ public class LurkingPredators extends CardImpl { } } -class LurkingPredatorsTriggeredAbility extends TriggeredAbilityImpl { - - public LurkingPredatorsTriggeredAbility() { - super(Zone.BATTLEFIELD, new LurkingPredatorsEffect()); - } - - public LurkingPredatorsTriggeredAbility(final LurkingPredatorsTriggeredAbility ability) { - super(ability); - } - - @Override - public LurkingPredatorsTriggeredAbility copy() { - return new LurkingPredatorsTriggeredAbility(this); - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == EventType.SPELL_CAST && game.getOpponents(controllerId).contains(event.getPlayerId())) { - return true; - } - return false; - } - - @Override - public String getRule() { - return "Whenever an opponent casts a spell, reveal the top card of your library. If it's a creature card, put it onto the battlefield. Otherwise, you may put that card on the bottom of your library"; - } -} - class LurkingPredatorsEffect extends OneShotEffect { public LurkingPredatorsEffect() { diff --git a/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java b/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java index 03fc491ca99..0a301d6c51a 100644 --- a/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java +++ b/Mage.Sets/src/mage/sets/tempest/ReflectingPool.java @@ -35,10 +35,10 @@ import mage.Constants.Rarity; import mage.Mana; import mage.abilities.Abilities; import mage.abilities.Ability; -import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.effects.common.ManaEffect; import mage.abilities.mana.ManaAbility; +import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; import mage.choices.Choice; import mage.choices.ChoiceImpl; @@ -59,7 +59,7 @@ public class ReflectingPool extends CardImpl { this.expansionSetCode = "TMP"; // {T}: Add to your mana pool one mana of any type that a land you control could produce. - this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new ReflectingPoolEffect(), new TapSourceCost())); + this.addAbility(new SimpleManaAbility(Constants.Zone.BATTLEFIELD, new ReflectingPoolEffect(), new TapSourceCost())); } public ReflectingPool(final ReflectingPool card) { @@ -88,60 +88,60 @@ class ReflectingPoolEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { List lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); + Mana types = new Mana(); for (Permanent land : lands) { Abilities mana = land.getAbilities().getManaAbilities(Constants.Zone.BATTLEFIELD); - Mana types = new Mana(); for (ManaAbility ability : mana) { types.add(ability.getNetMana(game)); } - Choice choice = new ChoiceImpl(true); - choice.setMessage("Pick a mana color"); - if (types.getBlack() > 0) { - choice.getChoices().add("Black"); + } + Choice choice = new ChoiceImpl(true); + choice.setMessage("Pick a mana color"); + if (types.getBlack() > 0) { + choice.getChoices().add("Black"); + } + if (types.getRed() > 0) { + choice.getChoices().add("Red"); + } + if (types.getBlue() > 0) { + choice.getChoices().add("Blue"); + } + if (types.getGreen() > 0) { + choice.getChoices().add("Green"); + } + if (types.getWhite() > 0) { + choice.getChoices().add("White"); + } + if (types.getColorless() > 0) { + choice.getChoices().add("Colorless"); + } + if (types.getAny() > 0) { + choice.getChoices().add("Black"); + choice.getChoices().add("Red"); + choice.getChoices().add("Blue"); + choice.getChoices().add("Green"); + choice.getChoices().add("White"); + choice.getChoices().add("Colorless"); + } + if (choice.getChoices().size() > 0) { + Player player = game.getPlayer(source.getControllerId()); + if (choice.getChoices().size() == 1) { + choice.setChoice(choice.getChoices().iterator().next()); + } else { + player.choose(outcome, choice, game); } - if (types.getRed() > 0) { - choice.getChoices().add("Red"); - } - if (types.getBlue() > 0) { - choice.getChoices().add("Blue"); - } - if (types.getGreen() > 0) { - choice.getChoices().add("Green"); - } - if (types.getWhite() > 0) { - choice.getChoices().add("White"); - } - if (types.getColorless() > 0) { - choice.getChoices().add("Colorless"); - } - if (types.getAny() > 0) { - choice.getChoices().add("Black"); - choice.getChoices().add("Red"); - choice.getChoices().add("Blue"); - choice.getChoices().add("Green"); - choice.getChoices().add("White"); - choice.getChoices().add("Colorless"); - } - if (choice.getChoices().size() > 0) { - Player player = game.getPlayer(source.getControllerId()); - if (choice.getChoices().size() == 1) { - choice.setChoice(choice.getChoices().iterator().next()); - } else { - player.choose(outcome, choice, game); - } - if (choice.getChoice().equals("Black")) { - player.getManaPool().addMana(Mana.BlackMana, game, source); - } else if (choice.getChoice().equals("Blue")) { - player.getManaPool().addMana(Mana.BlueMana, game, source); - } else if (choice.getChoice().equals("Red")) { - player.getManaPool().addMana(Mana.RedMana, game, source); - } else if (choice.getChoice().equals("Green")) { - player.getManaPool().addMana(Mana.GreenMana, game, source); - } else if (choice.getChoice().equals("White")) { - player.getManaPool().addMana(Mana.WhiteMana, game, source); - } else if (choice.getChoice().equals("Colorless")) { - player.getManaPool().addMana(Mana.ColorlessMana, game, source); - } + if (choice.getChoice().equals("Black")) { + player.getManaPool().addMana(Mana.BlackMana, game, source); + } else if (choice.getChoice().equals("Blue")) { + player.getManaPool().addMana(Mana.BlueMana, game, source); + } else if (choice.getChoice().equals("Red")) { + player.getManaPool().addMana(Mana.RedMana, game, source); + } else if (choice.getChoice().equals("Green")) { + player.getManaPool().addMana(Mana.GreenMana, game, source); + } else if (choice.getChoice().equals("White")) { + player.getManaPool().addMana(Mana.WhiteMana, game, source); + } else if (choice.getChoice().equals("Colorless")) { + player.getManaPool().addMana(Mana.ColorlessMana, game, source); } } return true;