* Some more changes for rework of ENTERS_THE_BATTLEFIELD event and card movement.

This commit is contained in:
LevelX2 2015-10-18 23:33:23 +02:00
parent 4216fbab8c
commit 415700ccb2
129 changed files with 1029 additions and 1265 deletions

View file

@ -41,7 +41,7 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
public final static int MAGE_VERSION_MAJOR = 1;
public final static int MAGE_VERSION_MINOR = 4;
public final static int MAGE_VERSION_PATCH = 4;
public final static String MAGE_VERSION_MINOR_PATCH = "v8";
public final static String MAGE_VERSION_MINOR_PATCH = "v9";
public final static String MAGE_VERSION_INFO = "";
private final int major;

View file

@ -28,14 +28,13 @@
package mage.sets.alarareborn;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterPermanentCard;
@ -54,10 +53,6 @@ public class Wargate extends CardImpl {
super(ownerId, 129, "Wargate", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{G}{W}{U}");
this.expansionSetCode = "ARB";
// Search your library for a permanent card with converted mana cost X or less, put it onto the battlefield, then shuffle your library.
this.getSpellAbility().addEffect(new WargateEffect());
}
@ -72,8 +67,8 @@ public class Wargate extends CardImpl {
}
}
class WargateEffect extends OneShotEffect {
WargateEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Search your library for a permanent card with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
@ -97,7 +92,7 @@ class WargateEffect extends OneShotEffect {
if (target.getTargets().size() > 0) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.sets.antiquities;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.mana.GenericManaCost;
@ -43,7 +42,6 @@ import mage.filter.common.FilterControlledArtifactPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetArtifactPermanent;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetControlledPermanent;
@ -57,7 +55,6 @@ public class TransmuteArtifact extends CardImpl {
super(ownerId, 58, "Transmute Artifact", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{U}{U}");
this.expansionSetCode = "ATQ";
// Sacrifice an artifact. If you do, search your library for an artifact card. If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. If you don't, put it into its owner's graveyard. Then shuffle your library.
this.getSpellAbility().addEffect(new TransmuteArtifactEffect());
}
@ -74,7 +71,6 @@ public class TransmuteArtifact extends CardImpl {
class TransmuteArtifactEffect extends SearchEffect {
public TransmuteArtifactEffect() {
super(new TargetCardInLibrary(new FilterArtifactCard()), Outcome.PutCardInPlay);
staticText = "Sacrifice an artifact. If you do, search your library for an artifact card. If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield. If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield. If you don't, put it into its owner's graveyard. Then shuffle your library";
@ -95,41 +91,36 @@ class TransmuteArtifactEffect extends SearchEffect {
if (controller == null) {
return false;
}
//Sacrifice an artifact.
//Sacrifice an artifact.
int convertedManaCost = 0;
boolean sacrifice = false;
TargetControlledPermanent targetArtifact = new TargetControlledPermanent(new FilterControlledArtifactPermanent());
if(controller.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)){
if (controller.chooseTarget(Outcome.Sacrifice, targetArtifact, source, game)) {
Permanent permanent = game.getPermanent(targetArtifact.getFirstTarget());
if(permanent != null){
if (permanent != null) {
convertedManaCost = permanent.getManaCost().convertedManaCost();
sacrifice = permanent.sacrifice(source.getSourceId(), game);
}
}
else
{
} else {
return true;
}
//If you do, search your library for an artifact card.
//If you do, search your library for an artifact card.
if (sacrifice && controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
for (UUID cardId: target.getTargets()) {
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().getCard(cardId, game);
if (card != null) {
//If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield.
if(card.getManaCost().convertedManaCost() <= convertedManaCost){
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
else
{
//If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield.
//If that card's converted mana cost is less than or equal to the sacrificed artifact's converted mana cost, put it onto the battlefield.
if (card.getManaCost().convertedManaCost() <= convertedManaCost) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
//If it's greater, you may pay {X}, where X is the difference. If you do, put it onto the battlefield.
GenericManaCost cost = new GenericManaCost(card.getManaCost().convertedManaCost() - convertedManaCost);
if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)){
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
else{
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
//If you don't, put it into its owner's graveyard. Then shuffle your library
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}
@ -142,5 +133,4 @@ class TransmuteArtifactEffect extends SearchEffect {
return false;
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.apocalypse;
import java.util.UUID;
@ -34,11 +33,11 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterCreatureCard;
@ -52,7 +51,6 @@ import mage.target.common.TargetCardInYourGraveyard;
*
* @author LevelX2
*/
public class LifeDeath extends SplitCard {
public LifeDeath(UUID ownerId) {
@ -61,8 +59,8 @@ public class LifeDeath extends SplitCard {
// Life
// All lands you control become 1/1 creatures until end of turn. They're still lands.
getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new LifeLandToken(), "lands",
new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn));
getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new LifeLandToken(), "lands",
new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn));
// Death
// Return target creature card from your graveyard to the battlefield. You lose life equal to its converted mana cost.
@ -83,6 +81,7 @@ public class LifeDeath extends SplitCard {
}
class LifeLandToken extends Token {
public LifeLandToken() {
super("", "1/1 creatures");
cardType.add(CardType.CREATURE);
@ -115,10 +114,10 @@ class DeathEffect extends OneShotEffect {
if (creatureCard != null && controller != null) {
boolean result = false;
if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
result = controller.putOntoBattlefieldWithInfo(creatureCard, game, Zone.GRAVEYARD, source.getSourceId());
}
controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game);
}
controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game);
return result;
return true;
}
return false;
}

View file

@ -44,6 +44,7 @@ import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.counters.Counters;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -77,21 +78,21 @@ public class MakeshiftMannequin extends CardImpl {
}
class MakeshiftMannequinEffect extends OneShotEffect {
MakeshiftMannequinEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Return target creature card from your graveyard to the battlefield with a mannequin counter on it. For as long as that creature has a mannequin counter on it, it has \"When this creature becomes the target of a spell or ability, sacrifice it.\"";
}
MakeshiftMannequinEffect(final MakeshiftMannequinEffect effect) {
super(effect);
}
@Override
public MakeshiftMannequinEffect copy() {
return new MakeshiftMannequinEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -99,12 +100,14 @@ class MakeshiftMannequinEffect extends OneShotEffect {
UUID cardId = this.getTargetPointer().getFirst(game, source);
Card card = controller.getGraveyard().get(cardId, game);
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
Counters counters = new Counters();
counters.addCounter(CounterType.MANNEQUIN.createInstance());
game.setEnterWithCounters(cardId, counters);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(cardId);
if (permanent != null) {
permanent.addCounters(CounterType.MANNEQUIN.createInstance(), game);
ContinuousEffect gainedEffect = new MakeshiftMannequinGainAbilityEffect();
gainedEffect.setTargetPointer(new FixedTarget(cardId));
gainedEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(gainedEffect, source);
}
}

View file

@ -51,7 +51,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
/**
*
* @author noxx
*
*/
public class RestorationAngel extends CardImpl {
@ -71,7 +71,7 @@ public class RestorationAngel extends CardImpl {
this.addAbility(FlashAbility.getInstance());
this.addAbility(FlyingAbility.getInstance());
// When Restoration Angel enters the battlefield, you may exile target non-Angel creature you control, then return that card to the battlefield under your control
Ability ability = new EntersBattlefieldTriggeredAbility(new RestorationAngelEffect(), true);
ability.addTarget(new TargetControlledCreaturePermanent(1, 1, filter, false));
@ -111,11 +111,13 @@ class RestorationAngelEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null && sourcePermanent != null) {
controller.moveCardToExileWithInfo(permanent, source.getSourceId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
return controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId());
int zcc = permanent.getZoneChangeCounter(game);
controller.moveCards(permanent, Zone.EXILED, source, game);
Card card = game.getCard(permanent.getId());
if (card != null
&& card.getZoneChangeCounter(game) == zcc + 1
&& game.getState().getZone(card.getId()).equals(Zone.EXILED)) {
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -110,12 +110,12 @@ class GoryosVengeanceEffect extends OneShotEffect {
if (controller != null) {
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
// Haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
// Exile it at end of turn
Effect exileEffect = new ExileTargetEffect("Exile " + permanent.getName() + " at the beginning of the next end step");

View file

@ -84,26 +84,26 @@ public class IwamoriOfTheOpenFist extends CardImpl {
class IwamoriOfTheOpenFistEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("legendary creature card");
static {
filter.add(new SupertypePredicate("Legendary"));
filter.add(new CardTypePredicate(CardType.CREATURE));
}
public IwamoriOfTheOpenFistEffect() {
super(Outcome.Detriment);
this.staticText = "each opponent may put a legendary creature card from his or her hand onto the battlefield";
}
public IwamoriOfTheOpenFistEffect(final IwamoriOfTheOpenFistEffect effect) {
super(effect);
}
@Override
public IwamoriOfTheOpenFistEffect copy() {
return new IwamoriOfTheOpenFistEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -123,14 +123,7 @@ class IwamoriOfTheOpenFistEffect extends OneShotEffect {
}
}
}
if (cards.size() > 0) {
for (Card card: cards.getCards(game)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
}
}
}
controller.moveCards(cards.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}

View file

@ -35,8 +35,8 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.OfferingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -100,13 +100,8 @@ class PatronOfTheMoonEffect extends OneShotEffect {
if (controller != null) {
TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped"));
controller.chooseTarget(outcome, controller.getHand(), target, source, game);
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), true);
}
}
return true;
return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return false;
}

View file

@ -113,14 +113,13 @@ class PeregrinationEffect extends OneShotEffect {
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
card = revealed.getCards(game).iterator().next();
controller.moveCards(card, null, Zone.HAND, source, game);
controller.moveCards(card, Zone.HAND, source, game);
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}

View file

@ -28,6 +28,7 @@
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.SpliceOntoArcaneAbility;
@ -58,7 +59,6 @@ public class Reweave extends CardImpl {
this.expansionSetCode = "CHK";
this.subtype.add("Arcane");
// Target permanent's controller sacrifices it. If he or she does, that player reveals cards from the top of his or her library until he or she reveals a permanent card that shares a card type with the sacrificed permanent, puts that card onto the battlefield, then shuffles his or her library.
this.getSpellAbility().addEffect(new ReweaveEffect());
Target target = new TargetPermanent();
@ -97,9 +97,10 @@ class ReweaveEffect extends OneShotEffect {
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
if (permanent != null) {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game);
if (permanent != null && sourceObject != null) {
if (permanent.sacrifice(source.getSourceId(), game)) {
Player permanentController = game.getPlayer(permanent.getControllerId());
if (permanentController != null) {
@ -122,11 +123,11 @@ class ReweaveEffect extends OneShotEffect {
}
}
} while (!cardFound && library.size() > 0);
permanentController.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
permanentController.moveCards(card, Zone.BATTLEFIELD, source, game);
}
if (cards.size() > 0) {
permanentController.revealCards("Reweave", cards, game);
permanentController.revealCards(sourceObject.getIdName(), cards, game);
if (cardFound && card != null) {
cards.remove(card);
}
@ -137,7 +138,7 @@ class ReweaveEffect extends OneShotEffect {
return true;
}
return false;
}
}
}
return true;
}

View file

@ -106,7 +106,7 @@ class ThroughTheBreachEffect extends OneShotEffect {
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);

View file

@ -56,8 +56,9 @@ import mage.target.common.TargetCardInLibrary;
* @author emerald000
*/
public class ArcumDagsson extends CardImpl {
private static final FilterPermanent filter = new FilterArtifactPermanent("artifact creature");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
}
@ -88,26 +89,27 @@ public class ArcumDagsson extends CardImpl {
}
class ArcumDagssonEffect extends OneShotEffect {
private static final FilterCard filter = new FilterArtifactCard("noncreature artifact card");
static {
filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
}
ArcumDagssonEffect() {
super(Outcome.Removal);
this.staticText = "Target artifact creature's controller sacrifices it. That player may search his or her library for a noncreature artifact card, put it onto the battlefield, then shuffle his or her library";
}
ArcumDagssonEffect(final ArcumDagssonEffect effect) {
super(effect);
}
@Override
public ArcumDagssonEffect copy() {
return new ArcumDagssonEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent artifactCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
@ -120,7 +122,7 @@ class ArcumDagssonEffect extends OneShotEffect {
if (player.searchLibrary(target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
player.shuffleLibrary(game);

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
@ -148,20 +148,20 @@ class KaaliaOfTheVastEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, "Put an Angel, Demon, or Dragon creature card from your hand onto the battlefield tapped and attacking?", source, game)) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, "Put an Angel, Demon, or Dragon creature card from your hand onto the battlefield tapped and attacking?", source, game)) {
return false;
}
TargetCardInHand target = new TargetCardInHand(filter);
if (target.canChoose(player.getId(), game) && target.choose(getOutcome(), player.getId(), source.getSourceId(), game)) {
if (target.canChoose(controller.getId(), game) && target.choose(getOutcome(), controller.getId(), source.getSourceId(), game)) {
if (target.getTargets().size() > 0) {
UUID cardId = target.getFirstTarget();
Card card = game.getCard(cardId);
if (card != null && game.getCombat() != null) {
UUID defenderId = game.getCombat().getDefendingPlayerId(source.getSourceId(), game);
if (defenderId != null) {
player.getHand().remove(card);
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), true);
controller.getHand().remove(card);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
Permanent creature = game.getPermanent(cardId);
if (creature != null) {
game.getCombat().addAttackerToCombat(card.getId(), defenderId, game);

View file

@ -110,17 +110,17 @@ class KodamasReachEffect extends OneShotEffect {
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
}
card = revealed.getCards(game).iterator().next();
if (card != null) {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.moveCards(card, Zone.HAND, source, game);
}
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}

View file

@ -110,7 +110,7 @@ class TarielReckonerOfSoulsEffect extends OneShotEffect {
}
if (!creatureCards.isEmpty()) {
Card card = creatureCards.getRandom(game);
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
}

View file

@ -164,7 +164,7 @@ class DarettiSacrificeEffect extends OneShotEffect {
if (artifact != null && artifact.sacrifice(source.getSourceId(), game)) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
return controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -104,7 +104,7 @@ class InfernalOfferingSacrificeEffect extends OneShotEffect {
if (opponent != null) {
//Choose creatures to sacrifice
Map<UUID, UUID> toSacrifice = new HashMap<>(2);
for (UUID playerId : player.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
if (playerId.equals(player.getId()) || playerId.equals(opponent.getId())) {
target = new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent(), true);
if (target.choose(Outcome.Sacrifice, playerId, source.getControllerId(), game)) {
@ -154,16 +154,16 @@ class InfernalOfferingReturnEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetOpponent(true);
target.choose(Outcome.PutCreatureInPlay, source.getControllerId(), source.getSourceId(), game);
Player opponent = game.getPlayer(target.getFirstTarget());
target = new TargetCardInYourGraveyard(new FilterCreatureCard("creature card in your graveyard"));
if (target.choose(Outcome.PutCreatureInPlay, player.getId(), source.getSourceId(), game)) {
Card card = player.getGraveyard().get(target.getFirstTarget(), game);
if (target.choose(Outcome.PutCreatureInPlay, controller.getId(), source.getSourceId(), game)) {
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
if (opponent != null) {
@ -171,7 +171,7 @@ class InfernalOfferingReturnEffect extends OneShotEffect {
if (target.choose(Outcome.PutCreatureInPlay, opponent.getId(), source.getSourceId(), game)) {
Card card = opponent.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
opponent.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
opponent.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -186,14 +186,14 @@ class NahiriTheLithomancerSecondAbilityEffect extends OneShotEffect {
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
} else {
Target target = new TargetCardInYourGraveyard(0, 1, filter);
target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
return true;

View file

@ -28,14 +28,14 @@
package mage.sets.commander2014;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -92,19 +92,16 @@ class ScrapMasteryEffect extends OneShotEffect {
if (controller != null) {
Map<UUID, Set<UUID>> exiledCards = new HashMap<>();
// exile artifacts from graveyard
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<UUID> cards = new HashSet<>();
for (Card card : player.getGraveyard().getCards(new FilterArtifactCard(), game)) {
cards.add(card.getId());
player.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
}
Set cards = player.getGraveyard().getCards(new FilterArtifactCard(), game);
controller.moveCards(cards, Zone.EXILED, source, game);
exiledCards.put(player.getId(), cards);
}
}
// sacrifice all artifacts
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), playerId, game)) {
@ -113,15 +110,11 @@ class ScrapMasteryEffect extends OneShotEffect {
}
}
// puts all cards he or she exiled this way onto the battlefield
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (UUID cardId : exiledCards.get(playerId)) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
Cards playersExiledCards = new CardsImpl(exiledCards.get(playerId));
controller.moveCards(playersExiledCards, Zone.BATTLEFIELD, source, game);
}
}
return true;

View file

@ -37,8 +37,9 @@ import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -148,26 +149,22 @@ class WakeTheDeadReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEff
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false)) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
permanent.changeControllerId(source.getControllerId(), game);
Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId());
effect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
}
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl(getTargetPointer().getTargets(game, source));
controller.moveCards(cards, Zone.BATTLEFIELD, source, game);
for (UUID targetId : cards) {
Permanent creature = game.getPermanent(targetId);
if (creature != null) {
Effect effect = new SacrificeTargetEffect("Sacrifice those creatures at the beginning of the next end step", source.getControllerId());
effect.setTargetPointer(new FixedTarget(creature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
}
}
return true;
}

View file

@ -28,12 +28,15 @@
package mage.sets.commander2014;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -86,9 +89,9 @@ class WaveOfVitriolEffect extends OneShotEffect {
new CardTypePredicate(CardType.LAND),
Predicates.not(new SupertypePredicate("Basic"))
)
));
}
public WaveOfVitriolEffect() {
super(Outcome.Benefit);
this.staticText = "Each player sacrifices all artifacts, enchantments, and nonbasic lands he or she controls. For each land sacrificed this way, its controller may search his or her library for a basic land card and put it onto the battlefield tapped. Then each player who searched his or her library this way shuffles it";
@ -108,11 +111,11 @@ class WaveOfVitriolEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Map<Player, Integer> sacrificedLands = new HashMap<>();
for(UUID playerId: controller.getInRange()) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
int count = 0;
for(Permanent permanent: game.getBattlefield().getAllActivePermanents(filter, playerId, game)) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, playerId, game)) {
if (permanent.sacrifice(source.getSourceId(), game) && permanent.getCardType().contains(CardType.LAND)) {
count++;
}
@ -123,25 +126,19 @@ class WaveOfVitriolEffect extends OneShotEffect {
}
}
game.getState().handleSimultaneousEvent(game);
for(Map.Entry<Player, Integer> entry: sacrificedLands.entrySet()) {
Cards toBattlefield = new CardsImpl();
Set<Player> playersToShuffle = new LinkedHashSet<>();
for (Map.Entry<Player, Integer> entry : sacrificedLands.entrySet()) {
if (entry.getKey().chooseUse(Outcome.PutLandInPlay, "Search your library for up to " + entry.getValue() + " basic lands?", source, game)) {
Target target = new TargetCardInLibrary(0, entry.getValue(), new FilterBasicLandCard());
entry.getKey().chooseTarget(outcome, target, source, game);
for(UUID targetId: target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null) {
entry.getKey().putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
}
}
entry.getKey().shuffleLibrary(game);
} else {
entry.setValue(0);
toBattlefield.addAll(target.getTargets());
playersToShuffle.add(entry.getKey());
}
}
for(Map.Entry<Player, Integer> entry: sacrificedLands.entrySet()) {
if (entry.getValue() > 0) {
entry.getKey().shuffleLibrary(game);
}
controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
for (Player player : playersToShuffle) {
player.shuffleLibrary(game);
}
return true;

View file

@ -1,31 +1,30 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.conflux;
import java.util.UUID;
@ -52,7 +51,7 @@ public class PathToExile extends CardImpl {
public PathToExile(UUID ownerId) {
super(ownerId, 15, "Path to Exile", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{W}");
this.expansionSetCode = "CON";
this.expansionSetCode = "CON";
// Exile target creature. Its controller may search his or her library for a basic land card,
// put that card onto the battlefield tapped, then shuffle his or her library.
@ -93,13 +92,13 @@ class PathToExileEffect extends OneShotEffect {
if (controller != null && permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
// if the zone change to exile gets replaced does not prevent the target controller to be able to search
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
controller.moveCardToExileWithInfo(permanent, null, "", source.getSourceId(), game, Zone.BATTLEFIELD, true);
if (player.chooseUse(Outcome.PutCardInPlay, "Search your library for a basic land card?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
if (player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
player.shuffleLibrary(game);

View file

@ -106,9 +106,9 @@ public class SkywardEyeProphets extends CardImpl {
cards.add(card);
controller.revealCards(sourceObject.getName(), cards, game);
if (card.getCardType().contains(CardType.LAND)) {
return controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.moveCards(card, Zone.HAND, source, game);
}
}
return true;

View file

@ -106,7 +106,7 @@ class GrenzoDungeonWardenEffect extends OneShotEffect {
if (card.getCardType().contains(CardType.CREATURE)) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && card.getPower().getValue() <= sourcePermanent.getPower().getValue()) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -31,8 +31,8 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -70,36 +70,32 @@ public class Victimize extends CardImpl {
}
class VictimizeEffect extends OneShotEffect {
VictimizeEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Choose two target creature cards in your graveyard. Sacrifice a creature. If you do, return the chosen cards to the battlefield tapped";
}
VictimizeEffect(final VictimizeEffect effect) {
super(effect);
}
@Override
public VictimizeEffect copy() {
return new VictimizeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature")));
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
for (UUID targetId: getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), true);
}
}
controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return true;
}
return false;
}
}
}

View file

@ -28,10 +28,6 @@
package mage.sets.darkascension;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
@ -41,6 +37,10 @@ import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.keyword.IntimidateAbility;
import mage.abilities.keyword.UndyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -74,6 +74,7 @@ public class MikaeusTheUnhallowed extends CardImpl {
this.addAbility(IntimidateAbility.getInstance());
// Whenever a Human deals damage to you, destroy it.
this.addAbility(new MikaeusTheUnhallowedAbility());
// Other non-Human creatures you control get +1/+1 and have undying.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(new UndyingAbility(), Duration.WhileOnBattlefield, filter, true)));
@ -109,7 +110,6 @@ class MikaeusTheUnhallowedAbility extends TriggeredAbilityImpl {
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.controllerId)) {

View file

@ -28,15 +28,14 @@
package mage.sets.darksteel;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterCard;
@ -64,7 +63,6 @@ public class Reshape extends CardImpl {
super(ownerId, 31, "Reshape", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{X}{U}{U}");
this.expansionSetCode = "DST";
// As an additional cost to cast Reshape, sacrifice an artifact.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, false)));
// Search your library for an artifact card with converted mana cost X or less and put it onto the battlefield. Then shuffle your library.
@ -94,8 +92,8 @@ class ReshapeSearchEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
//Set the mana cost one higher to 'emulate' a less than or equal to comparison.
@ -104,17 +102,17 @@ class ReshapeSearchEffect extends OneShotEffect {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, xValue));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}

View file

@ -69,10 +69,10 @@ public class CryptChampion extends CardImpl {
// Double strike
this.addAbility(DoubleStrikeAbility.getInstance());
// When Crypt Champion enters the battlefield, each player puts a creature card with converted mana cost 3 or less from his or her graveyard onto the battlefield.
this.addAbility(new EntersBattlefieldTriggeredAbility(new CryptChampionEffect()));
// When Crypt Champion enters the battlefield, sacrifice it unless {R} was spent to cast it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SacrificeSourceUnlessConditionEffect(new ManaWasSpentCondition(ColoredManaSymbol.R)), false), new ManaSpentToCastWatcher());
}
@ -88,26 +88,26 @@ public class CryptChampion extends CardImpl {
}
class CryptChampionEffect extends OneShotEffect {
CryptChampionEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "each player puts a creature card with converted mana cost 3 or less from his or her graveyard onto the battlefield";
}
CryptChampionEffect(final CryptChampionEffect effect) {
super(effect);
}
@Override
public CryptChampionEffect copy() {
return new CryptChampionEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterCard filter = new FilterCreatureCard("creature card with converted mana cost 3 or less from your graveyard");
@ -117,7 +117,7 @@ class CryptChampionEffect extends OneShotEffect {
if (target.canChoose(playerId, game) && player.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -25,17 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.dragonsmaze;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -45,6 +37,13 @@ import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.ColorPredicate;
@ -52,27 +51,21 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class BloodBaronOfVizkopa extends CardImpl {
private static final FilterCard filter = new FilterCard("white and from black");
static {
filter.add(Predicates.or(
new ColorPredicate(ObjectColor.WHITE),
new ColorPredicate(ObjectColor.BLACK)));
}
public BloodBaronOfVizkopa (UUID ownerId) {
public BloodBaronOfVizkopa(UUID ownerId) {
super(ownerId, 57, "Blood Baron of Vizkopa", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{3}{W}{B}");
this.expansionSetCode = "DGM";
this.subtype.add("Vampire");
this.power = new MageInt(4);
this.toughness = new MageInt(4);
@ -85,7 +78,7 @@ public class BloodBaronOfVizkopa extends CardImpl {
}
public BloodBaronOfVizkopa (final BloodBaronOfVizkopa card) {
public BloodBaronOfVizkopa(final BloodBaronOfVizkopa card) {
super(card);
}
@ -97,7 +90,7 @@ public class BloodBaronOfVizkopa extends CardImpl {
}
class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl {
public BloodBaronOfVizkopaEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature);
staticText = "As long as you have 30 or more life and an opponent has 10 or less life, {this} gets +6/+6 and has flying";
@ -117,21 +110,21 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl {
if (conditionState(source, game)) {
Permanent creature = game.getPermanent(source.getSourceId());
if (creature != null) {
switch (layer) {
case PTChangingEffects_7:
if (sublayer == SubLayer.ModifyPT_7c) {
creature.addPower(6);
creature.addToughness(6);
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game);
}
break;
default:
}
return true;
switch (layer) {
case PTChangingEffects_7:
if (sublayer == SubLayer.ModifyPT_7c) {
creature.addPower(6);
creature.addToughness(6);
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
creature.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game);
}
break;
default:
}
return true;
}
}
return false;
@ -140,10 +133,12 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl {
protected boolean conditionState(Ability source, Game game) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLife() >= 30) {
for (UUID opponentId :player.getInRange()) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && opponent.getLife() < 11) {
return true;
for (UUID opponentId : player.getInRange()) {
if (player.hasOpponent(opponentId, game)) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null && opponent.getLife() < 11) {
return true;
}
}
}
}
@ -159,6 +154,6 @@ class BloodBaronOfVizkopaEffect extends ContinuousEffectImpl {
public boolean hasLayer(Layer layer) {
return (layer.equals(Layer.AbilityAddingRemovingEffects_6) || layer.equals(layer.PTChangingEffects_7));
}
}
}

View file

@ -101,9 +101,9 @@ class DeathmistRaptorEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
if (controller != null && (sourceObject instanceof Card)) {
controller.putOntoBattlefieldWithInfo((Card) sourceObject, game, Zone.GRAVEYARD, source.getSourceId(), false,
controller.chooseUse(Outcome.Detriment, "Return " + sourceObject.getLogName() + " face down to battlefield (otherwise face up)?", source, game));
return true;
return controller.moveCards((Card) sourceObject, Zone.BATTLEFIELD, source, game, false,
controller.chooseUse(Outcome.Detriment, "Return " + sourceObject.getLogName() + " face down to battlefield (otherwise face up)?", source, game),
false, null);
}
return false;
}

View file

@ -122,7 +122,7 @@ class SwiftWarkiteEffect extends OneShotEffect {
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
@ -143,7 +143,7 @@ class SwiftWarkiteEffect extends OneShotEffect {
target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);

View file

@ -37,7 +37,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -108,23 +107,20 @@ class SkirkDrillSergeantEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player == null || sourceObject == null) {
if (controller == null || sourceObject == null) {
return false;
}
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(sourceObject.getName(), cards, game);
if (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().getFromTop(game);
controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card != null) {
if (filter.match(card, game)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}

View file

@ -65,7 +65,6 @@ public class OathOfDruids extends CardImpl {
super(ownerId, 115, "Oath of Druids", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
this.expansionSetCode = "EXO";
// At the beginning of each player's upkeep, that player chooses target player who controls more creatures than he or she does and is his or her opponent. The first player may reveal cards from the top of his or her library until he or she reveals a creature card. If he or she does, that player puts that card onto the battlefield and all other cards revealed this way into his or her graveyard.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfDruidsEffect(), TargetController.ANY, true);
ability.addTarget(new TargetPlayer(1, 1, false, filter));
@ -136,32 +135,32 @@ class OathOfDruidsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = game.getObject(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (player == null || sourceObject == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || sourceObject == null) {
return false;
}
Cards revealed = new CardsImpl();
Card creatureCard = null;
Cards nonCreatureCards = new CardsImpl();
//The first player may reveal cards from the top of his or her library
while (creatureCard == null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
while (creatureCard == null && controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
revealed.add(card);
// until he or she reveals a creature card.
// until he or she reveals a creature card.
if (card.getCardType().contains(CardType.CREATURE)) {
creatureCard = card;
} else {
nonCreatureCards.add(card);
}
}
player.revealCards(sourceObject.getName(), revealed, game);
controller.revealCards(sourceObject.getIdName(), revealed, game);
//If he or she does, that player puts that card onto the battlefield
if (creatureCard != null) {
player.putOntoBattlefieldWithInfo(creatureCard, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game);
}
// and all other cards revealed this way into his or her graveyard
player.moveCards(nonCreatureCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(nonCreatureCards, Zone.GRAVEYARD, source, game);
return true;
}

View file

@ -65,7 +65,7 @@ public class OathOfLieges extends CardImpl {
this.expansionSetCode = "EXO";
// At the beginning of each player's upkeep, that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library.
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, Outcome.PutLandInPlay);
Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, true, Outcome.PutLandInPlay, true);
effect.setText("that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library");
Ability ability = new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, true);
ability.addTarget(new TargetPlayer(1, 1, false, filter));

View file

@ -29,6 +29,8 @@ package mage.sets.fatereforged;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -96,15 +98,18 @@ class GhastlyConscriptionEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) {
ArrayList<Card> cardsToManifest = new ArrayList<>();
for(Card card: targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) {
for (Card card : targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) {
cardsToManifest.add(card);
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
}
if (cardsToManifest.isEmpty()) {
return true;
}
Collections.shuffle(cardsToManifest);
game.informPlayers(controller.getLogName() + " shuffles the face-down pile");
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
for (Card card: cardsToManifest) {
for (Card card : cardsToManifest) {
ManaCosts manaCosts = null;
if (card.getCardType().contains(CardType.CREATURE)) {
manaCosts = card.getSpellAbility().getManaCosts();
@ -112,13 +117,12 @@ class GhastlyConscriptionEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(controller.getLogName())
.append(" puts facedown card from exile onto the battlefield").toString());
}
}
Set<Card> toBattlefield = new LinkedHashSet();
toBattlefield.addAll(cardsToManifest);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;

View file

@ -29,7 +29,9 @@ package mage.sets.fatereforged;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
@ -74,7 +76,7 @@ public class JeskaiInfiltrator extends CardImpl {
Effect effect = new ConditionalRestrictionEffect(new CantBeBlockedSourceEffect(), new OneControlledCreatureCondition());
effect.setText("{this} can't be blocked as long as you control no other creatures");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// Whenever Jeskai Infiltrator deals combat damage to a player, exile it and the top card of your library in a face-down pile, shuffle that pile, then manifest those cards.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new JeskaiInfiltratorEffect(), false));
}
@ -90,35 +92,35 @@ public class JeskaiInfiltrator extends CardImpl {
}
class JeskaiInfiltratorEffect extends OneShotEffect {
JeskaiInfiltratorEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "exile it and the top card of your library in a face-down pile, shuffle that pile, then manifest those cards";
}
JeskaiInfiltratorEffect(final JeskaiInfiltratorEffect effect) {
super(effect);
}
@Override
public JeskaiInfiltratorEffect copy() {
return new JeskaiInfiltratorEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
List<Card> cardsToManifest = new ArrayList<>(2);
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Card sourceCard = game.getCard(source.getSourceId());
if (sourcePermanent != null && sourceCard != null) {
player.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
if (sourcePermanent != null && sourceCard != null) {
controller.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
cardsToManifest.add(sourceCard);
}
if (sourcePermanent!= null && player.getLibrary().size() > 0) {
Card cardFromLibrary = player.getLibrary().removeFromTop(game);
player.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
if (sourcePermanent != null && controller.getLibrary().size() > 0) {
Card cardFromLibrary = controller.getLibrary().removeFromTop(game);
controller.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
cardsToManifest.add(cardFromLibrary);
}
Collections.shuffle(cardsToManifest);
@ -133,13 +135,12 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(player.getLogName())
.append(" puts facedown card from exile onto the battlefield").toString());
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
Set<Card> toBattlefield = new LinkedHashSet();
toBattlefield.addAll(cardsToManifest);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;

View file

@ -46,6 +46,7 @@ import mage.filter.Filter.ComparisonType;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
@ -99,11 +100,13 @@ class RallyTheAncestorsEffect extends OneShotEffect {
FilterCreatureCard filter = new FilterCreatureCard();
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, xValue + 1));
Set<Card> cards = player.getGraveyard().getCards(filter, game);
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
for (Card card : cards) {
if (card != null) {
if (player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Effect exileEffect = new ExileTargetEffect("Exile those creatures at the beginning of your next upkeep");
exileEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());

View file

@ -97,6 +97,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect {
this.tapped = tapped;
setText();
}
public ReturnSourceFromExileToBattlefieldEffect(boolean tapped, boolean ownerControl) {
super(Outcome.PutCreatureInPlay);
this.tapped = tapped;
@ -135,7 +136,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect {
return false;
}
return player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), tapped);
return player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
private void setText() {
@ -144,7 +145,7 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect {
sb.append(" tapped");
}
if (ownerControl) {
sb.append(" under its owner's control");
sb.append(" under its owner's control");
}
staticText = sb.toString();
}

View file

@ -35,8 +35,8 @@ import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayVariableLoyaltyCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -154,12 +154,7 @@ class UginTheSpiritDragonEffect3 extends OneShotEffect {
controller.drawCards(7, game);
TargetCardInHand target = new TargetCardInHand(0, 7, new FilterPermanentCard("permanent cards"));
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getControllerId());
}
}
controller.moveCards(new CardsImpl(target.getTargets()), Zone.BATTLEFIELD, source, game);
}
return true;
}

View file

@ -59,18 +59,17 @@ public class EndlessWhispers extends CardImpl {
super(ownerId, 49, "Endless Whispers", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}");
this.expansionSetCode = "5DN";
// Each creature has "When this creature dies, choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step."
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnSourceToBattlefieldEffect());
Effect effect = new CreateDelayedTriggeredAbilityEffect(delayedAbility, true);
effect.setText("choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step");
Ability gainAbility = new DiesTriggeredAbility(effect);
gainAbility.addTarget(new TargetOpponent());
effect = new GainAbilityAllEffect(gainAbility, Duration.WhileOnBattlefield, new FilterCreaturePermanent("Each creature"));
effect.setText("Each creature has \"When this creature dies, choose target opponent. That player puts this card from its owner's graveyard onto the battlefield under his or her control at the beginning of the next end step.\"");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
public EndlessWhispers(final EndlessWhispers card) {
@ -85,18 +84,17 @@ public class EndlessWhispers extends CardImpl {
class ReturnSourceToBattlefieldEffect extends OneShotEffect {
public ReturnSourceToBattlefieldEffect() {
this(false);
}
public ReturnSourceToBattlefieldEffect(boolean tapped) {
super(Outcome.PutCreatureInPlay);
setText();
staticText = "That player puts this card from its owner's graveyard onto the battlefield under his or her control";
}
public ReturnSourceToBattlefieldEffect(boolean tapped, boolean ownerControl) {
super(Outcome.PutCreatureInPlay);
setText();
}
public ReturnSourceToBattlefieldEffect(final ReturnSourceToBattlefieldEffect effect) {
@ -112,24 +110,19 @@ class ReturnSourceToBattlefieldEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
if (!game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
return false;
}
}
Card card = game.getCard(source.getSourceId());
if (card == null) {
return false;
}
Player player = game.getPlayer(source.getFirstTarget());
if (player == null) {
if (player == null) {
return false;
}
return player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false);
}
return player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
private void setText() {
StringBuilder sb = new StringBuilder("That player puts this card from its owner's graveyard onto the battlefield under his or her control");
}
}
}

View file

@ -34,7 +34,6 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.SourceOnBattlefieldCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -66,7 +65,7 @@ public class MyrServitor extends CardImpl {
SourceOnBattlefieldCondition.getInstance(),
"At the beginning of your upkeep, if {this} is on the battlefield, each player returns all cards named Myr Servitor from his or her graveyard to the battlefield"
));
}
public MyrServitor(final MyrServitor card) {
@ -80,39 +79,38 @@ public class MyrServitor extends CardImpl {
}
class MyrServitorReturnEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("cards named Myr Servitor");
static {
filter.add(new NamePredicate("Myr Servitor"));
}
public MyrServitorReturnEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "if {this} is on the battlefield, each player returns all cards named Myr Servitor from his or her graveyard to the battlefield";
}
public MyrServitorReturnEffect(final MyrServitorReturnEffect effect) {
super(effect);
}
@Override
public MyrServitorReturnEffect copy() {
return new MyrServitorReturnEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId: controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card: player.getGraveyard().getCards(filter, game)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
}
controller.moveCards(player.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game);
}
}
return true;
}
return false;
}

View file

@ -96,7 +96,7 @@ class TheRackTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return new StringBuilder("At the beginning of the chosen player's upkeep, ").append(super.getRule()).toString();
return "At the beginning of the chosen player's upkeep, " + super.getRule();
}
}
@ -119,7 +119,7 @@ class TheRackEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
UUID playerId = (UUID) game.getState().getValue(new StringBuilder(source.getSourceId().toString()).append("_player").toString());
UUID playerId = (UUID) game.getState().getValue(source.getSourceId().toString() + "_player");
Player chosenPlayer = game.getPlayer(playerId);
if (chosenPlayer != null) {
int damage = 3 - chosenPlayer.getHand().size();

View file

@ -70,7 +70,7 @@ public class SwordOfTheMeek extends CardImpl {
this.subtype.add("Equipment");
// Equipped creature gets +1/+2.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1,2,Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 2, Duration.WhileOnBattlefield)));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2)));
// Whenever a 1/1 creature enters the battlefield under your control, you may return Sword of the Meek from your graveyard to the battlefield, then attach it to that creature.
@ -108,7 +108,7 @@ class SwordOfTheMeekEffect extends OneShotEffect {
Card equipment = game.getCard(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (equipment != null && controller != null && game.getState().getZone(source.getSourceId()).equals(Zone.GRAVEYARD)) {
controller.putOntoBattlefieldWithInfo(equipment, game, Zone.GRAVEYARD, source.getSourceId());
controller.moveCards(equipment, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
return permanent.addAttachment(equipment.getId(), game);

View file

@ -180,7 +180,7 @@ class ObzedatGhostCouncilReturnEffect extends OneShotEffect {
// return it only from the own exile zone
if (currentZone != null && currentZone.size() > 0) {
Player owner = game.getPlayer(card.getOwnerId());
if (owner != null && owner.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) {
if (owner != null && owner.moveCards(card, Zone.BATTLEFIELD, source, game)) {
return true;
}
}

View file

@ -78,13 +78,12 @@ public class DanceOfTheDead extends CardImpl {
this.expansionSetCode = "ICE";
this.subtype.add("Aura");
// Enchant creature card in a graveyard
TargetCardInGraveyard auraTarget = new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard"));
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new DanceOfTheDeadAttachEffect(Outcome.PutCreatureInPlay));
Ability enchantAbility = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(enchantAbility);
this.addAbility(enchantAbility);
// When Dance of the Dead enters the battlefield, if it's on the battlefield, it loses "enchant creature card in a graveyard" and gains "enchant creature put onto the battlefield with Dance of the Dead." Put enchanted creature card to the battlefield tapped under your control and attach Dance of the Dead to it. When Dance of the Dead leaves the battlefield, that creature's controller sacrifices it.
Ability ability = new ConditionalTriggeredAbility(
new EntersBattlefieldTriggeredAbility(new DanceOfTheDeadReAttachEffect(), false),
@ -92,18 +91,18 @@ public class DanceOfTheDead extends CardImpl {
"When {this} enters the battlefield, if it's on the battlefield, it loses \"enchant creature card in a graveyard\" and gains \"enchant creature put onto the battlefield with {this}.\" Return enchanted creature card to the battlefield under your control and attach {this} to it.");
ability.addEffect(new DanceOfTheDeadChangeAbilityEffect());
this.addAbility(ability);
this.addAbility(new LeavesBattlefieldTriggeredAbility(new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(), false));
this.addAbility(new LeavesBattlefieldTriggeredAbility(new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(), false));
// Enchanted creature gets +1/+1 and doesn't untap during its controller's untap step.
ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(1, 1, Duration.WhileOnBattlefield));
Effect effect = new DontUntapInControllersUntapStepEnchantedEffect();
effect.setText("and doesn't untap during its controller's untap step");
ability.addEffect(effect);
this.addAbility(ability);
// At the beginning of the upkeep of enchanted creature's controller, that player may pay {1}{B}. If he or she does, untap that creature.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DanceOfTheDeadDoIfCostPaidEffect(), TargetController.CONTROLLER_ATTACHED_TO, false));
}
public DanceOfTheDead(final DanceOfTheDead card) {
@ -117,36 +116,36 @@ public class DanceOfTheDead extends CardImpl {
}
class DanceOfTheDeadReAttachEffect extends OneShotEffect {
public DanceOfTheDeadReAttachEffect() {
super(Outcome.Benefit);
this.staticText = "Return enchanted creature card to the battlefield under your control and attach {this} to it";
}
public DanceOfTheDeadReAttachEffect(final DanceOfTheDeadReAttachEffect effect) {
super(effect);
}
@Override
public DanceOfTheDeadReAttachEffect copy() {
return new DanceOfTheDeadReAttachEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantment = game.getPermanent(source.getSourceId());
if (controller != null && enchantment != null) {
Card cardInGraveyard = game.getCard(enchantment.getAttachedTo());
if (cardInGraveyard == null) {
return true;
}
// put card into play
controller.putOntoBattlefieldWithInfo(cardInGraveyard, game, Zone.GRAVEYARD, source.getSourceId(), true);
controller.moveCards(cardInGraveyard, Zone.BATTLEFIELD, source, game, true, false, false, null);
Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId());
FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with Dance of the Dead");
filter.add(new PermanentIdPredicate(cardInGraveyard.getId()));
Target target = new TargetCreaturePermanent(filter);
@ -159,27 +158,27 @@ class DanceOfTheDeadReAttachEffect extends OneShotEffect {
}
return true;
}
return false;
}
}
class DanceOfTheDeadLeavesBattlefieldTriggeredEffect extends OneShotEffect {
public DanceOfTheDeadLeavesBattlefieldTriggeredEffect() {
super(Outcome.Benefit);
this.staticText = "enchanted creature's controller sacrifices it";
}
public DanceOfTheDeadLeavesBattlefieldTriggeredEffect(final DanceOfTheDeadLeavesBattlefieldTriggeredEffect effect) {
super(effect);
}
@Override
public DanceOfTheDeadLeavesBattlefieldTriggeredEffect copy() {
return new DanceOfTheDeadLeavesBattlefieldTriggeredEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
@ -236,17 +235,16 @@ class DanceOfTheDeadAttachEffect extends OneShotEffect {
class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements SourceEffect {
private final static Ability newAbility = new EnchantAbility("creature put onto the battlefield with Dance of the Dead");
static {
newAbility.setRuleAtTheTop(true);
}
public DanceOfTheDeadChangeAbilityEffect() {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
staticText = "it loses \"enchant creature card in a graveyard\" and gains \"enchant creature put onto the battlefield with Dance of the Dead\"";
}
public DanceOfTheDeadChangeAbilityEffect(final DanceOfTheDeadChangeAbilityEffect effect) {
super(effect);
}
@ -255,7 +253,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements
public DanceOfTheDeadChangeAbilityEffect copy() {
return new DanceOfTheDeadChangeAbilityEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
@ -267,7 +265,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements
Permanent permanent = affectedObjectList.get(0).getPermanent(game);;
if (permanent != null) {
Ability abilityToRemove = null;
for (Ability ability: permanent.getAbilities()) {
for (Ability ability : permanent.getAbilities()) {
if (ability instanceof EnchantAbility) {
abilityToRemove = ability;
}
@ -277,7 +275,7 @@ class DanceOfTheDeadChangeAbilityEffect extends ContinuousEffectImpl implements
}
permanent.addAbility(newAbility, source.getSourceId(), game);
return true;
}
}
return false;
}
}
@ -309,4 +307,4 @@ class DanceOfTheDeadDoIfCostPaidEffect extends DoIfCostPaid {
return new StringBuilder("that player may ").append(getCostText())
.append(". If he or she does, ").append(executingEffects.getText(mode)).toString();
}
}
}

View file

@ -96,13 +96,12 @@ class CaravanVigilEffect extends OneShotEffect {
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
Cards cards = new CardsImpl(card);
if (MorbidCondition.getInstance().apply(game, source)
&& controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to put the card onto the battlefield instead?", source, game)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.moveCards(card, Zone.HAND, source, game);
}
controller.revealCards(sourceObject.getIdName(), cards, game);
}

View file

@ -98,16 +98,16 @@ class GhostQuarterEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getPermanentOrLKIBattlefield(source.getFirstTarget()); // if indestructible effect should work also
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) {
Player controller = game.getPlayer(permanent.getControllerId());
if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
if (player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
}
return true;
}

View file

@ -98,7 +98,7 @@ class PhyrexianDelverEffect extends OneShotEffect {
if (creatureCard != null && controller != null) {
boolean result = false;
if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
result = controller.putOntoBattlefieldWithInfo(creatureCard, game, Zone.GRAVEYARD, source.getSourceId());
result = controller.moveCards(creatureCard, Zone.BATTLEFIELD, source, game);;
}
controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game);
return result;

View file

@ -67,7 +67,7 @@ public class ThicketElemental extends CardImpl {
// When Thicket Elemental enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ThicketElementalEffect());
this.addAbility(new ConditionalTriggeredAbility(ability, KickedCondition.getInstance(),
"When {this} enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library."));
"When {this} enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library."));
}
public ThicketElemental(final ThicketElemental card) {
@ -82,8 +82,6 @@ public class ThicketElemental extends CardImpl {
class ThicketElementalEffect extends OneShotEffect {
public ThicketElementalEffect() {
super(Outcome.Benefit);
staticText = "if {this} was kicked, reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and shuffle all other cards revealed this way into your library";
@ -102,15 +100,13 @@ class ThicketElementalEffect extends OneShotEffect {
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card.getCardType().contains(CardType.CREATURE)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
controller.revealCards("ThicketElemental", revealedCards, game);
for (Card card: revealedCards.getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(game);
return true;
}
@ -121,4 +117,4 @@ class ThicketElementalEffect extends OneShotEffect {
public ThicketElementalEffect copy() {
return new ThicketElementalEffect(this);
}
}
}

View file

@ -27,6 +27,8 @@
*/
package mage.sets.judgment;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
@ -44,10 +46,10 @@ import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import mage.util.CardUtil;
@ -94,6 +96,7 @@ class WorldgorgerDragonEntersEffect extends OneShotEffect {
static {
filter.add(new ControllerPredicate(TargetController.YOU));
filter.add(new AnotherPredicate());
}
public WorldgorgerDragonEntersEffect() {
@ -112,11 +115,9 @@ class WorldgorgerDragonEntersEffect extends OneShotEffect {
if (controller != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileId != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (!permanent.getId().equals(source.getSourceId())) { // Another
controller.moveCardToExileWithInfo(permanent, exileId, sourceObject.getIdName(), source.getSourceId(), game, Zone.BATTLEFIELD, true);
}
}
Set<Card> cardsToExile = new LinkedHashSet<>();
cardsToExile.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game));
controller.moveCardsToExile(cardsToExile, source, game, true, exileId, sourceObject.getIdName());
return true;
}
}
@ -148,14 +149,7 @@ class WorldgorgerDragonLeavesEffect extends OneShotEffect {
int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exile != null) {
exile = exile.copy();
for (UUID cardId : exile) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
}
}
return true;
return controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}
return false;

View file

@ -64,13 +64,13 @@ public class AshcloudPhoenix extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Ashcloud Phoenix dies, return it to the battlefield face down under your control.
this.addAbility(new DiesTriggeredAbility(new AshcloudPhoenixEffect()));
// Morph {4}{R}{R}
this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{4}{R}{R}")));
// When Ashcloud Phoenix is turned face up, it deals 2 damage to each player.
Effect effect = new DamagePlayersEffect(2, TargetController.ANY);
effect.setText("it deals 2 damage to each player");
@ -88,30 +88,30 @@ public class AshcloudPhoenix extends CardImpl {
}
class AshcloudPhoenixEffect extends OneShotEffect {
AshcloudPhoenixEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "return it to the battlefield face down under your control";
}
AshcloudPhoenixEffect(final AshcloudPhoenixEffect effect) {
super(effect);
}
@Override
public AshcloudPhoenixEffect copy() {
return new AshcloudPhoenixEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
Player owner = game.getPlayer(card.getOwnerId());
if (owner != null && owner.getGraveyard().contains(card.getId())) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false, true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, true, false, null);
}
}
return true;

View file

@ -112,45 +112,41 @@ class KheruLichLordEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
for (Card card : controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game)) {
cards.add(card.getId());
}
if (cards.size() > 0) {
Card card = cards.getRandom(game);
controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), source.getSourceId(), source.getControllerId(), game));
Card card = cards.getRandom(game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
FixedTarget fixedTarget = new FixedTarget(permanent, game);
ContinuousEffect effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(TrampleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent.getId()));
effect.setTargetPointer(fixedTarget);
game.addEffect(effect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTarget(permanent.getId()));
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
KheruLichLordReplacementEffect replacementEffect = new KheruLichLordReplacementEffect();
replacementEffect.setTargetPointer(new FixedTarget(permanent.getId()));
KheruLichLordReplacementEffect replacementEffect = new KheruLichLordReplacementEffect();
replacementEffect.setTargetPointer(fixedTarget);
game.addEffect(replacementEffect, source);
}
}
return true;
}
return false;
}
}
@ -183,11 +179,11 @@ class KheruLichLordReplacementEffect extends ReplacementEffectImpl {
return true;
}
@Override
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE

View file

@ -46,19 +46,21 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* As Meandering Towershell returns to the battlefield because of the delayed triggered ability,
* you choose which opponent or opposing planeswalker its attacking. It doesnt have to attack
* the same opponent or opposing planeswalker that it was when it was exiled.
* As Meandering Towershell returns to the battlefield because of the delayed
* triggered ability, you choose which opponent or opposing planeswalker its
* attacking. It doesnt have to attack the same opponent or opposing
* planeswalker that it was when it was exiled.
*
* If Meandering Towershell enters the battlefield attacking, it wasnt declared as an attacking
* creature that turn. Abilities that trigger when a creature attacks, including its own triggered
* ability, wont trigger.
* If Meandering Towershell enters the battlefield attacking, it wasnt declared
* as an attacking creature that turn. Abilities that trigger when a creature
* attacks, including its own triggered ability, wont trigger.
*
* On the turn Meandering Towershell attacks and is exiled, raid abilities will see it as a creature
* that attacked. Conversely, on the turn Meandering Towershell enters the battlefield attacking,
* raid abilities will not.
* On the turn Meandering Towershell attacks and is exiled, raid abilities will
* see it as a creature that attacked. Conversely, on the turn Meandering
* Towershell enters the battlefield attacking, raid abilities will not.
*
* If you attack with a Meandering Towershell that you dont own, youll control it when it returns to the battlefield.
* If you attack with a Meandering Towershell that you dont own, youll control
* it when it returns to the battlefield.
*
* @author LevelX2
*/
@ -75,7 +77,7 @@ public class MeanderingTowershell extends CardImpl {
// Islandwalk
this.addAbility(new IslandwalkAbility());
// Whenever Meandering Towershell attacks, exile it.
// Whenever Meandering Towershell attacks, exile it.
// Return it to the battlefield under your control tapped and attacking
// at the beginning of the next declare attackers step on your next turn.
this.addAbility(new AttacksTriggeredAbility(new MeanderingTowershellEffect(), false));
@ -191,7 +193,7 @@ class MeanderingTowershellReturnEffect extends OneShotEffect {
if (controller != null) {
Card card = game.getCard(source.getSourceId());
if (card != null && game.getState().getZone(source.getSourceId()).equals(Zone.EXILED)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
game.getCombat().addAttackingCreature(card.getId(), game);
return true;
}

View file

@ -47,8 +47,6 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
* @author LevelX2
@ -59,15 +57,14 @@ public class SeeTheUnwritten extends CardImpl {
super(ownerId, 149, "See the Unwritten", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{4}{G}{G}");
this.expansionSetCode = "KTK";
// Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard.
// <i>Ferocious</i> - If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new SeeTheUnwrittenEffect(1),
new SeeTheUnwrittenEffect(2),
new SeeTheUnwrittenEffect(2),
new InvertCondition(FerociousCondition.getInstance()),
"Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard." +
"<br/><i>Ferocious</i> &mdash; If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one" ));
"Reveal the top eight cards of your library. You may put a creature card from among them onto the battlefield. Put the rest into your graveyard."
+ "<br/><i>Ferocious</i> &mdash; If you control a creature with power 4 or greater, you may put two creature cards onto the battlefield instead of one"));
}
public SeeTheUnwritten(final SeeTheUnwritten card) {
@ -89,9 +86,9 @@ class SeeTheUnwrittenEffect extends OneShotEffect {
public SeeTheUnwrittenEffect(int numberOfCardsToPutIntoPlay) {
super(Outcome.DrawCard);
this.numberOfCardsToPutIntoPlay = numberOfCardsToPutIntoPlay;
this.staticText = "Reveal the top eight cards of your library. You may put " +
(numberOfCardsToPutIntoPlay == 1 ? "a creature card":"two creature cards") +
" from among them onto the battlefield. Put the rest into your graveyard";
this.staticText = "Reveal the top eight cards of your library. You may put "
+ (numberOfCardsToPutIntoPlay == 1 ? "a creature card" : "two creature cards")
+ " from among them onto the battlefield. Put the rest into your graveyard";
}
public SeeTheUnwrittenEffect(final SeeTheUnwrittenEffect effect) {
@ -126,24 +123,24 @@ class SeeTheUnwrittenEffect extends OneShotEffect {
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
if (creatureCardsFound > 0 && controller.chooseUse(outcome, "Put creature(s) into play?", source, game)) {
int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound);
int cardsToChoose = Math.min(numberOfCardsToPutIntoPlay, creatureCardsFound);
TargetCard target = new TargetCard(cardsToChoose, cardsToChoose, Zone.LIBRARY, filter);
if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
for(UUID creatureId: target.getTargets()) {
for (UUID creatureId : target.getTargets()) {
Card card = game.getCard(creatureId);
if (card != null) {
cards.remove(card);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
}
controller.moveCards(cards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -128,7 +128,7 @@ class IncandescentSoulstokeEffect extends OneShotEffect {
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);

View file

@ -27,9 +27,7 @@
*/
package mage.sets.magic2010;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
@ -130,13 +128,12 @@ class HiveMindEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Spell spell;
spell = game.getStack().getSpell(((FixedTarget) getTargetPointer()).getTarget());
if (spell == null) { // if spell e.g. was countered
if (spell == null) { // if spell e.g. was countered
spell = (Spell) game.getLastKnownInformation(((FixedTarget) getTargetPointer()).getTarget(), Zone.STACK);
}
Player player = game.getPlayer(source.getControllerId());
if (spell != null && player != null) {
Set<UUID> players = player.getInRange();
for (UUID playerId : players) {
for (UUID playerId : game.getState().getPlayersInRange(player.getId(), game)) {
if (!playerId.equals(spell.getControllerId())) {
Spell copy = spell.copySpell();
copy.setControllerId(playerId);

View file

@ -27,18 +27,17 @@
*/
package mage.sets.magic2010;
import java.util.LinkedList;
import java.util.Set;
import java.util.LinkedHashSet;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -52,7 +51,6 @@ public class OpenTheVaults extends CardImpl {
super(ownerId, 21, "Open the Vaults", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{4}{W}{W}");
this.expansionSetCode = "M10";
// Return all artifact and enchantment cards from all graveyards to the battlefield under their owners' control.
this.getSpellAbility().addEffect(new OpenTheVaultsEffect());
}
@ -85,33 +83,21 @@ class OpenTheVaultsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
LinkedList<Card> enchantments = new LinkedList<Card>();
LinkedList<Card> artifacts = new LinkedList<Card>();
Set<UUID> playerIds = player.getInRange();
playerIds.add(player.getId());
for (UUID playerId : playerIds) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
LinkedHashSet<Card> cardsToReturn = new LinkedHashSet<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Cards graveyard = game.getPlayer(playerId).getGraveyard();
for (UUID cardId : graveyard) {
Card card = game.getCard(cardId);
if (card != null && card.getCardType().contains(CardType.ENCHANTMENT)) {
enchantments.add(card);
}
if (card != null && card.getCardType().contains(CardType.ARTIFACT)) {
artifacts.add(card);
if (card != null
&& (card.getCardType().contains(CardType.ENCHANTMENT) || card.getCardType().contains(CardType.ARTIFACT))) {
cardsToReturn.add(card);
}
}
}
for (Card card : enchantments) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), card.getOwnerId());
}
for (Card card : artifacts) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), card.getOwnerId());
}
controller.moveCards(cardsToReturn, Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
return false;
}

View file

@ -95,16 +95,16 @@ class SphinxAmbassadorEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && targetPlayer != null && sourcePermanent != null) {
if (controller != null && targetPlayer != null && sourcePermanent != null) {
TargetCardInLibrary target = new TargetCardInLibrary();
player.searchLibrary(target, game, targetPlayer.getId());
controller.searchLibrary(target, game, targetPlayer.getId());
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
TreeSet<String> choices = new TreeSet<String>();
TreeSet<String> choices = new TreeSet<>();
Collection<Card> cards = game.getCards();
for (Card gameCard : cards) {
if (gameCard.getOwnerId().equals(targetPlayer.getId())) {
@ -124,8 +124,8 @@ class SphinxAmbassadorEffect extends OneShotEffect {
game.informPlayers(new StringBuilder(sourcePermanent.getName()).append(", named card: [").append(cardName).append("]").toString());
if (!card.getName().equals(cardName) && card.getCardType().contains(CardType.CREATURE)) {
if (player.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
if (controller.chooseUse(outcome, new StringBuilder("Put ").append(card.getName()).append(" onto the battlefield?").toString(), source, game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -111,17 +111,17 @@ class CultivateEffect extends OneShotEffect {
controller.choose(Outcome.Benefit, revealed, target2, game);
Card card = revealed.get(target2.getFirstTarget(), game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
revealed.remove(card);
}
card = revealed.getCards(game).iterator().next();
if (card != null) {
controller.moveCards(card, null, Zone.HAND, source, game);
controller.moveCards(card, Zone.HAND, source, game);
}
} else if (target.getTargets().size() == 1) {
Card card = revealed.getCards(game).iterator().next();
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,12 +20,11 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.magic2011;
import java.util.UUID;
@ -86,7 +85,7 @@ public class NecroticPlague extends CardImpl {
Effect effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield);
effect.setText("Enchanted creature has \"At the beginning of your upkeep, sacrifice this creature.\"");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
this.addAbility(new DiesAttachedTriggeredAbility(new NecroticPlagueEffect(),"enchanted creature", false));
this.addAbility(new DiesAttachedTriggeredAbility(new NecroticPlagueEffect(), "enchanted creature", false));
}
@ -94,7 +93,7 @@ public class NecroticPlague extends CardImpl {
public void adjustTargets(Ability ability, Game game) {
if (ability instanceof DiesAttachedTriggeredAbility) {
Permanent attachedTo = null;
for (Effect effect :ability.getEffects()) {
for (Effect effect : ability.getEffects()) {
attachedTo = (Permanent) effect.getValue("attachedTo");
}
if (attachedTo != null) {
@ -122,8 +121,6 @@ public class NecroticPlague extends CardImpl {
class NecroticPlagueEffect extends OneShotEffect {
public NecroticPlagueEffect() {
super(Outcome.PutCardInPlay);
staticText = "its controller chooses target creature one of his or her opponents controls. Return {this} from its owner's graveyard to the battlefield attached to that creature";
@ -143,7 +140,7 @@ class NecroticPlagueEffect extends OneShotEffect {
Permanent creature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
if (sourceEnchantmentCard != null && creature != null) {
game.getState().setValue("attachTo:" + sourceEnchantmentCard.getId(), creature);
creatureController.putOntoBattlefieldWithInfo(sourceEnchantmentCard, game, Zone.GRAVEYARD, source.getSourceId());
creatureController.moveCards(sourceEnchantmentCard, Zone.BATTLEFIELD, source, game);
return creature.addAttachment(sourceEnchantmentCard.getId(), game);
}
}

View file

@ -97,8 +97,8 @@ class BoonweaverGiantEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
@ -108,18 +108,18 @@ class BoonweaverGiantEffect extends OneShotEffect {
Card card = null;
Zone zone = null;
if (player.chooseUse(Outcome.Neutral, "Search your graveyard for an Aura card?", source, game)) {
if (controller.chooseUse(Outcome.Neutral, "Search your graveyard for an Aura card?", source, game)) {
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(filter);
if (player.choose(Outcome.PutCardInPlay, player.getGraveyard(), target, game)) {
if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) {
card = game.getCard(target.getFirstTarget());
if (card != null) {
zone = Zone.GRAVEYARD;
}
}
}
if (card == null && player.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", source, game)) {
if (card == null && controller.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", source, game)) {
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.PutCardInPlay, player.getHand(), target, game)) {
if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
card = game.getCard(target.getFirstTarget());
if (card != null) {
zone = Zone.HAND;
@ -128,13 +128,13 @@ class BoonweaverGiantEffect extends OneShotEffect {
}
if (card == null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
card = game.getCard(target.getFirstTarget());
if (card != null) {
zone = Zone.LIBRARY;
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
}
// aura card found - attach it
if (card != null) {
@ -142,7 +142,7 @@ class BoonweaverGiantEffect extends OneShotEffect {
if (permanent != null) {
game.getState().setValue("attachTo:" + card.getId(), permanent);
}
player.putOntoBattlefieldWithInfo(card, game, zone, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (permanent != null) {
return permanent.addAttachment(card.getId(), game);
}

View file

@ -132,10 +132,10 @@ class JaliraMasterPolymorphistEffect extends OneShotEffect {
} while (library.size() > 0 && card != null && !filter.match(card, game));
// reveal cards
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
controller.revealCards(sourceObject.getIdName(), cards, game);
}
// put nonlegendary creature card to battlefield
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
// remove it from revealed card list
cards.remove(card);
// Put the rest on the bottom of your library in a random order

View file

@ -51,6 +51,7 @@ import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.players.Player;
import mage.target.TargetPermanent;
@ -121,26 +122,30 @@ class NissaWorldwakerSearchEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterBasicLandCard());
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
Card card = controller.getLibrary().getCard(cardId, game);
if (card != null) {
if (player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) {
ContinuousEffect effect = new BecomesCreatureTargetEffect(new NissaWorldwakerToken(), false, true, Duration.Custom);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent land = game.getPermanent(card.getId());
if (land != null) {
ContinuousEffect effect = new BecomesCreatureTargetEffect(new NissaWorldwakerToken(), false, true, Duration.Custom);
effect.setTargetPointer(new FixedTarget(land, game));
game.addEffect(effect, source);
}
}
}
}
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
}

View file

@ -35,7 +35,6 @@ import mage.abilities.costs.common.PutCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -86,40 +85,36 @@ public class YisanTheWandererBard extends CardImpl {
}
class YisanTheWandererBardEffect extends OneShotEffect {
public YisanTheWandererBardEffect() {
super(Outcome.Benefit);
this.staticText = "Search your library for a creature card with converted mana cost equal to the number of verse counters on {this}, put it onto the battlefield, then shuffle your library";
}
public YisanTheWandererBardEffect(final YisanTheWandererBardEffect effect) {
super(effect);
}
@Override
public YisanTheWandererBardEffect copy() {
return new YisanTheWandererBardEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null && player != null) {
if (sourcePermanent != null && controller != null) {
int newConvertedCost = sourcePermanent.getCounters().getCount("verse");
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.add(new CardTypePredicate(CardType.CREATURE));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
}
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -113,8 +113,8 @@ class NissasPilgrimageEffect extends OneShotEffect {
Card card = cards.getRandom(game);
if (card != null) {
cards.remove(card);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
controller.moveCards(cards, Zone.LIBRARY, Zone.HAND, source, game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.moveCards(cards, Zone.HAND, source, game);
}
}
}

View file

@ -36,8 +36,9 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -92,63 +93,62 @@ class TheGreatAuroraEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Map<UUID, List<Permanent>> permanentsOwned = new HashMap<>();
Collection<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
for (Permanent permanent : permanents) {
List<Permanent> list = permanentsOwned.get(permanent.getOwnerId());
if (list == null) {
list = new ArrayList<>();
permanentsOwned.put(permanent.getOwnerId(), list);
}
list.add(permanent);
}
// shuffle permanents and hand cards into owner's library
Map<UUID, Integer> permanentsCount = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int handCards = player.getHand().size();
player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game);
List<Permanent> list = permanentsOwned.remove(player.getId());
permanentsCount.put(playerId, handCards + (list != null ? list.size() : 0));
for (Permanent permanent : list) {
player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true);
Map<UUID, List<Permanent>> permanentsOwned = new HashMap<>();
Collection<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
for (Permanent permanent : permanents) {
List<Permanent> list = permanentsOwned.get(permanent.getOwnerId());
if (list == null) {
list = new ArrayList<>();
permanentsOwned.put(permanent.getOwnerId(), list);
}
player.shuffleLibrary(game);
list.add(permanent);
}
}
game.applyEffects(); // so effects from creatures that were on the battlefield won't trigger from draw or put into play
// shuffle permanents and hand cards into owner's library
Map<UUID, Integer> permanentsCount = new HashMap<>();
// Draw cards
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int count = permanentsCount.get(playerId);
if (count > 0) {
player.drawCards(count, game);
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int handCards = player.getHand().size();
player.moveCards(player.getHand(), Zone.HAND, Zone.LIBRARY, source, game);
List<Permanent> list = permanentsOwned.remove(player.getId());
permanentsCount.put(playerId, handCards + (list != null ? list.size() : 0));
for (Permanent permanent : list) {
player.moveCardToLibraryWithInfo(permanent, source.getSourceId(), game, Zone.BATTLEFIELD, true, true);
}
player.shuffleLibrary(game);
}
}
}
// put lands onto the battlefield
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetCard target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterLandCard("put any number of land cards from your hand onto the battlefield"));
player.chooseTarget(Outcome.PutLandInPlay, player.getHand(), target, source, game);
for (UUID cardId : target.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), false);
game.applyEffects(); // so effects from creatures that were on the battlefield won't trigger from draw or put into play
// Draw cards
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int count = permanentsCount.get(playerId);
if (count > 0) {
player.drawCards(count, game);
}
}
}
// put lands onto the battlefield
Cards toBattlefield = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
TargetCard target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterLandCard("put any number of land cards from your hand onto the battlefield"));
player.chooseTarget(Outcome.PutLandInPlay, player.getHand(), target, source, game);
toBattlefield.addAll(target.getTargets());
}
}
return controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
}
return true;
return false;
}
}

View file

@ -78,6 +78,7 @@ public class WoodlandBellower extends CardImpl {
}
class WoodlandBellowerEffect extends OneShotEffect {
WoodlandBellowerEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Search your library for a nonlegendary green creature card with converted mana cost 3 or less, put it onto the battlefield, then shuffle your library";
@ -89,27 +90,25 @@ class WoodlandBellowerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
FilterCard filter = new FilterCard("nonlegendary green creature card with converted mana cost 3 or less");
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(Predicates.not(new SupertypePredicate("Legendary")));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 4));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}
@ -118,4 +117,4 @@ class WoodlandBellowerEffect extends OneShotEffect {
return new WoodlandBellowerEffect(this);
}
}
}

View file

@ -35,7 +35,6 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -109,8 +108,7 @@ class MagisterOfWorthVoteEffect extends OneShotEffect {
if (player.chooseUse(Outcome.DestroyPermanent, "Choose grace?", source, game)) {
graceCount++;
game.informPlayers(player.getLogName() + " has chosen: grace");
}
else {
} else {
condemnationCount++;
game.informPlayers(player.getLogName() + " has chosen: condemnation");
}
@ -130,7 +128,7 @@ class MagisterOfWorthVoteEffect extends OneShotEffect {
class MagisterOfWorthDestroyEffect extends OneShotEffect {
private static final FilterPermanent filter = new FilterCreaturePermanent("creatures other than {this}");
static {
filter.add(new AnotherPredicate());
}
@ -175,12 +173,10 @@ class MagisterOfWorthReturnFromGraveyardEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
for (UUID playerId: controller.getInRange()) {
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
}
player.moveCards(player.getGraveyard().getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game);
}
}
return true;
@ -193,4 +189,4 @@ class MagisterOfWorthReturnFromGraveyardEffect extends OneShotEffect {
return new MagisterOfWorthReturnFromGraveyardEffect(this);
}
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.sets.mercadianmasques;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -91,13 +90,8 @@ class BriberyEffect extends OneShotEffect {
if (controller != null && opponent != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, new FilterCreatureCard("creature card"));
if (controller.searchLibrary(target, game, opponent.getId())) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = opponent.getLibrary().getCard(targetId, game);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
}
Card card = opponent.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
opponent.shuffleLibrary(game);
return true;

View file

@ -100,7 +100,7 @@ class ShallowGraveEffect extends OneShotEffect {
}
}
if (lastCreatureCard != null) {
if (controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId())) {
if (controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game)) {
Permanent returnedCreature = game.getPermanent(lastCreatureCard.getId());
if (returnedCreature != null) {
FixedTarget fixedTarget = new FixedTarget(returnedCreature, game);

View file

@ -158,8 +158,7 @@ class ScytheOfTheWretchedReanimateEffect extends OneShotEffect {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
Zone currentZone = game.getState().getZone(card.getId());
controller.putOntoBattlefieldWithInfo(card, game, currentZone, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Effect effect = new AttachEffect(Outcome.AddAbility);
effect.setTargetPointer(new FixedTarget(card.getId()));
effect.apply(game, source);

View file

@ -25,18 +25,18 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ShuffleSpellEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterCard;
@ -47,8 +47,6 @@ import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
* @author Loki
*/
@ -77,6 +75,7 @@ public class GreenSunsZenith extends CardImpl {
}
class GreenSunsZenithSearchEffect extends OneShotEffect {
GreenSunsZenithSearchEffect() {
super(Outcome.PutCreatureInPlay);
staticText = "Search your library for a green creature card with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
@ -88,28 +87,28 @@ class GreenSunsZenithSearchEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
//Set the mana cost one higher to 'emulate' a less than or equal to comparison.
int xValue = source.getManaCostsToPay().getX() + 1;
FilterCard filter = new FilterCard("green creature card with converted mana cost " + xValue + " or less");
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new CardTypePredicate(CardType.CREATURE));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, xValue));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}

View file

@ -33,8 +33,8 @@ import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.abilities.keyword.EntwineAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -102,13 +102,8 @@ class ToothAndNailPutCreatureOnBattlefieldEffect extends OneShotEffect {
TargetCardInHand target = new TargetCardInHand(0, 2, new FilterCreatureCard("creature cards"));
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Card card = game.getCard(targetId);
if (card != null) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId(), false);
}
}
return true;
return controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return false;
}

View file

@ -27,16 +27,14 @@
*/
package mage.sets.morningtide;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterLandCard;
@ -56,7 +54,6 @@ public class Scapeshift extends CardImpl {
super(ownerId, 136, "Scapeshift", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{G}{G}");
this.expansionSetCode = "MOR";
// Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library.
this.getSpellAbility().addEffect(new ScapeshiftEffect());
}
@ -71,12 +68,11 @@ public class Scapeshift extends CardImpl {
}
}
class ScapeshiftEffect extends OneShotEffect {
public ScapeshiftEffect() {
super(Outcome.Neutral);
staticText = "Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library";
staticText = "Sacrifice any number of lands. Search your library for that many land cards, put them onto the battlefield tapped, then shuffle your library";
}
public ScapeshiftEffect(final ScapeshiftEffect effect) {
@ -90,35 +86,29 @@ class ScapeshiftEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null){
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int amount = 0;
TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
if(player.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)){
for(Object uuid : sacrificeLand.getTargets()){
Permanent land = game.getPermanent((UUID)uuid);
if(land != null){
if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
for (Object uuid : sacrificeLand.getTargets()) {
Permanent land = game.getPermanent((UUID) uuid);
if (land != null) {
land.sacrifice(source.getSourceId(), game);
amount++;
}
}
}
TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
for (UUID cardId: (List<UUID>)target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getControllerId(), true);
}
}
}
player.shuffleLibrary(game);
if (controller.searchLibrary(target, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game),
Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}

View file

@ -59,16 +59,16 @@ import mage.target.common.TargetCardInYourGraveyard;
* @author fireshoes
*/
public class LinSivviDefiantHero extends CardImpl {
private static final FilterCard filter = new FilterCard("Rebel card from your graveyard");
static {
filter.add(new OwnerPredicate(TargetController.YOU));
filter.add(new SubtypePredicate("Rebel"));
}
static final String rule = "Put target Rebel card from your graveyard on the bottom of your library";
public LinSivviDefiantHero(UUID ownerId) {
super(ownerId, 12, "Lin Sivvi, Defiant Hero", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{W}{W}");
this.expansionSetCode = "NMS";
@ -84,7 +84,7 @@ public class LinSivviDefiantHero extends CardImpl {
new ManaCostsImpl("{X}"));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
// {3}: Put target Rebel card from your graveyard on the bottom of your library.
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOnLibraryTargetEffect(false, rule), new GenericManaCost(3));
ability.addTarget(new TargetCardInYourGraveyard(1, filter));
@ -119,8 +119,8 @@ class LinSivviDefiantHeroEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
@ -131,15 +131,15 @@ class LinSivviDefiantHeroEffect extends OneShotEffect {
filter.add(new SubtypePredicate("Rebel"));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}
}
}

View file

@ -28,9 +28,6 @@
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.costs.Cost;
@ -40,7 +37,9 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterCard;
@ -61,7 +60,6 @@ public class BirthingPod extends CardImpl {
super(ownerId, 104, "Birthing Pod", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}{GP}");
this.expansionSetCode = "NPH";
// {1}{GP}, {tap}, Sacrifice a creature: Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card onto the battlefield, then shuffle your library. Activate this ability only any time you could cast a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new BirthingPodEffect(), new ManaCostsImpl("{1}{GP}"));
ability.addCost(new TapSourceCost());
@ -80,6 +78,7 @@ public class BirthingPod extends CardImpl {
}
class BirthingPodEffect extends OneShotEffect {
BirthingPodEffect() {
super(Outcome.Benefit);
staticText = "Search your library for a creature card with converted mana cost equal to 1 plus the sacrificed creature's converted mana cost, put that card onto the battlefield, then shuffle your library";
@ -101,22 +100,18 @@ class BirthingPodEffect extends OneShotEffect {
break;
}
}
Player player = game.getPlayer(source.getControllerId());
if (sacrificedPermanent != null && player != null) {
Player controller = game.getPlayer(source.getControllerId());
if (sacrificedPermanent != null && controller != null) {
int newConvertedCost = sacrificedPermanent.getManaCost().convertedManaCost() + 1;
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.add(new CardTypePredicate(CardType.CREATURE));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
for (UUID cardId : target.getTargets()) {
Card card = player.getLibrary().getCard(cardId, game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
}
}
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -29,13 +29,6 @@ package mage.sets.newphyrexia;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -43,6 +36,13 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
@ -63,7 +63,6 @@ public class MeliraSylvokOutcast extends CardImpl {
this.subtype.add("Human");
this.subtype.add("Scout");
this.power = new MageInt(2);
this.toughness = new MageInt(2);
@ -113,7 +112,7 @@ class MeliraSylvokOutcastEffect extends ReplacementEffectImpl {
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ADD_COUNTER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getData().equals(CounterType.POISON.getName()) && event.getTargetId().equals(source.getControllerId());
@ -141,16 +140,19 @@ class MeliraSylvokOutcastEffect2 extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.ADD_COUNTER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.M1M1.getName())) {
Permanent perm = game.getPermanent(event.getTargetId());
if (perm == null) {
perm = game.getPermanentEntering(event.getTargetId());
}
if (perm != null && perm.getCardType().contains(CardType.CREATURE) && perm.getControllerId().equals(source.getControllerId())) {
return true;
}
@ -181,7 +183,7 @@ class MeliraSylvokOutcastEffect3 extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Set<UUID> opponents = game.getOpponents(source.getControllerId());
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (opponents.contains(perm.getControllerId())) {
perm.getAbilities().remove(InfectAbility.getInstance());
}

View file

@ -29,6 +29,7 @@ package mage.sets.odyssey;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -36,7 +37,6 @@ import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -94,25 +94,23 @@ class ZoologistEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("Zoologist", cards, game);
if (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().getFromTop(game);
controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
if (card != null) {
if (card.getCardType().contains(CardType.CREATURE)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
} else {
player.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}
return false;
return true;
}
}

View file

@ -35,7 +35,6 @@ import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
@ -78,7 +77,7 @@ class PatriarchsBiddingEffect extends OneShotEffect {
public PatriarchsBiddingEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield.";
this.staticText = "each player chooses a creature type. Each player returns all creature cards of a type chosen this way from his or her graveyard to the battlefield";
}
public PatriarchsBiddingEffect(final PatriarchsBiddingEffect effect) {
@ -91,12 +90,12 @@ class PatriarchsBiddingEffect extends OneShotEffect {
}
@Override
public boolean apply(Game game, Ability ability) {
Player controller = game.getPlayer(ability.getControllerId());
MageObject sourceObject = game.getObject(ability.getSourceId());
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null) {
Set<String> chosenTypes = new HashSet<>();
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceImpl(true);
typeChoice.setMessage("Choose a creature type");
@ -108,24 +107,21 @@ class PatriarchsBiddingEffect extends OneShotEffect {
}
String chosenType = typeChoice.getChoice();
if (chosenType != null) {
game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has chosen " + chosenType);
game.informPlayers(sourceObject.getLogName() + ": " + player.getLogName() + " has chosen " + chosenType);
chosenTypes.add(chosenType);
}
}
List<SubtypePredicate> predicates = new ArrayList<>();
for (String type : chosenTypes) {
predicates.add(new SubtypePredicate(type));
}
FilterCard filter = new FilterCreatureCard();
filter.add(Predicates.or(predicates));
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(filter, game)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, ability.getSourceId());
}
player.moveCards(player.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game);
}
}
return true;

View file

@ -29,6 +29,7 @@ package mage.sets.onslaught;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
@ -79,47 +80,46 @@ public class RiptideShapeshifter extends CardImpl {
}
class RiptideShapeshifterEffect extends OneShotEffect {
RiptideShapeshifterEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "Choose a creature type. Reveal cards from the top of your library until you reveal a creature card of that type. Put that card onto the battlefield and shuffle the rest into your library";
}
RiptideShapeshifterEffect(final RiptideShapeshifterEffect effect) {
super(effect);
}
@Override
public RiptideShapeshifterEffect copy() {
return new RiptideShapeshifterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose a creature type:");
choice.setChoices(CardRepository.instance.getCreatureTypes());
while (!player.choose(Outcome.BoostCreature, choice, game)) {
if (!player.canRespond()) {
while (!controller.choose(Outcome.BoostCreature, choice, game)) {
if (!controller.canRespond()) {
return false;
}
}
Cards revealedCards = new CardsImpl();
while (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card.getCardType().contains(CardType.CREATURE) && card.getSubtype().contains(choice.getChoice())) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
player.revealCards("Riptide Shapeshifter", revealedCards, game);
for (Card card: revealedCards.getCards(game)) {
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
player.shuffleLibrary(game);
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -43,7 +43,7 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.BlockedByIdPredicate;
@ -101,7 +101,7 @@ public class SistersOfStoneDeath extends CardImpl {
class SistersOfStoneDeathEffect extends OneShotEffect {
private UUID exileId;
private final UUID exileId;
public SistersOfStoneDeathEffect(UUID exileId) {
super(Outcome.PutCreatureInPlay);
@ -117,7 +117,7 @@ class SistersOfStoneDeathEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
CardsImpl cardsInExile = new CardsImpl();
TargetCard target = new TargetCard(Zone.PICK, new FilterCard());
TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ExileZone exile = game.getExile().getExileZone(exileId);
@ -129,7 +129,7 @@ class SistersOfStoneDeathEffect extends OneShotEffect {
}
if (controller.choose(Outcome.PutCreatureInPlay, cardsInExile, target, game)) {
Card chosenCard = game.getCard(target.getFirstTarget());
return controller.moveCards(chosenCard, Zone.EXILED, source, game);
return controller.moveCards(chosenCard, Zone.BATTLEFIELD, source, game);
}
}
}

View file

@ -40,7 +40,6 @@ import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.EntersTheBattlefieldEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
@ -96,7 +95,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = ((EntersTheBattlefieldEvent) event).getTarget();
permanent = game.getPermanentEntering(event.getTargetId());
}
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(event.getAmount() * 2), game, event.getAppliedEffects());
@ -112,7 +111,7 @@ class CorpsejackMenaceReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.P1P1.getName())) {
Permanent permanent = ((EntersTheBattlefieldEvent) event).getTarget();
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}

View file

@ -195,7 +195,7 @@ class VolatileRigEffect2 extends OneShotEffect {
for (Permanent permanent: permanents) {
permanent.damage(4, source.getSourceId(), game, false, true);
}
for (UUID playerId: player.getInRange()) {
for (UUID playerId: game.getState().getPlayersInRange(player.getId(), game)) {
Player damageToPlayer = game.getPlayer(playerId);
if (damageToPlayer != null) {
damageToPlayer.damage(4, source.getSourceId(), game, false, true);

View file

@ -46,7 +46,7 @@ import mage.target.common.TargetCardInLibrary;
/**
*
* @author jeffwadsworth
*
*/
public class EnduringIdeal extends CardImpl {
@ -54,13 +54,12 @@ public class EnduringIdeal extends CardImpl {
super(ownerId, 9, "Enduring Ideal", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{5}{W}{W}");
this.expansionSetCode = "SOK";
// Search your library for an enchantment card and put it onto the battlefield. Then shuffle your library.
this.getSpellAbility().addEffect(new EnduringIdealEffect());
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
}
public EnduringIdeal(final EnduringIdeal card) {
@ -74,9 +73,9 @@ public class EnduringIdeal extends CardImpl {
}
class EnduringIdealEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard();
static {
filter.add(new CardTypePredicate(CardType.ENCHANTMENT));
}
@ -93,16 +92,16 @@ class EnduringIdealEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
you.searchLibrary(target, game);
controller.searchLibrary(target, game);
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard == null) {
applied = false;
} else{
applied = you.putOntoBattlefieldWithInfo(targetCard, game, Zone.LIBRARY, source.getSourceId());
you.shuffleLibrary(game);
} else {
applied = controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game);
controller.shuffleLibrary(game);
}
}
return applied;

View file

@ -56,12 +56,11 @@ public class EternalDominion extends CardImpl {
super(ownerId, 36, "Eternal Dominion", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{7}{U}{U}{U}");
this.expansionSetCode = "SOK";
// Search target opponent's library for an artifact, creature, enchantment, or land card.
// Put that card onto the battlefield under your control. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new EternalDominionEffect());
this.getSpellAbility().addTarget(new TargetOpponent());
// Epic
this.getSpellAbility().addEffect(new EpicEffect());
@ -78,9 +77,9 @@ public class EternalDominion extends CardImpl {
}
class EternalDominionEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("an artifact, creature, enchantment, or land card");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE),
@ -101,13 +100,13 @@ class EternalDominionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
boolean applied = false;
Player opponent = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (opponent != null && you != null) {
Player controller = game.getPlayer(source.getControllerId());
if (opponent != null && controller != null) {
TargetCardInLibrary target = new TargetCardInLibrary(filter);
you.searchLibrary(target, game, opponent.getId());
controller.searchLibrary(target, game, opponent.getId());
Card targetCard = game.getCard(target.getFirstTarget());
if (targetCard != null) {
applied = you.putOntoBattlefieldWithInfo(targetCard, game, Zone.LIBRARY, source.getSourceId());
applied = controller.moveCards(targetCard, Zone.BATTLEFIELD, source, game);
}
opponent.shuffleLibrary(game);
}

View file

@ -28,7 +28,6 @@
package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -37,7 +36,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -93,7 +95,7 @@ class FootstepsOfTheGoryoEffect extends OneShotEffect {
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
// Sacrifice it at end of turn
@ -104,11 +106,10 @@ class FootstepsOfTheGoryoEffect extends OneShotEffect {
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
return true;
}
}
}
return true;
}
return false;
}

View file

@ -117,7 +117,7 @@ class ImpromptuRaidEffect extends OneShotEffect {
controller.moveCards(card, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
return true;
}
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);

View file

@ -116,16 +116,16 @@ class PuppeteerCliqueEffect extends OneShotEffect {
boolean result = false;
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
if (you.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
hasteEffect.setTargetPointer(new FixedTarget(permanent.getId()));
hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(hasteEffect, source);
ExileTargetEffect exileEffect = new ExileTargetEffect("exile " + permanent.getLogName());
exileEffect.setTargetPointer(new FixedTarget(card.getId()));
exileEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect, TargetController.YOU);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());

View file

@ -107,8 +107,8 @@ class TezzeretTheSeekerEffect2 extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
@ -123,15 +123,15 @@ class TezzeretTheSeekerEffect2 extends OneShotEffect {
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, cmc + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return false;
}
}

View file

@ -45,6 +45,7 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
@ -58,7 +59,6 @@ public class CorpseDance extends CardImpl {
super(ownerId, 10, "Corpse Dance", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{B}");
this.expansionSetCode = "TMP";
// Buyback {2}
this.addAbility(new BuybackAbility("{2}"));
@ -97,26 +97,29 @@ class CorpseDanceEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card lastCreatureCard = null;
for (Card card :controller.getGraveyard().getCards(game)) {
for (Card card : controller.getGraveyard().getCards(game)) {
if (card.getCardType().contains(CardType.CREATURE)) {
lastCreatureCard = card;
}
}
if (lastCreatureCard != null) {
if (controller.putOntoBattlefieldWithInfo(lastCreatureCard, game, Zone.GRAVEYARD, source.getSourceId())) {
FixedTarget fixedTarget = new FixedTarget(lastCreatureCard.getId());
// Gains Haste
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
hasteEffect.setTargetPointer(fixedTarget);
game.addEffect(hasteEffect, source);
// Exile it at end of turn
ExileTargetEffect exileEffect = new ExileTargetEffect(null,"",Zone.BATTLEFIELD);
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
if (controller.moveCards(lastCreatureCard, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(lastCreatureCard.getId());
if (creature != null) {
FixedTarget fixedTarget = new FixedTarget(creature, game);
// Gains Haste
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
hasteEffect.setTargetPointer(fixedTarget);
game.addEffect(hasteEffect, source);
// Exile it at end of turn
ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
exileEffect.setTargetPointer(fixedTarget);
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
}
}
}
return true;

View file

@ -27,6 +27,9 @@
*/
package mage.sets.tempest;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -39,7 +42,6 @@ import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -89,27 +91,31 @@ class LivingDeathEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Map<UUID, Set<Card>> exiledCards = new HashMap<>();
// move creature cards from graveyard to exile
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
Set<Card> cardsPlayer = player.getGraveyard().getCards(new FilterCreatureCard(), game);
if (!cardsPlayer.isEmpty()) {
exiledCards.put(player.getId(), cardsPlayer);
player.moveCards(cardsPlayer, Zone.EXILED, source, game);
}
}
}
game.applyEffects();
// sacrifice all creatures
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), game)) {
permanent.sacrifice(source.getSourceId(), game);
}
game.applyEffects();
// put exiled cards to battlefield
ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId());
if (exileZone != null) {
for (Card card : exileZone.getCards(game)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCards(card, Zone.EXILED, source, game);
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<Card> cardsPlayer = exiledCards.get(playerId);
if (cardsPlayer != null && !cardsPlayer.isEmpty()) {
player.moveCards(cardsPlayer, Zone.BATTLEFIELD, source, game, false, false, false, null);
}
}
}

View file

@ -28,12 +28,12 @@
package mage.sets.tempest;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
@ -49,6 +49,8 @@ public class StaunchDefenders extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// When Staunch Defenders enters the battlefield, you gain 4 life.
this.addAbility(new EntersBattlefieldTriggeredAbility(new GainLifeEffect(4), false));
}

View file

@ -76,35 +76,35 @@ public class AcademyResearchers extends CardImpl {
}
class AcademyResearchersEffect extends OneShotEffect {
AcademyResearchersEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "you may put an Aura card from your hand onto the battlefield attached to {this}.";
}
AcademyResearchersEffect(final AcademyResearchersEffect effect) {
super(effect);
}
@Override
public AcademyResearchersEffect copy() {
return new AcademyResearchersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null){
if (controller != null && permanent != null) {
FilterCard filter = new FilterCard();
filter.add(new SubtypePredicate("Aura"));
filter.add(new AuraCardCanAttachToPermanentId(permanent.getId()));
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (player.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
if (controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Card auraInHand = game.getCard(target.getFirstTarget());
if (auraInHand != null) {
game.getState().setValue("attachTo:" + auraInHand.getId(), permanent);
if (player.putOntoBattlefieldWithInfo(auraInHand, game, Zone.HAND, source.getSourceId())) {
if (controller.moveCards(auraInHand, Zone.BATTLEFIELD, source, game)) {
permanent.addAttachment(auraInHand.getId(), game);
}
}

View file

@ -167,16 +167,14 @@ class AshiokNightmareWeaverPutIntoPlayEffect extends OneShotEffect {
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
if (controller.chooseTarget(Outcome.PutCreatureInPlay, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null && controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) {
// why is this change of controller neccessary?
if (card != null
&& controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.changeControllerId(source.getControllerId(), game);
ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
return true;
}
}

View file

@ -39,6 +39,8 @@ import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
@ -161,8 +163,8 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
} else {
return true;
}
for (UUID playerId : controller.getInRange()) {
Cards cardsToBringIntoPlay = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
String exileKey = playerId.toString() + CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()).toString();
@ -173,13 +175,14 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
for (Card card : exileZone.getCards(game)) {
card.setFaceDown(false, game);
if (CardUtil.isPermanentCard(card)) {
player.moveCards(card, Zone.EXILED, source, game);
cardsToBringIntoPlay.add(card);
}
}
}
}
}
}
controller.moveCards(cardsToBringIntoPlay.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
return true;
}
return false;

View file

@ -115,19 +115,22 @@ class WhipOfErebosEffect extends OneShotEffect {
Card card = game.getCard(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && card != null) {
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId())) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
// gains haste
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
// Exile at begin of next end step
ExileTargetEffect exileEffect = new ExileTargetEffect(null, null, Zone.BATTLEFIELD);
exileEffect.setTargetPointer(new FixedTarget(creature, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect);
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
game.addDelayedTriggeredAbility(delayedAbility);
}
}
return true;
}

View file

@ -38,7 +38,6 @@ import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
@ -179,28 +178,19 @@ class XenagosExileEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cards cards = new CardsImpl(Zone.EXILED);
int count = Math.min(player.getLibrary().size(), 7);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().getFromTop(game);
cards.add(card);
card.moveToExile(null, null, source.getSourceId(), game);
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards exiledCards = new CardsImpl();
exiledCards.addAll(controller.getLibrary().getTopCards(game, 7));
controller.moveCards(exiledCards, Zone.EXILED, source, game);
FilterCard filter = new FilterCard("creature and/or land cards to put onto the battlefield");
filter.add(Predicates.or(new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.LAND)));
TargetCard target1 = new TargetCard(0, Integer.MAX_VALUE, Zone.EXILED, filter);
if (cards.size() > 0
if (exiledCards.size() > 0
&& target1.canChoose(source.getSourceId(), source.getControllerId(), game)
&& player.choose(Outcome.PutCardInPlay, cards, target1, game)) {
for (UUID targetId : target1.getTargets()) {
Card card = cards.get(targetId, game);
if (card != null) {
player.moveCards(card, Zone.EXILED, source, game);
}
}
&& controller.choose(Outcome.PutCardInPlay, exiledCards, target1, game)) {
controller.moveCards(new CardsImpl(target1.getTargets()), Zone.BATTLEFIELD, source, game);
}
return true;
}

View file

@ -27,6 +27,9 @@
*/
package mage.sets.timespiral;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
@ -41,7 +44,6 @@ import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -97,12 +99,15 @@ class LivingEndEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Map<UUID, Set<Card>> exiledCards = new HashMap<>();
// move creature cards from graveyard to exile
for (UUID playerId : controller.getInRange()) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
for (Card card : player.getGraveyard().getCards(new FilterCreatureCard(), game)) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.GRAVEYARD, true);
Set<Card> cardsPlayer = player.getGraveyard().getCards(new FilterCreatureCard(), game);
if (!cardsPlayer.isEmpty()) {
exiledCards.put(player.getId(), cardsPlayer);
player.moveCards(cardsPlayer, Zone.EXILED, source, game);
}
}
}
@ -111,12 +116,12 @@ class LivingEndEffect extends OneShotEffect {
permanent.sacrifice(source.getSourceId(), game);
}
// put exiled cards to battlefield
ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId());
if (exileZone != null) {
for (Card card : exileZone.getCards(game)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCards(card, Zone.EXILED, source, game);
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
Set<Card> cardsPlayer = exiledCards.get(playerId);
if (cardsPlayer != null && !cardsPlayer.isEmpty()) {
player.moveCards(cardsPlayer, Zone.BATTLEFIELD, source, game, false, false, false, null);
}
}
}

View file

@ -77,8 +77,6 @@ public class Gamekeeper extends CardImpl {
class GamekeeperEffect extends OneShotEffect {
public GamekeeperEffect() {
super(Outcome.Benefit);
staticText = "reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and put all other cards revealed this way into your graveyard";
@ -98,15 +96,13 @@ class GamekeeperEffect extends OneShotEffect {
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card.getCardType().contains(CardType.CREATURE)) {
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
controller.revealCards("Gamekeeper", revealedCards, game);
for (Card card: revealedCards.getCards(game)) {
card.moveToZone(Zone.GRAVEYARD, source.getSourceId(), game, true);
}
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.GRAVEYARD, source, game);
return true;
}
return false;
@ -116,4 +112,4 @@ class GamekeeperEffect extends OneShotEffect {
public GamekeeperEffect copy() {
return new GamekeeperEffect(this);
}
}
}

Some files were not shown because too many files have changed in this diff Show more