* Praetor's Grasp - Fixed that the cast and reveal effects did not work.

This commit is contained in:
LevelX2 2015-02-25 01:19:27 +01:00
parent e418d69068
commit 7ac423f1d6
3 changed files with 55 additions and 24 deletions

View file

@ -62,14 +62,14 @@ public class ManaVault extends CardImpl {
// At the beginning of your upkeep, you may pay {4}. If you do, untap Mana Vault. // At the beginning of your upkeep, you may pay {4}. If you do, untap Mana Vault.
this.addAbility(new BeginningOfUpkeepTriggeredAbility( this.addAbility(new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD, Zone.BATTLEFIELD,
new DoIfCostPaid(new UntapSourceEffect(), new GenericManaCost(4)), new DoIfCostPaid(new UntapSourceEffect(), new GenericManaCost(4),"Pay {4} to untap {this}?"),
TargetController.YOU, TargetController.YOU,
false)); false));
// At the beginning of your draw step, if Mana Vault is tapped, it deals 1 damage to you. // At the beginning of your draw step, if Mana Vault is tapped, it deals 1 damage to you.
this.addAbility(new ConditionalTriggeredAbility( this.addAbility(new ConditionalTriggeredAbility(
new BeginningOfDrawTriggeredAbility(Zone.BATTLEFIELD, new DamageControllerEffect(1), TargetController.YOU, false), new BeginningOfDrawTriggeredAbility(Zone.BATTLEFIELD, new DamageControllerEffect(1), TargetController.YOU, false),
SourceTappedCondition.getInstance(), SourceTappedCondition.getInstance(),
"At the beginning of your draw step, if Mana Vault is tapped, it deals 1 damage to you.", false)); "At the beginning of your draw step, if {this} is tapped, it deals 1 damage to you.", false));
// {tap}: Add {3} to your mana pool. // {tap}: Add {3} to your mana pool.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(3), new TapSourceCost())); this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(3), new TapSourceCost()));
} }

View file

@ -27,6 +27,8 @@
*/ */
package mage.sets.newphyrexia; package mage.sets.newphyrexia;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -34,14 +36,18 @@ import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.constants.*; import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import mage.util.CardUtil;
import java.util.UUID;
import mage.game.permanent.Permanent;
/** /**
* *
@ -90,16 +96,18 @@ class PraetorsGraspEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget()); Player opponent = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); MageObject sourceObject = source.getSourceObject(game);
if (player != null && opponent != null && sourcePermanent != null) { if (controller != null && opponent != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary(); TargetCardInLibrary target = new TargetCardInLibrary();
if (player.searchLibrary(target, game, opponent.getId())) { if (controller.searchLibrary(target, game, opponent.getId())) {
UUID targetId = target.getFirstTarget(); UUID targetId = target.getFirstTarget();
Card card = opponent.getLibrary().remove(targetId, game); Card card = opponent.getLibrary().getCard(targetId, game);
if (card != null) { UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject);
if (card != null && exileId != null) {
card.setFaceDown(true); card.setFaceDown(true);
card.moveToExile(getId(), sourcePermanent.getName(), source.getSourceId(), game); game.informPlayers(controller.getName() + " moves the searched card face down to exile");
card.moveToExile(exileId, sourceObject.getName(), source.getSourceId(), game);
game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source); game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source);
game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source); game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source);
} }
@ -139,11 +147,19 @@ class PraetorsGraspPlayEffect extends AsThoughEffectImpl {
@Override @Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(cardId)) { if (sourceId.equals(cardId)) {
Card card = game.getCard(cardId);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null && card != null && game.getState().getZone(cardId) == Zone.EXILED) { MageObject sourceObject = source.getSourceObject(game);
UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject, true);
if (exileId != null && sourceObject != null && controller != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(cardId)) {
if (controller.chooseUse(outcome, "Play the exiled card?", game)) {
return true; return true;
} }
} else {
discard();
}
}
} }
return false; return false;
} }
@ -178,13 +194,21 @@ class PraetorsGraspRevealEffect extends AsThoughEffectImpl {
@Override @Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(cardId)) { if (sourceId.equals(cardId)) {
Card card = game.getCard(cardId); MageObject sourceObject = source.getSourceObject(game);
Card sourceCard = game.getCard(source.getSourceId()); UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject, true);
if (exileId != null && sourceObject != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(cardId)) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(cardId);
if (controller != null && card != null && game.getState().getZone(cardId) == Zone.EXILED) { if (controller != null && card != null && game.getState().getZone(cardId) == Zone.EXILED) {
if (controller.chooseUse(outcome, "Reveal exiled card?", game)) { if (controller.chooseUse(outcome, "Reveal exiled card?", game)) {
Cards cards = new CardsImpl(card); Cards cards = new CardsImpl(card);
controller.lookAtCards("Exiled with " + sourceCard.getName(), cards, game); controller.lookAtCards("Exiled with " + sourceObject.getName(), cards, game);
}
}
} else {
discard();
} }
} }
} }

View file

@ -479,12 +479,19 @@ public class CardUtil {
} }
public static UUID getObjectExileZoneId(Game game, MageObject mageObject) { public static UUID getObjectExileZoneId(Game game, MageObject mageObject) {
return getObjectExileZoneId(game, mageObject, false);
}
public static UUID getObjectExileZoneId(Game game, MageObject mageObject, boolean previous) {
int zoneChangeCounter = 0; int zoneChangeCounter = 0;
if (mageObject instanceof Permanent) { if (mageObject instanceof Permanent) {
zoneChangeCounter = ((Permanent) mageObject).getZoneChangeCounter(); zoneChangeCounter = ((Permanent) mageObject).getZoneChangeCounter();
} else if (mageObject instanceof Card) { } else if (mageObject instanceof Card) {
zoneChangeCounter = ((Card) mageObject).getZoneChangeCounter(); zoneChangeCounter = ((Card) mageObject).getZoneChangeCounter();
} }
if (zoneChangeCounter > 0 && previous) {
zoneChangeCounter--;
}
return getExileZoneId(getObjectZoneString(SOURCE_EXILE_ZONE_TEXT,mageObject.getId(), game, zoneChangeCounter, false), game); return getExileZoneId(getObjectZoneString(SOURCE_EXILE_ZONE_TEXT,mageObject.getId(), game, zoneChangeCounter, false), game);
} }