From 4a3dfed92f906f42794ca1c455b71f724cb953a5 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Fri, 12 Aug 2011 08:51:35 +0400 Subject: [PATCH] Refactored Belltower Sphinx implementation. --- .../mage/sets/ravnika/BelltowerSphinx.java | 26 ++++++------------- .../PutLibraryIntoGraveTargetEffect.java | 4 +++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Mage.Sets/src/mage/sets/ravnika/BelltowerSphinx.java b/Mage.Sets/src/mage/sets/ravnika/BelltowerSphinx.java index 75e46dad8b..0d6dfe620d 100644 --- a/Mage.Sets/src/mage/sets/ravnika/BelltowerSphinx.java +++ b/Mage.Sets/src/mage/sets/ravnika/BelltowerSphinx.java @@ -31,19 +31,15 @@ import mage.Constants; import mage.Constants.CardType; import mage.Constants.Rarity; import mage.MageInt; -import mage.MageObject; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.common.PutLibraryIntoGraveTargetEffect; -import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.abilities.keyword.FlyingAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; import java.util.UUID; @@ -79,7 +75,7 @@ public class BelltowerSphinx extends CardImpl { class BelltowerSphinxEffect extends TriggeredAbilityImpl { public BelltowerSphinxEffect() { - super(Constants.Zone.BATTLEFIELD, null); + super(Constants.Zone.BATTLEFIELD, new PutLibraryIntoGraveTargetEffect(0)); } public BelltowerSphinxEffect(BelltowerSphinxEffect effect) { @@ -94,18 +90,12 @@ class BelltowerSphinxEffect extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(this.sourceId)) { - MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Card) { - Player player = game.getPlayer(((Card)object).getOwnerId()); + UUID controller = game.getControllerId(event.getSourceId()); + if (controller != null) { + Player player = game.getPlayer(controller); if (player != null) { - int cardsCount = Math.min(event.getAmount(), player.getLibrary().size()); - for (int i = 0; i < cardsCount; i++) { - Card card = player.getLibrary().removeFromTop(game); - if (card != null) - card.moveToZone(Constants.Zone.GRAVEYARD, this.id, game, false); - else - break; - } + getEffects().get(0).setTargetPointer(new FixedTarget(player.getId())); + ((PutLibraryIntoGraveTargetEffect) getEffects().get(0)).setAmount(new StaticValue(event.getAmount())); return true; } } diff --git a/Mage/src/mage/abilities/effects/common/PutLibraryIntoGraveTargetEffect.java b/Mage/src/mage/abilities/effects/common/PutLibraryIntoGraveTargetEffect.java index ba5da20f09..2688d52133 100644 --- a/Mage/src/mage/abilities/effects/common/PutLibraryIntoGraveTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/PutLibraryIntoGraveTargetEffect.java @@ -61,6 +61,10 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect