[ALL] reworked Gustha's Scepter

This commit is contained in:
Evan Kranzler 2022-02-25 07:20:40 -05:00
parent 1c107cde01
commit 614e11bf3e

View file

@ -1,37 +1,31 @@
package mage.cards.g;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetCard;
import mage.target.common.TargetCardInExile;
import mage.target.common.TargetCardInHand;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author LevelX2, jeffwadsworth & L_J
* @author LevelX2, jeffwadsworth, L_J & TheElk801
*/
public final class GusthasScepter extends CardImpl {
@ -39,16 +33,13 @@ public final class GusthasScepter extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{0}");
// {T}: Exile a card from your hand face down. You may look at it for as long as it remains exiled.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GusthasScepterExileEffect(), new TapSourceCost()));
this.addAbility(new SimpleActivatedAbility(new GusthasScepterExileEffect(), new TapSourceCost()));
// {T}: Return a card you own exiled with Gusthas Scepter to your hand.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ReturnToHandTargetEffect(), new TapSourceCost());
ability.addTarget(new TargetCardInGusthasScepterExile(this.getId()));
this.addAbility(ability);
this.addAbility(new SimpleActivatedAbility(new GusthasScepterReturnEffect(), new TapSourceCost()));
// When you lose control of Gusthas Scepter, put all cards exiled with Gusthas Scepter into their owners graveyard.
this.addAbility(new GusthasScepterLoseControlAbility());
}
private GusthasScepter(final GusthasScepter card) {
@ -65,7 +56,7 @@ class GusthasScepterExileEffect extends OneShotEffect {
public GusthasScepterExileEffect() {
super(Outcome.DrawCard);
staticText = "Exile a card from your hand face down. You may look at it for as long as it remains exiled";
staticText = "exile a card from your hand face down. You may look at it for as long as it remains exiled";
}
public GusthasScepterExileEffect(final GusthasScepterExileEffect effect) {
@ -75,25 +66,23 @@ class GusthasScepterExileEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetCardInHand(new FilterCard("card to exile"));
if (controller.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId());
if (card != null && sourceObject != null) {
UUID exileId = source.getSourceId();
if (card.moveToExile(exileId,
sourceObject.getIdName(),
source,
game)) {
card.setFaceDown(true, game);
game.addEffect(new GusthasScepterLookAtCardEffect(card.getId()), source);
return true;
}
}
}
if (controller == null || controller.getHand().isEmpty()) {
return false;
}
return false;
TargetCard target = new TargetCardInHand();
controller.chooseTarget(outcome, controller.getHand(), target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
controller.moveCardsToExile(
card, source, game, false,
CardUtil.getExileZoneId(game, source),
CardUtil.getSourceName(game, source)
);
card.setFaceDown(true, game);
game.addEffect(new GusthasScepterLookAtCardEffect(card, game), source);
return true;
}
@Override
@ -102,81 +91,54 @@ class GusthasScepterExileEffect extends OneShotEffect {
}
}
class TargetCardInGusthasScepterExile extends TargetCardInExile {
class GusthasScepterReturnEffect extends OneShotEffect {
public TargetCardInGusthasScepterExile(UUID cardId) {
super(1, 1, new FilterCard("card exiled with Gustha's Scepter"), null);
private static final FilterCard filter = new FilterCard("card you own exiled with this permanent");
GusthasScepterReturnEffect() {
super(Outcome.Benefit);
staticText = "return a card you own exiled with {this} to your hand";
}
public TargetCardInGusthasScepterExile(final TargetCardInGusthasScepterExile target) {
super(target);
private GusthasScepterReturnEffect(final GusthasScepterReturnEffect effect) {
super(effect);
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = new HashSet<>();
Card sourceCard = game.getCard(sourceId);
if (sourceCard != null) {
UUID exileId = sourceId;
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null && !exile.isEmpty()) {
possibleTargets.addAll(exile);
}
public GusthasScepterReturnEffect copy() {
return new GusthasScepterReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
return possibleTargets;
}
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
Card sourceCard = game.getCard(sourceId);
if (sourceCard != null) {
UUID exileId = sourceId;
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null && !exile.isEmpty()) {
return true;
}
TargetCard target = new TargetCardInExile(filter, CardUtil.getExileZoneId(game, source));
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
return false;
}
return false;
}
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
Card card = game.getCard(id);
if (card != null
&& game.getState().getZone(card.getId()) == Zone.EXILED) {
ExileZone exile = null;
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
UUID exileId = source.getSourceId();
exile = game.getExile().getExileZone(exileId);
}
if (exile != null
&& exile.contains(id)) {
return filter.match(card, source.getControllerId(), game);
}
}
return false;
}
@Override
public TargetCardInGusthasScepterExile copy() {
return new TargetCardInGusthasScepterExile(this);
player.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
return card != null && player.moveCards(card, Zone.HAND, source, game);
}
}
class GusthasScepterLookAtCardEffect extends AsThoughEffectImpl {
private final UUID cardId;
private final MageObjectReference mor;
public GusthasScepterLookAtCardEffect(UUID cardId) {
public GusthasScepterLookAtCardEffect(Card card, Game game) {
super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit);
this.cardId = cardId;
this.mor = new MageObjectReference(card, game);
staticText = "You may look at it for as long as it remains exiled";
}
public GusthasScepterLookAtCardEffect(final GusthasScepterLookAtCardEffect effect) {
super(effect);
this.cardId = effect.cardId;
this.mor = effect.mor;
}
@Override
@ -191,26 +153,16 @@ class GusthasScepterLookAtCardEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (objectId.equals(cardId) && affectedControllerId.equals(source.getControllerId())) {
MageObject sourceObject = source.getSourceObject(game);
if (sourceObject != null) {
UUID exileId = source.getSourceId();
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null
&& exileZone.contains(cardId)) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(cardId);
if (controller != null
&& card != null
&& game.getState().getZone(cardId) == Zone.EXILED) {
return true;
}
} else {
discard();
}
}
if (!mor.zoneCounterIsCurrent(game)) {
discard();
return false;
}
return false;
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
if (exileZone == null || !exileZone.contains(mor.getSourceId())) {
discard();
return false;
}
return mor.refersTo(objectId, game) && source.isControlledBy(affectedControllerId);
}
}
@ -236,14 +188,12 @@ class GusthasScepterLoseControlAbility extends DelayedTriggeredAbility {
}
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.LOST_CONTROL) {
return event.getPlayerId().equals(controllerId)
&& event.getTargetId().equals(this.getSourceId());
} else if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
if (event.getTargetId().equals(this.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
return (zEvent.getFromZone() == Zone.BATTLEFIELD);
}
switch (event.getType()) {
case LOST_CONTROL:
return event.getPlayerId().equals(controllerId)
&& event.getTargetId().equals(this.getSourceId());
case ZONE_CHANGE:
return event.getTargetId().equals(this.getSourceId()) && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD;
}
return false;
}
@ -258,7 +208,6 @@ class GusthasScepterPutExiledCardsInOwnersGraveyard extends OneShotEffect {
public GusthasScepterPutExiledCardsInOwnersGraveyard() {
super(Outcome.Neutral);
staticText = " put all cards exiled with {this} into their owner's graveyard";
}
public GusthasScepterPutExiledCardsInOwnersGraveyard(final GusthasScepterPutExiledCardsInOwnersGraveyard effect) {
@ -268,14 +217,11 @@ class GusthasScepterPutExiledCardsInOwnersGraveyard extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
UUID exileId = source.getSourceId();
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null) {
return controller.moveCards(exileZone.getCards(game), Zone.GRAVEYARD, source, game);
}
if (controller == null) {
return false;
}
return false;
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return exileZone != null && controller.moveCards(exileZone.getCards(game), Zone.GRAVEYARD, source, game);
}
@Override