* Changed some more card movement handling.

This commit is contained in:
LevelX2 2015-10-22 23:02:07 +02:00
parent ff71654a5f
commit 92bcd0d522
17 changed files with 197 additions and 224 deletions

View file

@ -27,8 +27,8 @@
*/
package mage.sets.scarsofmirrodin;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
@ -38,7 +38,9 @@ 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;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
@ -46,9 +48,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.List;
import java.util.UUID;
/**
* @author nantuko
*/
@ -161,19 +160,22 @@ class CloneShellDiesEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent != null) {
List<UUID> imprinted = permanent.getImprinted();
if (imprinted.size() > 0) {
Card imprintedCard = game.getCard(imprinted.get(0));
imprintedCard.setFaceDown(false, game);
if (imprintedCard.getCardType().contains(CardType.CREATURE)) {
imprintedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent != null) {
List<UUID> imprinted = permanent.getImprinted();
if (imprinted.size() > 0) {
Card imprintedCard = game.getCard(imprinted.get(0));
imprintedCard.setFaceDown(false, game);
if (imprintedCard.getCardType().contains(CardType.CREATURE)) {
controller.moveCards(imprintedCard, Zone.BATTLEFIELD, source, game);
}
}
}
return true;
}
return true;
return false;
}
@Override

View file

@ -25,14 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -41,6 +36,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.IntimidateAbility;
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;
import mage.filter.predicate.Predicates;
@ -57,7 +56,7 @@ import mage.target.common.TargetCardInOpponentsGraveyard;
*/
public class GethLordOfTheVault extends CardImpl {
public GethLordOfTheVault (UUID ownerId) {
public GethLordOfTheVault(UUID ownerId) {
super(ownerId, 64, "Geth, Lord of the Vault", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{B}{B}");
this.expansionSetCode = "SOM";
this.supertype.add("Legendary");
@ -82,15 +81,15 @@ public class GethLordOfTheVault extends CardImpl {
ability.getTargets().clear();
FilterCard filter = new FilterCard(new StringBuilder("artifact or creature card with converted mana cost ").append(xValue).append(" from an opponent's graveyard").toString());
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, xValue));
Target target = new TargetCardInOpponentsGraveyard(filter);
ability.addTarget(target);
}
}
public GethLordOfTheVault (final GethLordOfTheVault card) {
public GethLordOfTheVault(final GethLordOfTheVault card) {
super(card);
}
@ -100,6 +99,7 @@ public class GethLordOfTheVault extends CardImpl {
}
}
class GethLordOfTheVaultEffect extends OneShotEffect {
public GethLordOfTheVaultEffect() {
@ -113,15 +113,19 @@ class GethLordOfTheVaultEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId(), true);
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCards(player.getLibrary().getTopCards(game, card.getManaCost().convertedManaCost()), Zone.LIBRARY, Zone.GRAVEYARD, source, game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(getTargetPointer().getFirst(game, source));
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
player.moveCards(player.getLibrary().getTopCards(game, card.getManaCost().convertedManaCost()), Zone.GRAVEYARD, source, game);
}
}
return true;
}
return true;
return false;
}
@Override

View file

@ -113,18 +113,8 @@ class NimDeathmantleTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
// make sure card is on battlefield
UUID sourceId = getSourceId();
if (game.getPermanent(sourceId) == null) {
// or it is being removed
if (game.getLastKnownInformation(sourceId, Zone.BATTLEFIELD) == null) {
return false;
}
}
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
Permanent permanent = zEvent.getTarget();
if (permanent != null
&& permanent.getControllerId().equals(this.controllerId)
&& zEvent.getToZone() == Zone.GRAVEYARD
@ -159,29 +149,28 @@ class NimDeathmantleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
Permanent equipment = game.getPermanent(source.getSourceId());
if (player != null && equipment != null) {
if (player.chooseUse(Outcome.Benefit, equipment.getName() + " - Pay " + cost.getText() + "?", source, game)) {
if (controller != null && equipment != null) {
if (controller.chooseUse(Outcome.Benefit, equipment.getName() + " - Pay " + cost.getText() + "?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) {
UUID target = targetPointer.getFirst(game, source);
if (target != null && equipment != null) {
if (target != null) {
Card card = game.getCard(target);
// check if it's still in graveyard
if (card != null && game.getState().getZone(card.getId()).equals(Zone.GRAVEYARD)) {
Player owner = game.getPlayer(card.getOwnerId());
if (card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId())) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.addAttachment(equipment.getId(), game);
return true;
}
}
}
}
}
}
return true;
}
return false;

View file

@ -115,9 +115,9 @@ public class ShapeAnew extends CardImpl {
}
targetController.revealCards(sourcePermanent.getIdName(), revealed, game);
if (artifactCard != null) {
artifactCard.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), targetController.getId());
targetController.moveCards(artifactCard, Zone.BATTLEFIELD, source, game);
}
targetController.moveCards(nonArtifactCards, null, Zone.LIBRARY, source, game);
targetController.putCardsOnTopOfLibrary(nonArtifactCards, game, source, false);
targetController.shuffleLibrary(game);
return true;
}

View file

@ -34,7 +34,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CastSourceTriggeredAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -106,10 +105,7 @@ class DemigodOfRevengeReturnEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (Card creature : controller.getGraveyard().getCards(filter, game)) {
creature.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
}
return true;
return controller.moveCards(controller.getGraveyard().getCards(filter, game), Zone.BATTLEFIELD, source, game);
}
return false;
}

View file

@ -28,16 +28,18 @@
package mage.sets.shardsofalara;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
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.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
@ -56,7 +58,6 @@ public class ClarionUltimatum extends CardImpl {
super(ownerId, 163, "Clarion Ultimatum", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{G}{G}{W}{W}{W}{U}{U}");
this.expansionSetCode = "ALA";
// Choose five permanents you control. For each of those permanents, you may search your library for a card with the same name as that permanent. Put those cards onto the battlefield tapped, then shuffle your library.
this.getSpellAbility().addEffect(new ClarionUltimatumEffect());
}
@ -90,32 +91,28 @@ class ClarionUltimatumEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
int permanentsCount = game.getBattlefield().getAllActivePermanents(source.getControllerId()).size();
if (player == null || permanentsCount < 1) {
if (controller == null || permanentsCount < 1) {
return false;
}
TargetControlledPermanent permanentsTarget = new TargetControlledPermanent(Math.min(permanentsCount, 5));
player.choose(Outcome.Benefit, permanentsTarget, source.getSourceId(), game);
controller.choose(Outcome.Benefit, permanentsTarget, source.getSourceId(), game);
List<Card> chosenCards = new ArrayList<Card>();
List<String> namesFiltered = new ArrayList<String>();
Set<Card> chosenCards = new LinkedHashSet<>();
List<String> namesFiltered = new ArrayList<>();
List<UUID> permanents = permanentsTarget.getTargets();
for (UUID permanentId : permanents) {
Permanent permanent = game.getPermanent(permanentId);
final String cardName = permanent.getName();
if (!namesFiltered.contains(cardName)) {
StringBuilder sb = new StringBuilder();
sb.append("Search for ").append(cardName).append(" in your library?");
if (player.chooseUse(Outcome.PutCardInPlay, sb.toString(), source, game)) {
if (controller.chooseUse(Outcome.PutCardInPlay, "Search for " + cardName + " in your library?", source, game)) {
FilterCard filter = new FilterCard("card named " + cardName);
filter.add(new NamePredicate(cardName));
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) {
chosenCards.add(card);
}
@ -126,14 +123,8 @@ class ClarionUltimatumEffect extends OneShotEffect {
}
}
for (Card card : chosenCards) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.setTapped(true);
}
}
player.shuffleLibrary(game);
controller.moveCards(chosenCards, Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.shuffleLibrary(game);
return true;
}
}

View file

@ -104,7 +104,7 @@ class PrinceOfThrallsTriggeredAbility extends TriggeredAbilityImpl {
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (game.getOpponents(this.getControllerId()).contains(permanent.getControllerId())) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game.getState().getZoneChangeCounter(event.getTargetId())));
}
return true;
}
@ -137,18 +137,21 @@ class PrinceOfThrallsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(targetPointer.getFirst(game, source));
Permanent permanent = (Permanent) game.getLastKnownInformation(card.getId(), Zone.BATTLEFIELD);
Player opponent = game.getPlayer(permanent.getControllerId());
if (opponent != null && card != null && permanent != null && source.getControllerId() != null) {
PayLifeCost cost = new PayLifeCost(3);
if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + permanent.getName() + " comes back into the battlefield under opponents control", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), true)) {
return true;
Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
if (controller != null && card != null && permanent != null) {
Player opponent = game.getPlayer(permanent.getControllerId());
if (opponent != null) {
PayLifeCost cost = new PayLifeCost(3);
if (opponent.chooseUse(Outcome.Neutral, cost.getText() + " or " + card.getLogName() + " comes back into the battlefield under opponents control", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), opponent.getId(), true)) {
return true;
}
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
card.putOntoBattlefield(game, Zone.GRAVEYARD, id, source.getControllerId());
return true;
}
return false;

View file

@ -29,22 +29,21 @@ package mage.sets.shardsofalara;
import java.util.List;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
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.common.FilterLandPermanent;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
@ -95,7 +94,7 @@ class ExileAllEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent: permanents) {
for (Permanent permanent : permanents) {
permanent.moveToExile(source.getSourceId(), "Realm Razer", source.getSourceId(), game);
}
return true;
@ -103,7 +102,6 @@ class ExileAllEffect extends OneShotEffect {
}
class RealmRazerEffect extends OneShotEffect {
public RealmRazerEffect() {
@ -122,17 +120,14 @@ class RealmRazerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
ExileZone exZone = game.getExile().getExileZone(source.getSourceId());
if (exZone != null) {
for (Card card : exZone.getCards(game)) {
if (card != null) {
if(card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId())){
game.getPermanent(card.getId()).setTapped(true);
}
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ExileZone exZone = game.getExile().getExileZone(source.getSourceId());
if (exZone != null) {
return controller.moveCards(exZone.getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
return true;
}
return false;
}
}
}

View file

@ -57,20 +57,24 @@ import mage.target.common.TargetControlledCreaturePermanent;
/**
*
* Once you announce youre casting Rescue from the Underworld, no player may attempt to
* stop you from casting the spell by removing the creature you want to sacrifice.
* Once you announce youre casting Rescue from the Underworld, no player may
* attempt to stop you from casting the spell by removing the creature you want
* to sacrifice.
*
* If you sacrifice a creature token to cast Rescue from the Underworld, it wont return
* to the battlefield, although the target creature card will.
* If you sacrifice a creature token to cast Rescue from the Underworld, it
* wont return to the battlefield, although the target creature card will.
*
* If either the sacrificed creature or the target creature card leaves the graveyard
* before the delayed triggered ability resolves during your next upkeep, it wont return.
* If either the sacrificed creature or the target creature card leaves the
* graveyard before the delayed triggered ability resolves during your next
* upkeep, it wont return.
*
* However, if the sacrificed creature is put into another public zone instead of the graveyard,
* perhaps because its your commander or because of another replacement effect, it will return
* to the battlefield from the zone it went to.
* However, if the sacrificed creature is put into another public zone instead
* of the graveyard, perhaps because its your commander or because of another
* replacement effect, it will return to the battlefield from the zone it went
* to.
*
* Rescue from the Underworld is exiled as it resolves, not later as its delayed trigger resolves.
* Rescue from the Underworld is exiled as it resolves, not later as its delayed
* trigger resolves.
*
*
* @author LevelX2
@ -81,9 +85,8 @@ public class RescueFromTheUnderworld extends CardImpl {
super(ownerId, 102, "Rescue from the Underworld", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{4}{B}");
this.expansionSetCode = "THS";
// As an additional cost to cast Rescue from the Underworld, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), false)));
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature"), false)));
// Choose target creature card in your graveyard. Return that card and the sacrificed card to the battlefield under your control at the beginning of your next upkeep. Exile Rescue from the Underworld.
this.getSpellAbility().addEffect(new RescueFromTheUnderworldTextEffect());
@ -151,15 +154,15 @@ class RescueFromTheUnderworldCreateDelayedTriggeredAbilityEffect extends OneShot
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game), game);
delayedAbility.getTargets().addAll(source.getTargets());
for(Effect effect : delayedAbility.getEffects()) {
for (Effect effect : delayedAbility.getEffects()) {
effect.getTargetPointer().init(game, source);
}
// add the sacrificed creature as target
for (Cost cost :source.getCosts()) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
TargetCardInGraveyard target = new TargetCardInGraveyard();
for(Permanent permanent : sacCost.getPermanents()) {
for (Permanent permanent : sacCost.getPermanents()) {
target.add(permanent.getId(), game);
delayedAbility.getTargets().add(target);
}
@ -214,20 +217,12 @@ class RescueFromTheUnderworldDelayedTriggeredAbility extends DelayedTriggeredAbi
class RescueFromTheUnderworldReturnEffect extends OneShotEffect {
private boolean tapped;
public RescueFromTheUnderworldReturnEffect() {
this(false);
}
public RescueFromTheUnderworldReturnEffect(boolean tapped) {
super(Outcome.PutCreatureInPlay);
this.tapped = tapped;
}
public RescueFromTheUnderworldReturnEffect(final RescueFromTheUnderworldReturnEffect effect) {
super(effect);
this.tapped = effect.tapped;
}
@Override
@ -237,39 +232,36 @@ class RescueFromTheUnderworldReturnEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
boolean result = false;
// Target card comes only back if in graveyard
for (UUID targetId: getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
if(card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId(), tapped)){
result = true;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// Target card comes only back if in graveyard
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
// However, if the sacrificed creature is put into another public zone instead of the graveyard,
// perhaps because its your commander or because of another replacement effect, it will return
// to the battlefield from the zone it went to.
if (source.getTargets().get(1) != null) {
for (UUID targetId: ((Target) source.getTargets().get(1)).getTargets()) {
Card card = game.getCard(targetId);
if (card != null && !card.isFaceDown(game)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (currentZone.equals(Zone.COMMAND) || currentZone.equals(Zone.GRAVEYARD) || currentZone.equals(Zone.EXILED)) {
if(card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId(), false)){
result = true;
// However, if the sacrificed creature is put into another public zone instead of the graveyard,
// perhaps because its your commander or because of another replacement effect, it will return
// to the battlefield from the zone it went to.
if (source.getTargets().get(1) != null) {
for (UUID targetId : ((Target) source.getTargets().get(1)).getTargets()) {
Card card = game.getCard(targetId);
if (card != null && !card.isFaceDown(game)) {
Player player = game.getPlayer(card.getOwnerId());
if (player != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (currentZone.equals(Zone.COMMAND) || currentZone.equals(Zone.GRAVEYARD) || currentZone.equals(Zone.EXILED)) {
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
}
}
return true;
}
return result;
return false;
}
}

View file

@ -52,6 +52,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
@ -116,17 +117,19 @@ class LimDulTheNecromancerEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
Zone currentZone = game.getState().getZone(card.getId());
if (card.putOntoBattlefield(game, currentZone, source.getSourceId(), source.getControllerId())
&& card.getCardType().contains(CardType.CREATURE)) {
Permanent creature = game.getPermanent(card.getId());
ContinuousEffect effect = new AddCardSubTypeTargetEffect("Zombie", Duration.WhileOnBattlefield);
effect.setTargetPointer(new FixedTarget(creature.getId()));
game.addEffect(effect, source);
return true;
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = game.getCard(targetPointer.getFirst(game, source));
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)
&& card.getCardType().contains(CardType.CREATURE)) {
Permanent creature = game.getPermanent(card.getId());
ContinuousEffect effect = new AddCardSubTypeTargetEffect("Zombie", Duration.WhileOnBattlefield);
effect.setTargetPointer(new FixedTarget(creature.getId()));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}

View file

@ -62,7 +62,7 @@ public class NorwoodPriestess extends CardImpl {
this.toughness = new MageInt(1);
// {tap}: You may put a green creature card from your hand onto the battlefield. Activate this ability only during your turn, before attackers are declared.
Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD,
Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD,
new NorwoodPriestessEffect(), new TapSourceCost(), MyTurnBeforeAttackersDeclaredCondition.getInstance());
this.addAbility(ability);
}
@ -80,9 +80,9 @@ public class NorwoodPriestess extends CardImpl {
class NorwoodPriestessEffect extends OneShotEffect {
private static final String choiceText = "Put a green creature card from your hand onto the battlefield?";
private static final FilterCreatureCard filter = new FilterCreatureCard("a green creature card");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
@ -103,19 +103,18 @@ class NorwoodPriestessEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || !player.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null || !controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
return false;
}
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
card.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), source.getControllerId());
return true;
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
return false;
}
}
}

View file

@ -44,6 +44,7 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.game.stack.StackObject;
import mage.players.Player;
import mage.target.TargetSpell;
/**
@ -99,24 +100,27 @@ class DesertionEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
UUID objectId = source.getFirstTarget();
UUID sourceId = source.getSourceId();
StackObject stackObject = game.getStack().getStackObject(objectId);
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
if (stackObject instanceof Spell) {
game.rememberLKI(objectId, Zone.STACK, (Spell) stackObject);
game.getStack().remove(stackObject);
if (!((Spell) stackObject).isCopiedSpell() && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game)) {
MageObject card = game.getObject(stackObject.getSourceId());
if (card instanceof Card) {
((Card) card).putOntoBattlefield(game, Zone.STACK, source.getSourceId(), source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
StackObject stackObject = game.getStack().getStackObject(objectId);
if (stackObject != null && !game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) {
if (stackObject instanceof Spell) {
game.rememberLKI(objectId, Zone.STACK, (Spell) stackObject);
game.getStack().remove(stackObject);
if (!((Spell) stackObject).isCopiedSpell() && filter.match(stackObject, source.getSourceId(), source.getControllerId(), game)) {
MageObject card = game.getObject(stackObject.getSourceId());
if (card instanceof Card) {
controller.moveCards((Card) card, Zone.BATTLEFIELD, source, game);
}
} else {
stackObject.counter(sourceId, game);
}
} else {
stackObject.counter(sourceId, game);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
return true;
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId()));
return true;
}
}
return false;
}

View file

@ -28,9 +28,6 @@
package mage.sets.worldwake;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -38,7 +35,9 @@ import mage.abilities.costs.common.TapSourceCost;
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.FilterCard;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -96,32 +95,30 @@ class AgadeemOccultistEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
int allycount = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent.hasSubtype("Ally")) {
allycount++;
}
}
FilterCard filter = new FilterCard("creature card in an opponent's graveyard");
filter.add(new CardTypePredicate(CardType.CREATURE));
TargetCardInOpponentsGraveyard target = new TargetCardInOpponentsGraveyard(1, 1, filter);
if (you != null) {
if (controller != null) {
if (target.canChoose(source.getControllerId(), game)
&& you.choose(Outcome.GainControl, target, source.getSourceId(), game)) {
&& controller.choose(Outcome.GainControl, target, source.getSourceId(), game)) {
if (!target.getTargets().isEmpty()) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (card.getManaCost().convertedManaCost() <= allycount) {
card.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
return true;
return controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
}
return true;
}
return false;
}

View file

@ -29,10 +29,6 @@ package mage.sets.zendikar;
import java.util.UUID;
import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.AttacksAttachedTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
@ -42,6 +38,10 @@ 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;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
@ -56,9 +56,9 @@ public class ExplorersScope extends CardImpl {
this.expansionSetCode = "ZEN";
this.subtype.add("Equipment");
// Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped.
// Whenever equipped creature attacks, look at the top card of your library. If it's a land card, you may put it onto the battlefield tapped.
this.addAbility(new AttacksAttachedTriggeredAbility(new ExplorersScopeEffect()));
// Equip ({1}: Attach to target creature you control. Equip only as a sorcery.)
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1)));
}
@ -105,7 +105,7 @@ class ExplorersScopeEffect extends OneShotEffect {
if (card.getCardType().contains(CardType.LAND)) {
String message = "Put " + card.getLogName() + " onto the battlefield tapped?";
if (controller.chooseUse(Outcome.PutLandInPlay, message, source, game)) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId(), true);
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
}

View file

@ -68,7 +68,6 @@ public class Gigantiform extends CardImpl {
this.expansionSetCode = "ZEN";
this.subtype.add("Aura");
// Kicker {4}
this.addAbility(new KickerAbility("{4}"));
@ -143,14 +142,14 @@ class GigantiformEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player != null && player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (controller != null && controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
return false;

View file

@ -28,11 +28,6 @@
package mage.sets.zendikar;
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.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
@ -42,6 +37,10 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
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.counters.CounterType;
import mage.filter.FilterCard;
import mage.filter.FilterSpell;
@ -61,6 +60,7 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class QuestForTheHolyRelic extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a creature spell");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
}
@ -69,7 +69,6 @@ public class QuestForTheHolyRelic extends CardImpl {
super(ownerId, 33, "Quest for the Holy Relic", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.expansionSetCode = "ZEN";
// Whenever you cast a creature spell, you may put a quest counter on Quest for the Holy Relic.
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.QUEST.createInstance()), filter, true));
// Remove five quest counters from Quest for the Holy Relic and sacrifice it: Search your library for an Equipment card, put it onto the battlefield, and attach it to a creature you control. Then shuffle your library.
@ -106,28 +105,26 @@ class QuestForTheHolyRelicEffect 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("Equipment");
filter.add(new SubtypePredicate("Equipment"));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
if (controller.searchLibrary(target, game)) {
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null && controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent equipment = game.getPermanent(card.getId());
Target targetCreature = new TargetControlledCreaturePermanent();
if (equipment != null && player.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) {
if (equipment != null && controller.choose(Outcome.BoostCreature, targetCreature, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
permanent.addAttachment(equipment.getId(), game);
}
}
}
player.shuffleLibrary(game);
controller.shuffleLibrary(game);
return true;
}
}