refactored card.moveToExile usages E-F

This commit is contained in:
Evan Kranzler 2021-02-28 17:09:37 -05:00
parent 4a09654743
commit 9567b19b01
12 changed files with 235 additions and 283 deletions

View file

@ -1,6 +1,5 @@
package mage.cards.e; package mage.cards.e;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -16,10 +15,12 @@ import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class EaterOfTheDead extends CardImpl { public final class EaterOfTheDead extends CardImpl {
@ -31,7 +32,7 @@ public final class EaterOfTheDead extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// {0}: If Eater of the Dead is tapped, exile target creature card from a graveyard and untap Eater of the Dead. // {0}: If Eater of the Dead is tapped, exile target creature card from a graveyard and untap Eater of the Dead.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new EaterOfTheDeadEffect(), new GenericManaCost(0)); Ability ability = new SimpleActivatedAbility(new EaterOfTheDeadEffect(), new GenericManaCost(0));
ability.addTarget(new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE)); ability.addTarget(new TargetCardInGraveyard(StaticFilters.FILTER_CARD_CREATURE));
this.addAbility(ability); this.addAbility(ability);
} }
@ -49,28 +50,31 @@ public final class EaterOfTheDead extends CardImpl {
class EaterOfTheDeadEffect extends OneShotEffect { class EaterOfTheDeadEffect extends OneShotEffect {
EaterOfTheDeadEffect() { EaterOfTheDeadEffect() {
super(Outcome.DestroyPermanent); super(Outcome.Exile);
staticText = "If {this} is tapped, exile target creature card from a graveyard and untap {this}"; staticText = "If {this} is tapped, exile target creature card from a graveyard and untap {this}";
} }
EaterOfTheDeadEffect(final EaterOfTheDeadEffect effect) { private EaterOfTheDeadEffect(final EaterOfTheDeadEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget()); Permanent permanent = source.getSourcePermanentOrLKI(game);
if (sourcePermanent != null && sourcePermanent.isTapped() && card != null) { if (player == null || permanent == null || !permanent.isTapped()) {
card.moveToExile(null, "Eater of the Dead", source, game); return false;
sourcePermanent.untap(game);
} }
return false; Card card = game.getCard(source.getFirstTarget());
if (card != null) {
player.moveCards(card, Zone.EXILED, source, game);
}
permanent.untap(game);
return true;
} }
@Override @Override
public EaterOfTheDeadEffect copy() { public EaterOfTheDeadEffect copy() {
return new EaterOfTheDeadEffect(this); return new EaterOfTheDeadEffect(this);
} }
} }

View file

@ -1,4 +1,3 @@
package mage.cards.e; package mage.cards.e;
import java.util.UUID; import java.util.UUID;
@ -7,6 +6,7 @@ import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl; import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.ExileSourceFromHandCost;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -44,40 +44,3 @@ public final class ElvishSpiritGuide extends CardImpl {
return new ElvishSpiritGuide(this); return new ElvishSpiritGuide(this);
} }
} }
class ExileSourceFromHandCost extends CostImpl {
public ExileSourceFromHandCost() {
this.text = "Exile {this} from your hand";
}
public ExileSourceFromHandCost(ExileSourceFromHandCost cost) {
super(cost);
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Card card = game.getCard(source.getSourceId());
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(source.getSourceId()) && card != null) {
paid = card.moveToExile(ability.getSourceId(), "from Hand", source, game);
}
return paid;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(source.getSourceId())) {
return true;
}
return false;
}
@Override
public ExileSourceFromHandCost copy() {
return new ExileSourceFromHandCost(this);
}
}

View file

@ -1,40 +1,36 @@
package mage.cards.e; package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.SearchEffect; import mage.cards.*;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterLandCard;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInExile;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.Objects;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class EndlessHorizons extends CardImpl { public final class EndlessHorizons extends CardImpl {
public EndlessHorizons(UUID ownerId, CardSetInfo setInfo) { public EndlessHorizons(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{W}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
// When Endless Horizons enters the battlefield, search your library for any number of Plains cards and exile them. Then shuffle your library. // When Endless Horizons enters the battlefield, search your library for any number of Plains cards and exile them. Then shuffle your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EndlessHorizonsEffect(), false)); this.addAbility(new EntersBattlefieldTriggeredAbility(new EndlessHorizonsEffect(), false));
// At the beginning of your upkeep, you may put a card you own exiled with Endless Horizons into your hand. // At the beginning of your upkeep, you may put a card you own exiled with Endless Horizons into your hand.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new EndlessHorizonsEffect2(), TargetController.YOU, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new EndlessHorizonsEffect2(), TargetController.YOU, false));
} }
private EndlessHorizons(final EndlessHorizons card) { private EndlessHorizons(final EndlessHorizons card) {
@ -47,20 +43,20 @@ public final class EndlessHorizons extends CardImpl {
} }
} }
class EndlessHorizonsEffect extends SearchEffect { class EndlessHorizonsEffect extends OneShotEffect {
private static final FilterLandCard filter = new FilterLandCard("Plains card"); private static final FilterCard filter = new FilterCard("Plains card");
static { static {
filter.add(SubType.PLAINS.getPredicate()); filter.add(SubType.PLAINS.getPredicate());
} }
public EndlessHorizonsEffect() { EndlessHorizonsEffect() {
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, filter), Outcome.Neutral); super(Outcome.Neutral);
this.staticText = "search your library for any number of Plains cards and exile them. Then shuffle your library"; this.staticText = "search your library for any number of Plains cards and exile them. Then shuffle your library";
} }
public EndlessHorizonsEffect(final EndlessHorizonsEffect effect) { private EndlessHorizonsEffect(final EndlessHorizonsEffect effect) {
super(effect); super(effect);
} }
@ -71,35 +67,39 @@ class EndlessHorizonsEffect extends SearchEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (you != null) { Permanent permanent = source.getSourcePermanentOrLKI(game);
if (you.searchLibrary(target, source, game)) { if (permanent == null || player == null) {
UUID exileZone = CardUtil.getCardExileZoneId(game, source); return false;
if (!target.getTargets().isEmpty()) {
for (UUID cardId : target.getTargets()) {
Card card = you.getLibrary().getCard(cardId, game);
if (card != null) {
card.moveToExile(exileZone, "Endless Horizons", source, game);
}
}
}
}
you.shuffleLibrary(source, game);
return true;
} }
return false; TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter);
player.searchLibrary(target, source, game);
Cards cards = new CardsImpl();
target.getTargets()
.stream()
.map(uuid -> player.getLibrary().getCard(uuid, game))
.filter(Objects::nonNull)
.forEach(cards::add);
player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), permanent.getIdName());
player.shuffleLibrary(source, game);
return true;
} }
} }
class EndlessHorizonsEffect2 extends OneShotEffect { class EndlessHorizonsEffect2 extends OneShotEffect {
public EndlessHorizonsEffect2() { private static final FilterCard filter = new FilterCard();
static {
filter.add(TargetController.YOU.getOwnerPredicate());
}
EndlessHorizonsEffect2() {
super(Outcome.ReturnToHand); super(Outcome.ReturnToHand);
this.staticText = "you may put a card you own exiled with {this} into your hand"; this.staticText = "you may put a card you own exiled with {this} into your hand";
} }
public EndlessHorizonsEffect2(final EndlessHorizonsEffect2 effect) { private EndlessHorizonsEffect2(final EndlessHorizonsEffect2 effect) {
super(effect); super(effect);
} }
@ -111,22 +111,15 @@ class EndlessHorizonsEffect2 extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
ExileZone exZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); return false;
if (exZone != null) {
Card card = null;
if (exZone.size() > 1) {
TargetCard target = new TargetCard(Zone.EXILED, new FilterCard());
controller.choose(outcome, exZone, target, game);
card = game.getCard(target.getFirstTarget());
} else {
card = exZone.getRandom(game);
}
controller.moveCards(card, Zone.HAND, source, game);
}
return true;
} }
return false; TargetCard target = new TargetCardInExile(
0, 1, filter, CardUtil.getExileZoneId(game, source)
);
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
return card != null && controller.moveCards(card, Zone.HAND, source, game);
} }
} }

View file

@ -1,24 +1,24 @@
package mage.cards.e; package mage.cards.e;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect; import mage.abilities.effects.common.ReturnToBattlefieldUnderYourControlTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
*
* @author Styxo * @author Styxo
*/ */
public final class EscapePod extends CardImpl { public final class EscapePod extends CardImpl {
@ -29,7 +29,6 @@ public final class EscapePod extends CardImpl {
// Exile target creature you control. Return that card to the battlefield under your control at the beginning of the next end step. // Exile target creature you control. Return that card to the battlefield under your control at the beginning of the next end step.
this.getSpellAbility().addEffect(new EscapePodEffect()); this.getSpellAbility().addEffect(new EscapePodEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
} }
private EscapePod(final EscapePod card) { private EscapePod(final EscapePod card) {
@ -44,34 +43,35 @@ public final class EscapePod extends CardImpl {
class EscapePodEffect extends OneShotEffect { class EscapePodEffect extends OneShotEffect {
public EscapePodEffect() { EscapePodEffect() {
super(Outcome.Detriment); super(Outcome.Detriment);
staticText = "Exile target creature you control. Return that card to the battlefield under your control at the beginning of the next end step"; staticText = "Exile target creature you control. Return that card to the battlefield " +
"under your control at the beginning of the next end step";
} }
public EscapePodEffect(final EscapePodEffect effect) { private EscapePodEffect(final EscapePodEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId()); if (player == null || permanent == null) {
if (permanent != null && sourceObject != null) { return false;
if (permanent.moveToExile(source.getSourceId(), sourceObject.getIdName(), source, game)) {
Effect effect = new ReturnToBattlefieldUnderYourControlTargetEffect();
effect.setText("Return that card to the battlefield under your control at the beginning of the next end step");
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
} }
return false; Card card = permanent.getMainCard();
player.moveCards(permanent, Zone.EXILED, source, game);
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
new ReturnToBattlefieldUnderYourControlTargetEffect().setText(
"Return that card to the battlefield under your control at the beginning of the next end step"
).setTargetPointer(new FixedTarget(card, game))
), source);
return true;
} }
@Override @Override
public EscapePodEffect copy() { public EscapePodEffect copy() {
return new EscapePodEffect(this); return new EscapePodEffect(this);
} }
} }

View file

@ -1,5 +1,6 @@
package mage.cards.f; package mage.cards.f;
import mage.ApprovingObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -13,7 +14,6 @@ import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
@ -24,7 +24,6 @@ import mage.target.targetpointer.FixedTarget;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import mage.ApprovingObject;
/** /**
* @author JayDi85 * @author JayDi85
@ -192,8 +191,7 @@ class FinaleOfPromiseReplacementEffect extends ReplacementEffectImpl {
if (controller != null) { if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source)); Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) { if (card != null) {
card.moveToExile(null, "", source, game); return controller.moveCards(card, Zone.EXILED, source, game);
return true;
} }
} }
return false; return false;

View file

@ -39,7 +39,6 @@ public final class FleshBlood extends SplitCard {
getRightHalfCard().getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); getRightHalfCard().getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
getRightHalfCard().getSpellAbility().addTarget(new TargetAnyTarget()); getRightHalfCard().getSpellAbility().addTarget(new TargetAnyTarget());
getRightHalfCard().getSpellAbility().addEffect(new BloodEffect()); getRightHalfCard().getSpellAbility().addEffect(new BloodEffect());
} }
private FleshBlood(final FleshBlood card) { private FleshBlood(final FleshBlood card) {
@ -65,19 +64,20 @@ class FleshEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card targetCard = game.getCard(source.getFirstTarget()); Card targetCard = game.getCard(source.getFirstTarget());
if (targetCard != null) { if (player == null || targetCard == null) {
int power = targetCard.getPower().getValue(); return false;
targetCard.moveToExile(null, null, source, game);
if (power > 0) {
Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetCreature != null) {
targetCreature.addCounters(CounterType.P1P1.createInstance(power), source.getControllerId(), source, game);
}
}
return true;
} }
return false; int power = targetCard.getPower().getValue();
player.moveCards(targetCard, Zone.EXILED, source, game);
if (power > 0) {
Permanent targetCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (targetCreature != null) {
targetCreature.addCounters(CounterType.P1P1.createInstance(power), source.getControllerId(), source, game);
}
}
return true;
} }
@Override @Override

View file

@ -1,25 +1,22 @@
package mage.cards.f; package mage.cards.f;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.SearchEffect; import mage.abilities.effects.SearchEffect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.Card; import mage.cards.*;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class Foresight extends CardImpl { public final class Foresight extends CardImpl {
@ -47,11 +44,11 @@ public final class Foresight extends CardImpl {
class ForesightEffect extends SearchEffect { class ForesightEffect extends SearchEffect {
ForesightEffect() { ForesightEffect() {
super(new TargetCardInLibrary(3, new FilterCard()), Outcome.Benefit); super(new TargetCardInLibrary(3, StaticFilters.FILTER_CARD), Outcome.Benefit);
staticText = "Search your library for three cards, exile them, then shuffle your library"; staticText = "Search your library for three cards, exile them, then shuffle your library";
} }
ForesightEffect(final ForesightEffect effect) { private ForesightEffect(final ForesightEffect effect) {
super(effect); super(effect);
} }
@ -63,21 +60,19 @@ class ForesightEffect extends SearchEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null && player.searchLibrary(target, source, game)) { if (player == null) {
for (UUID targetId : getTargets()) { return false;
Card card = player.getLibrary().getCard(targetId, game);
if (card != null) {
card.moveToExile(null, null, source, game);
}
}
player.shuffleLibrary(source, game);
return true;
} }
return false; player.searchLibrary(target, source, game);
Cards cards = new CardsImpl();
for (UUID targetId : target.getTargets()) {
Card card = player.getLibrary().getCard(targetId, game);
if (card != null) {
cards.add(card);
}
}
player.moveCards(cards, Zone.EXILED, source, game);
player.shuffleLibrary(source, game);
return true;
} }
public List<UUID> getTargets() {
return target.getTargets();
}
} }

View file

@ -1,7 +1,5 @@
package mage.cards.f; package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.abilities.effects.common.CreateTokenCopyTargetEffect;
@ -9,13 +7,16 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetNonlandPermanent; import mage.target.common.TargetNonlandPermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
*
* @author spjspj * @author spjspj
*/ */
public final class FracturedIdentity extends CardImpl { public final class FracturedIdentity extends CardImpl {
@ -40,12 +41,12 @@ public final class FracturedIdentity extends CardImpl {
class FracturedIdentityEffect extends OneShotEffect { class FracturedIdentityEffect extends OneShotEffect {
public FracturedIdentityEffect() { FracturedIdentityEffect() {
super(Outcome.Exile); super(Outcome.Exile);
this.staticText = "Exile target nonland permanent. Each player other than its controller creates a token that's a copy of it"; this.staticText = "Exile target nonland permanent. Each player other than its controller creates a token that's a copy of it";
} }
public FracturedIdentityEffect(final FracturedIdentityEffect effect) { private FracturedIdentityEffect(final FracturedIdentityEffect effect) {
super(effect); super(effect);
} }
@ -56,17 +57,19 @@ class FracturedIdentityEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) { if (player == null || permanent == null) {
return false; return false;
} }
player.moveCards(permanent, Zone.EXILED, source, game);
permanent.moveToExile(null, null, source, game); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
UUID controllerId = permanent.getControllerId(); if (permanent.isControlledBy(playerId)) {
for (UUID opponentId : game.getOpponents(controllerId)) { continue;
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(opponentId, null, false); }
effect.setTargetPointer(new FixedTarget(permanent, game)); new CreateTokenCopyTargetEffect(
effect.apply(game, source); playerId, null, false
).setTargetPointer(new FixedTarget(permanent, game)).apply(game, source);
} }
return true; return true;
} }

View file

@ -1,14 +1,10 @@
package mage.cards.f; package mage.cards.f;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility; import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards; import mage.cards.Cards;
@ -17,26 +13,28 @@ import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.StaticFilters;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
*
* @author L_J * @author L_J
*/ */
public final class FreeForAll extends CardImpl { public final class FreeForAll extends CardImpl {
public FreeForAll(UUID ownerId, CardSetInfo setInfo) { public FreeForAll(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}");
// When Free-for-All enters the battlefield, exile all creatures face down. // When Free-for-All enters the battlefield, exile all creatures face down.
this.addAbility(new EntersBattlefieldTriggeredAbility(new FreeForAllExileAllEffect())); this.addAbility(new EntersBattlefieldTriggeredAbility(new FreeForAllExileAllEffect()));
// At the beginning of each player's upkeep, that player chooses a card exiled with Free-for-All at random and puts it onto the battlefield. // At the beginning of each player's upkeep, that player chooses a card exiled with Free-for-All at random and puts it onto the battlefield.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new FreeForAllReturnFromExileEffect(), TargetController.ANY, false, true)); this.addAbility(new BeginningOfUpkeepTriggeredAbility(new FreeForAllReturnFromExileEffect(), TargetController.ANY, false));
// When Free-for-All leaves the battlefield, put all cards exiled with it into their owners' graveyards. // When Free-for-All leaves the battlefield, put all cards exiled with it into their owners' graveyards.
this.addAbility(new LeavesBattlefieldTriggeredAbility(new FreeForAllLeavesBattlefieldEffect(), false)); this.addAbility(new LeavesBattlefieldTriggeredAbility(new FreeForAllLeavesBattlefieldEffect(), false));
@ -54,12 +52,12 @@ public final class FreeForAll extends CardImpl {
class FreeForAllExileAllEffect extends OneShotEffect { class FreeForAllExileAllEffect extends OneShotEffect {
public FreeForAllExileAllEffect() { FreeForAllExileAllEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "exile all creatures face down"; staticText = "exile all creatures face down";
} }
public FreeForAllExileAllEffect(final FreeForAllExileAllEffect effect) { private FreeForAllExileAllEffect(final FreeForAllExileAllEffect effect) {
super(effect); super(effect);
} }
@ -70,26 +68,32 @@ class FreeForAllExileAllEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game); Player player = game.getPlayer(source.getControllerId());
for (Permanent permanent : permanents) { Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
Card card = game.getCard(permanent.getId()); if (player == null || sourcePermanent == null) {
permanent.moveToExile(source.getSourceId(), "Free-for-All", source, game); return false;
if (card != null) {
card.setFaceDown(true, game);
}
} }
Cards cards = new CardsImpl();
game.getBattlefield().getActivePermanents(
StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game
).stream().forEach(cards::add);
player.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), sourcePermanent.getIdName());
cards.getCards(game)
.stream()
.filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED)
.forEach(card -> card.setFaceDown(true, game));
return true; return true;
} }
} }
class FreeForAllReturnFromExileEffect extends OneShotEffect { class FreeForAllReturnFromExileEffect extends OneShotEffect {
public FreeForAllReturnFromExileEffect() { FreeForAllReturnFromExileEffect() {
super(Outcome.PutCardInPlay); super(Outcome.PutCardInPlay);
staticText = "that player chooses a card exiled with Free-for-All at random and puts it onto the battlefield"; staticText = "that player chooses a card exiled with {this} at random and puts it onto the battlefield";
} }
public FreeForAllReturnFromExileEffect(final FreeForAllReturnFromExileEffect effect) { private FreeForAllReturnFromExileEffect(final FreeForAllReturnFromExileEffect effect) {
super(effect); super(effect);
} }
@ -100,27 +104,24 @@ class FreeForAllReturnFromExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(game.getActivePlayerId());
if (player != null) { ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
ExileZone exZone = game.getExile().getExileZone(source.getSourceId()); if (player == null || exZone == null || exZone.isEmpty()) {
if (exZone != null) { return false;
Cards exiledCards = new CardsImpl(exZone.getCards(game));
return player.moveCards(exiledCards.getRandom(game), Zone.BATTLEFIELD, source, game);
}
return true;
} }
return false; Cards exiledCards = new CardsImpl(exZone.getCards(game));
return player.moveCards(exiledCards.getRandom(game), Zone.BATTLEFIELD, source, game);
} }
} }
class FreeForAllLeavesBattlefieldEffect extends OneShotEffect { class FreeForAllLeavesBattlefieldEffect extends OneShotEffect {
public FreeForAllLeavesBattlefieldEffect() { FreeForAllLeavesBattlefieldEffect() {
super(Outcome.Detriment); super(Outcome.Detriment);
this.staticText = "put all cards exiled with it into their owners' graveyards"; this.staticText = "put all cards exiled with it into their owners' graveyards";
} }
public FreeForAllLeavesBattlefieldEffect(final FreeForAllLeavesBattlefieldEffect effect) { private FreeForAllLeavesBattlefieldEffect(final FreeForAllLeavesBattlefieldEffect effect) {
super(effect); super(effect);
} }
@ -132,13 +133,9 @@ class FreeForAllLeavesBattlefieldEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { ExileZone exZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
ExileZone exZone = game.getExile().getExileZone(source.getSourceId()); return controller != null
if (exZone != null) { && exZone != null
return controller.moveCards(exZone.getCards(game), Zone.GRAVEYARD, source, game, false, false, true, null); && controller.moveCards(exZone.getCards(game), Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
} }
} }

View file

@ -1,7 +1,5 @@
package mage.cards.f; package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -9,15 +7,15 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.SpiritWhiteToken; import mage.game.permanent.token.SpiritWhiteToken;
import mage.game.permanent.token.Token;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import mage.util.CardUtil;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class FuneralPyre extends CardImpl { public final class FuneralPyre extends CardImpl {
@ -25,11 +23,9 @@ public final class FuneralPyre extends CardImpl {
public FuneralPyre(UUID ownerId, CardSetInfo setInfo) { public FuneralPyre(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}"); super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}");
// Exile target card from a graveyard. Its owner puts a 1/1 white Spirit creature token with flying onto the battlefield. // Exile target card from a graveyard. Its owner puts a 1/1 white Spirit creature token with flying onto the battlefield.
this.getSpellAbility().addEffect(new FuneralPyreEffect()); this.getSpellAbility().addEffect(new FuneralPyreEffect());
this.getSpellAbility().addTarget(new TargetCardInGraveyard()); this.getSpellAbility().addTarget(new TargetCardInGraveyard());
} }
private FuneralPyre(final FuneralPyre card) { private FuneralPyre(final FuneralPyre card) {
@ -44,12 +40,13 @@ public final class FuneralPyre extends CardImpl {
class FuneralPyreEffect extends OneShotEffect { class FuneralPyreEffect extends OneShotEffect {
public FuneralPyreEffect() { FuneralPyreEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "Exile target card from a graveyard. Its owner puts a 1/1 white Spirit creature token with flying onto the battlefield"; this.staticText = "Exile target card from a graveyard. " +
"Its owner creates a 1/1 white Spirit creature token with flying";
} }
public FuneralPyreEffect(final FuneralPyreEffect effect) { private FuneralPyreEffect(final FuneralPyreEffect effect) {
super(effect); super(effect);
} }
@ -60,17 +57,16 @@ class FuneralPyreEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Card exiledCard = game.getCard(source.getTargets().getFirstTarget()); Player player = game.getPlayer(source.getControllerId());
if (exiledCard != null) { Card exiledCard = game.getCard(source.getFirstTarget());
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), 0); if (player == null || exiledCard == null) {
if (exiledCard.moveToExile(exileId, "Funeral Pyre", source, game)) { return false;
Player owner = game.getPlayer(exiledCard.getOwnerId());
if (owner != null) {
Token token = new SpiritWhiteToken();
return token.putOntoBattlefield(1, game, source, owner.getId());
}
}
} }
return false; Player owner = game.getPlayer(exiledCard.getOwnerId());
player.moveCards(exiledCard, Zone.EXILED, source, game);
if (owner != null) {
new SpiritWhiteToken().putOntoBattlefield(1, game, source, owner.getId());
}
return true;
} }
} }

View file

@ -1,30 +1,24 @@
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.costs.common.ExileSourceFromHandCost;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player; import java.util.UUID;
/** /**
*
* @author Plopman * @author Plopman
*/ */
public final class SimianSpiritGuide extends CardImpl { public final class SimianSpiritGuide extends CardImpl {
public SimianSpiritGuide(UUID ownerId, CardSetInfo setInfo) { public SimianSpiritGuide(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}");
this.subtype.add(SubType.APE); this.subtype.add(SubType.APE);
this.subtype.add(SubType.SPIRIT); this.subtype.add(SubType.SPIRIT);
@ -44,40 +38,3 @@ public final class SimianSpiritGuide extends CardImpl {
return new SimianSpiritGuide(this); return new SimianSpiritGuide(this);
} }
} }
class ExileSourceFromHandCost extends CostImpl {
public ExileSourceFromHandCost() {
this.text = "Exile {this} from your hand";
}
public ExileSourceFromHandCost(ExileSourceFromHandCost cost) {
super(cost);
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Card card = game.getCard(source.getSourceId());
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(source.getSourceId()) && card != null) {
paid = card.moveToExile(ability.getSourceId(), "from Hand", source, game);
}
return paid;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
Player player = game.getPlayer(controllerId);
if (player != null && player.getHand().contains(source.getSourceId())) {
return true;
}
return false;
}
@Override
public ExileSourceFromHandCost copy() {
return new ExileSourceFromHandCost(this);
}
}

View file

@ -0,0 +1,46 @@
package mage.abilities.costs.common;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.cards.Card;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
* @author TheElk801
*/
public class ExileSourceFromHandCost extends CostImpl {
public ExileSourceFromHandCost() {
this.text = "exile {this} from your hand";
}
private ExileSourceFromHandCost(ExileSourceFromHandCost cost) {
super(cost);
}
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player player = game.getPlayer(controllerId);
Card card = game.getCard(source.getSourceId());
if (player != null && player.getHand().contains(source.getSourceId()) && card != null) {
paid = player.moveCards(card, Zone.EXILED, source, game);
}
return paid;
}
@Override
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
Player player = game.getPlayer(controllerId);
return player != null && player.getHand().contains(source.getSourceId());
}
@Override
public ExileSourceFromHandCost copy() {
return new ExileSourceFromHandCost(this);
}
}