mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Refactored Belltower Sphinx implementation.
This commit is contained in:
parent
8d673217e7
commit
4a3dfed92f
2 changed files with 12 additions and 18 deletions
|
@ -31,19 +31,15 @@ import mage.Constants;
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.Rarity;
|
import mage.Constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
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.PutLibraryIntoGraveTargetEffect;
|
||||||
import mage.abilities.effects.common.ReturnToHandTargetEffect;
|
|
||||||
import mage.abilities.keyword.FlyingAbility;
|
import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.Card;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -79,7 +75,7 @@ public class BelltowerSphinx extends CardImpl<BelltowerSphinx> {
|
||||||
class BelltowerSphinxEffect extends TriggeredAbilityImpl<BelltowerSphinxEffect> {
|
class BelltowerSphinxEffect extends TriggeredAbilityImpl<BelltowerSphinxEffect> {
|
||||||
|
|
||||||
public BelltowerSphinxEffect() {
|
public BelltowerSphinxEffect() {
|
||||||
super(Constants.Zone.BATTLEFIELD, null);
|
super(Constants.Zone.BATTLEFIELD, new PutLibraryIntoGraveTargetEffect(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public BelltowerSphinxEffect(BelltowerSphinxEffect effect) {
|
public BelltowerSphinxEffect(BelltowerSphinxEffect effect) {
|
||||||
|
@ -94,18 +90,12 @@ class BelltowerSphinxEffect extends TriggeredAbilityImpl<BelltowerSphinxEffect>
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(this.sourceId)) {
|
if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(this.sourceId)) {
|
||||||
MageObject object = game.getObject(event.getSourceId());
|
UUID controller = game.getControllerId(event.getSourceId());
|
||||||
if (object != null && object instanceof Card) {
|
if (controller != null) {
|
||||||
Player player = game.getPlayer(((Card)object).getOwnerId());
|
Player player = game.getPlayer(controller);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
int cardsCount = Math.min(event.getAmount(), player.getLibrary().size());
|
getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
|
||||||
for (int i = 0; i < cardsCount; i++) {
|
((PutLibraryIntoGraveTargetEffect) getEffects().get(0)).setAmount(new StaticValue(event.getAmount()));
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
|
||||||
if (card != null)
|
|
||||||
card.moveToZone(Constants.Zone.GRAVEYARD, this.id, game, false);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,10 @@ public class PutLibraryIntoGraveTargetEffect extends OneShotEffect<PutLibraryInt
|
||||||
this.amount = effect.amount.clone();
|
this.amount = effect.amount.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAmount(DynamicValue value) {
|
||||||
|
this.amount = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PutLibraryIntoGraveTargetEffect copy() {
|
public PutLibraryIntoGraveTargetEffect copy() {
|
||||||
return new PutLibraryIntoGraveTargetEffect(this);
|
return new PutLibraryIntoGraveTargetEffect(this);
|
||||||
|
|
Loading…
Reference in a new issue