From 8206e294930de4defc2d65fcc9b8082afc0542d0 Mon Sep 17 00:00:00 2001 From: JOAC69 Date: Sat, 24 Sep 2016 18:19:10 -0500 Subject: [PATCH] Refactor - SkywardEyeProphetsEffect is shared so moved to new RevealTopLandToBattlefieldElseHandEffect --- .../mage/sets/conflux/SkywardEyeProphets.java | 52 +----------------- .../mage/sets/dissension/CoilingOracle.java | 4 +- ...ealTopLandToBattlefieldElseHandEffect.java | 53 +++++++++++++++++++ 3 files changed, 57 insertions(+), 52 deletions(-) create mode 100644 Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java diff --git a/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java b/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java index 8b5697c408..56e6bc9e84 100644 --- a/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java +++ b/Mage.Sets/src/mage/sets/conflux/SkywardEyeProphets.java @@ -29,21 +29,14 @@ package mage.sets.conflux; import java.util.UUID; import mage.MageInt; -import mage.MageObject; -import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.RevealTopLandToBattlefieldElseHandEffect; import mage.abilities.keyword.VigilanceAbility; -import mage.cards.Card; import mage.cards.CardImpl; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; /** * @author North @@ -62,7 +55,7 @@ public class SkywardEyeProphets extends CardImpl { // Vigilance this.addAbility(VigilanceAbility.getInstance()); // {tap}: Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand. - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new SkywardEyeProphetsEffect(), new TapSourceCost())); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealTopLandToBattlefieldElseHandEffect(), new TapSourceCost())); } public SkywardEyeProphets(final SkywardEyeProphets card) { @@ -73,45 +66,4 @@ public class SkywardEyeProphets extends CardImpl { public SkywardEyeProphets copy() { return new SkywardEyeProphets(this); } - - public static class SkywardEyeProphetsEffect extends OneShotEffect { - - public SkywardEyeProphetsEffect() { - super(Outcome.DrawCard); - this.staticText = "Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand"; - } - - public SkywardEyeProphetsEffect(final SkywardEyeProphetsEffect effect) { - super(effect); - } - - @Override - public SkywardEyeProphetsEffect copy() { - return new SkywardEyeProphetsEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - MageObject sourceObject = game.getObject(source.getSourceId()); - if (sourceObject == null || controller == null) { - return false; - } - if (controller.getLibrary().size() > 0) { - CardsImpl cards = new CardsImpl(); - Card card = controller.getLibrary().getFromTop(game); - if (card == null) { - return false; - } - cards.add(card); - controller.revealCards(sourceObject.getName(), cards, game); - if (card.getCardType().contains(CardType.LAND)) { - return controller.moveCards(card, Zone.BATTLEFIELD, source, game); - } else { - controller.moveCards(card, Zone.HAND, source, game); - } - } - return true; - } - } } diff --git a/Mage.Sets/src/mage/sets/dissension/CoilingOracle.java b/Mage.Sets/src/mage/sets/dissension/CoilingOracle.java index eacd381955..195d0f22bf 100644 --- a/Mage.Sets/src/mage/sets/dissension/CoilingOracle.java +++ b/Mage.Sets/src/mage/sets/dissension/CoilingOracle.java @@ -30,10 +30,10 @@ package mage.sets.dissension; import java.util.UUID; import mage.MageInt; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.common.RevealTopLandToBattlefieldElseHandEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; -import mage.sets.conflux.SkywardEyeProphets.SkywardEyeProphetsEffect; /** * @author mluds @@ -51,7 +51,7 @@ public class CoilingOracle extends CardImpl { this.toughness = new MageInt(1); // When Coiling Oracle enters the battlefield, reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put that card into your hand. - this.addAbility(new EntersBattlefieldTriggeredAbility(new SkywardEyeProphetsEffect())); + this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealTopLandToBattlefieldElseHandEffect())); } public CoilingOracle(final CoilingOracle card) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java new file mode 100644 index 0000000000..a3cfd54854 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/RevealTopLandToBattlefieldElseHandEffect.java @@ -0,0 +1,53 @@ +package mage.abilities.effects.common; + +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +public class RevealTopLandToBattlefieldElseHandEffect extends OneShotEffect { + + public RevealTopLandToBattlefieldElseHandEffect() { + super(Outcome.DrawCard); + this.staticText = "Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand"; + } + + public RevealTopLandToBattlefieldElseHandEffect(final RevealTopLandToBattlefieldElseHandEffect effect) { + super(effect); + } + + @Override + public RevealTopLandToBattlefieldElseHandEffect copy() { + return new RevealTopLandToBattlefieldElseHandEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (sourceObject == null || controller == null) { + return false; + } + if (controller.getLibrary().size() > 0) { + CardsImpl cards = new CardsImpl(); + Card card = controller.getLibrary().getFromTop(game); + if (card == null) { + return false; + } + cards.add(card); + controller.revealCards(sourceObject.getName(), cards, game); + if (card.getCardType().contains(CardType.LAND)) { + return controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } else { + controller.moveCards(card, Zone.HAND, source, game); + } + } + return true; + } +}