mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
refactored card.moveToExile for I-J
reworked Inverter of Truth and Luminate Primordial
This commit is contained in:
parent
28c0bd55e8
commit
4c3de17006
5 changed files with 103 additions and 97 deletions
|
@ -1,34 +1,33 @@
|
|||
|
||||
|
||||
package mage.cards.i;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Loki
|
||||
*/
|
||||
public final class IdentityCrisis extends CardImpl {
|
||||
|
||||
public IdentityCrisis (UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{W}{W}{B}{B}");
|
||||
public IdentityCrisis(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}{W}{B}{B}");
|
||||
|
||||
|
||||
this.getSpellAbility().addEffect(new IdentityCrisisEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPlayer());
|
||||
}
|
||||
|
||||
public IdentityCrisis (final IdentityCrisis card) {
|
||||
private IdentityCrisis(final IdentityCrisis card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
@ -36,43 +35,34 @@ public final class IdentityCrisis extends CardImpl {
|
|||
public IdentityCrisis copy() {
|
||||
return new IdentityCrisis(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class IdentityCrisisEffect extends OneShotEffect {
|
||||
|
||||
IdentityCrisisEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "Exile all cards from target player's hand and graveyard";
|
||||
}
|
||||
|
||||
IdentityCrisisEffect(final IdentityCrisisEffect effect) {
|
||||
private IdentityCrisisEffect(final IdentityCrisisEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null) {
|
||||
for (UUID cid : player.getHand().copy()) {
|
||||
Card c = game.getCard(cid);
|
||||
if (c != null) {
|
||||
c.moveToExile(null, null, source, game);
|
||||
}
|
||||
}
|
||||
for (UUID cid : player.getGraveyard().copy()) {
|
||||
Card c = game.getCard(cid);
|
||||
if (c != null) {
|
||||
c.moveToExile(null, null, source, game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (controller == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Cards cards = new CardsImpl();
|
||||
cards.addAll(player.getHand());
|
||||
cards.addAll(player.getGraveyard());
|
||||
return controller.moveCards(cards, Zone.EXILED, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityCrisisEffect copy() {
|
||||
return new IdentityCrisisEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.ColorlessPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class InfernalReckoning extends CardImpl {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("colorless creature");
|
||||
private static final FilterPermanent filter = new FilterCreaturePermanent("colorless creature");
|
||||
|
||||
static {
|
||||
filter.add(ColorlessPredicate.instance);
|
||||
|
@ -31,7 +33,7 @@ public final class InfernalReckoning extends CardImpl {
|
|||
|
||||
// Exile target colorless creature. You gain life equal to its power.
|
||||
this.getSpellAbility().addEffect(new InfernalJudgmentEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(filter));
|
||||
}
|
||||
|
||||
private InfernalReckoning(final InfernalReckoning card) {
|
||||
|
@ -46,12 +48,12 @@ public final class InfernalReckoning extends CardImpl {
|
|||
|
||||
class InfernalJudgmentEffect extends OneShotEffect {
|
||||
|
||||
public InfernalJudgmentEffect() {
|
||||
InfernalJudgmentEffect() {
|
||||
super(Outcome.GainLife);
|
||||
staticText = "exile target colorless creature. You gain life equal to its power";
|
||||
}
|
||||
|
||||
public InfernalJudgmentEffect(final InfernalJudgmentEffect effect) {
|
||||
private InfernalJudgmentEffect(final InfernalJudgmentEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -62,14 +64,13 @@ class InfernalJudgmentEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (permanent == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
int creaturePower = permanent.getPower().getValue();
|
||||
permanent.moveToExile(null, null, source, game);
|
||||
game.getState().processAction(game);
|
||||
player.moveCards(permanent, Zone.EXILED, source, game);
|
||||
player.gainLife(creaturePower, game, source);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,32 @@
|
|||
|
||||
package mage.cards.i;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.DevoidAbility;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class InverterOfTruth extends CardImpl {
|
||||
|
||||
public InverterOfTruth(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{B}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{B}");
|
||||
this.subtype.add(SubType.ELDRAZI);
|
||||
this.power = new MageInt(6);
|
||||
this.toughness = new MageInt(6);
|
||||
|
@ -37,7 +38,7 @@ public final class InverterOfTruth extends CardImpl {
|
|||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// When Inverter of Truth enters the battlefield, exile all cards from your library face down, then shuffle all cards from your graveyard into your library.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new ExileLibraryEffect(), false));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new InverterOfTruthEffect(), false));
|
||||
}
|
||||
|
||||
private InverterOfTruth(final InverterOfTruth card) {
|
||||
|
@ -50,35 +51,37 @@ public final class InverterOfTruth extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class ExileLibraryEffect extends OneShotEffect {
|
||||
class InverterOfTruthEffect extends OneShotEffect {
|
||||
|
||||
public ExileLibraryEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "exile all cards from your library face down, then shuffle all cards from your graveyard into your library";
|
||||
InverterOfTruthEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "exile all cards from your library face down, " +
|
||||
"then shuffle all cards from your graveyard into your library";
|
||||
}
|
||||
|
||||
private InverterOfTruthEffect(final InverterOfTruthEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileLibraryEffect copy() {
|
||||
return new ExileLibraryEffect();
|
||||
public InverterOfTruthEffect copy() {
|
||||
return new InverterOfTruthEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
int count = controller.getLibrary().size();
|
||||
if (count > 0) {
|
||||
for (Card cardToExile: controller.getLibrary().getCards(game)) {
|
||||
cardToExile.moveToExile(null, "", source, game);
|
||||
cardToExile.setFaceDown(true, game);
|
||||
}
|
||||
}
|
||||
for (Card cardToLibrary: controller.getGraveyard().getCards(game)) {
|
||||
controller.moveCardToLibraryWithInfo(cardToLibrary, source, game, Zone.GRAVEYARD, true, true);
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Cards cards = new CardsImpl(player.getLibrary().getCards(game));
|
||||
player.moveCards(cards, Zone.EXILED, source, game);
|
||||
cards.removeIf(uuid -> game.getState().getZone(uuid) != Zone.EXILED);
|
||||
cards.getCards(game)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.forEach(card -> card.setFaceDown(true, game));
|
||||
player.shuffleCardsToLibrary(player.getGraveyard(), game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package mage.cards.l;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
|
@ -42,29 +43,31 @@ public final class Liberate extends CardImpl {
|
|||
|
||||
class LiberateEffect extends OneShotEffect {
|
||||
|
||||
public LiberateEffect() {
|
||||
LiberateEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText = "exile target creature you control. Return that card to the battlefield under its owner's control at the beginning of the next end step";
|
||||
staticText = "exile target creature you control. Return that card to the battlefield " +
|
||||
"under its owner's control at the beginning of the next end step";
|
||||
}
|
||||
|
||||
public LiberateEffect(final LiberateEffect effect) {
|
||||
private LiberateEffect(final LiberateEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (permanent != null && sourceObject != null) {
|
||||
if (permanent.moveToExile(source.getSourceId(), sourceObject.getIdName(), source, game)) {
|
||||
Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false);
|
||||
effect.setText("Return that card to the battlefield under its owner's control at the beginning of the next end step");
|
||||
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
|
||||
return true;
|
||||
}
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = permanent.getMainCard();
|
||||
player.moveCards(permanent, Zone.EXILED, source, game);
|
||||
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(
|
||||
new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false)
|
||||
.setText("Return that card to the battlefield under its owner's control at the beginning of the next end step")
|
||||
.setTargetPointer(new FixedTarget(card, game))
|
||||
), source);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.l;
|
||||
|
||||
import mage.MageInt;
|
||||
|
@ -11,6 +10,7 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.game.Game;
|
||||
|
@ -20,7 +20,8 @@ import mage.target.Target;
|
|||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetadjustment.TargetAdjuster;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
|
@ -34,7 +35,7 @@ public final class LuminatePrimordial extends CardImpl {
|
|||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(7);
|
||||
|
||||
//Vigilance
|
||||
// Vigilance
|
||||
this.addAbility(VigilanceAbility.getInstance());
|
||||
|
||||
// When Luminate Primordial enters the battlefield, for each opponent, exile up to one target creature
|
||||
|
@ -74,12 +75,12 @@ enum LuminatePrimordialAdjuster implements TargetAdjuster {
|
|||
|
||||
class LuminatePrimordialEffect extends OneShotEffect {
|
||||
|
||||
public LuminatePrimordialEffect() {
|
||||
LuminatePrimordialEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "for each opponent, exile up to one target creature that player controls and that player gains life equal to its power";
|
||||
}
|
||||
|
||||
public LuminatePrimordialEffect(final LuminatePrimordialEffect effect) {
|
||||
private LuminatePrimordialEffect(final LuminatePrimordialEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -90,18 +91,26 @@ class LuminatePrimordialEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Target target : source.getTargets()) {
|
||||
if (target instanceof TargetCreaturePermanent) {
|
||||
Permanent targetCreature = game.getPermanent(target.getFirstTarget());
|
||||
if (targetCreature != null && !targetCreature.isControlledBy(source.getControllerId())) {
|
||||
int amountLife = targetCreature.getPower().getValue();
|
||||
Player controller = game.getPlayer(targetCreature.getControllerId());
|
||||
targetCreature.moveToExile(null, null, source, game);
|
||||
if (controller != null && amountLife != 0) {
|
||||
controller.gainLife(amountLife, game, source);
|
||||
}
|
||||
}
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
Set<Permanent> permanents = source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getFirstTarget)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
Map<UUID, Integer> map = new HashMap<>();
|
||||
permanents.stream().map(p -> map.put(p.getControllerId(), p.getPower().getValue()));
|
||||
controller.moveCards(permanents, Zone.EXILED, source, game);
|
||||
for (Map.Entry<UUID, Integer> entry : map.entrySet()) {
|
||||
Player player = game.getPlayer(entry.getKey());
|
||||
if (player == null || entry.getValue() < 1) {
|
||||
continue;
|
||||
}
|
||||
player.gainLife(entry.getValue(), game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue