From 596bee33c28deb663890dfd4b1171d90c9ccea58 Mon Sep 17 00:00:00 2001 From: LoneFox Date: Wed, 24 Jun 2015 19:56:22 +0300 Subject: [PATCH] Use ShuffleIntoLibrarySourceEffect instead of custom effect implementation for Blitz Hellion and Lightning Shrieker. This also fixes a bug where controller's library was shuffled instead of owner's. --- .../mage/sets/alarareborn/BlitzHellion.java | 46 +++---------------- .../sets/fatereforged/LightningShrieker.java | 46 +++---------------- 2 files changed, 13 insertions(+), 79 deletions(-) diff --git a/Mage.Sets/src/mage/sets/alarareborn/BlitzHellion.java b/Mage.Sets/src/mage/sets/alarareborn/BlitzHellion.java index d9a9cf556a..ead81b9ff4 100644 --- a/Mage.Sets/src/mage/sets/alarareborn/BlitzHellion.java +++ b/Mage.Sets/src/mage/sets/alarareborn/BlitzHellion.java @@ -29,17 +29,15 @@ package mage.sets.alarareborn; import java.util.UUID; -import mage.constants.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.keyword.TrampleAbility; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; +import mage.constants.*; /** * @@ -64,7 +62,9 @@ public class BlitzHellion extends CardImpl { this.addAbility(HasteAbility.getInstance()); // At the beginning of the end step, Blitz Hellion's owner shuffles it into his or her library. - this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ShuffleSourceEffect(), TargetController.ANY, null, false)); + Effect effect = new ShuffleIntoLibrarySourceEffect(); + effect.setText("{this}'s owner shuffles it into his or her library."); + this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, null, false)); } public BlitzHellion(final BlitzHellion card) { @@ -76,35 +76,3 @@ public class BlitzHellion extends CardImpl { return new BlitzHellion(this); } } - -class ShuffleSourceEffect extends OneShotEffect { - - ShuffleSourceEffect() { - super(Outcome.Neutral); - staticText = "{this}'s owner shuffles it into his or her library"; - } - - ShuffleSourceEffect(final ShuffleSourceEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { - return false; - } - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - permanent.moveToZone(Zone.LIBRARY, id, game, false); - player.shuffleLibrary(game); - return true; - } - return false; - } - - @Override - public ShuffleSourceEffect copy() { - return new ShuffleSourceEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/fatereforged/LightningShrieker.java b/Mage.Sets/src/mage/sets/fatereforged/LightningShrieker.java index 44d856d69f..22a7fa3ed7 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/LightningShrieker.java +++ b/Mage.Sets/src/mage/sets/fatereforged/LightningShrieker.java @@ -29,21 +29,17 @@ package mage.sets.fatereforged; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ShuffleIntoLibrarySourceEffect; import mage.abilities.keyword.FlyingAbility; -import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; 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.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; /** * @@ -65,7 +61,9 @@ public class LightningShrieker extends CardImpl { // Haste this.addAbility(HasteAbility.getInstance()); // At the beginning of the end step, Lightning Shrieker's owner shuffles it into his or her library. - this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ShuffleSourceEffect(), TargetController.ANY, null, false)); + Effect effect = new ShuffleIntoLibrarySourceEffect(); + effect.setText("{this}'s owner shuffles it into his or her library."); + this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY, null, false)); } public LightningShrieker(final LightningShrieker card) { @@ -77,35 +75,3 @@ public class LightningShrieker extends CardImpl { return new LightningShrieker(this); } } - -class ShuffleSourceEffect extends OneShotEffect { - - ShuffleSourceEffect() { - super(Outcome.Neutral); - staticText = "{this}'s owner shuffles it into his or her library"; - } - - ShuffleSourceEffect(final ShuffleSourceEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player == null) { - return false; - } - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - permanent.moveToZone(Zone.LIBRARY, id, game, false); - player.shuffleLibrary(game); - return true; - } - return false; - } - - @Override - public ShuffleSourceEffect copy() { - return new ShuffleSourceEffect(this); - } -} \ No newline at end of file