* 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.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD,
new DoIfCostPaid(new UntapSourceEffect(), new GenericManaCost(4)),
new DoIfCostPaid(new UntapSourceEffect(), new GenericManaCost(4),"Pay {4} to untap {this}?"),
TargetController.YOU,
false));
// At the beginning of your draw step, if Mana Vault is tapped, it deals 1 damage to you.
this.addAbility(new ConditionalTriggeredAbility(
new BeginningOfDrawTriggeredAbility(Zone.BATTLEFIELD, new DamageControllerEffect(1), TargetController.YOU, false),
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.
this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD, Mana.ColorlessMana(3), new TapSourceCost()));
}

View file

@ -27,6 +27,8 @@
*/
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.OneShotEffect;
@ -34,14 +36,18 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
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.players.Player;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent;
import java.util.UUID;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/**
*
@ -90,16 +96,18 @@ class PraetorsGraspEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && opponent != null && sourcePermanent != null) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && opponent != null && sourceObject != null) {
TargetCardInLibrary target = new TargetCardInLibrary();
if (player.searchLibrary(target, game, opponent.getId())) {
if (controller.searchLibrary(target, game, opponent.getId())) {
UUID targetId = target.getFirstTarget();
Card card = opponent.getLibrary().remove(targetId, game);
if (card != null) {
Card card = opponent.getLibrary().getCard(targetId, game);
UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject);
if (card != null && exileId != null) {
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 PraetorsGraspRevealEffect(card.getId()), source);
}
@ -139,11 +147,19 @@ class PraetorsGraspPlayEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(cardId)) {
Card card = game.getCard(cardId);
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;
}
} else {
discard();
}
}
}
return false;
}
@ -178,13 +194,21 @@ class PraetorsGraspRevealEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(cardId)) {
Card card = game.getCard(cardId);
Card sourceCard = game.getCard(source.getSourceId());
MageObject sourceObject = source.getSourceObject(game);
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());
Card card = game.getCard(cardId);
if (controller != null && card != null && game.getState().getZone(cardId) == Zone.EXILED) {
if (controller.chooseUse(outcome, "Reveal exiled card?", game)) {
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) {
return getObjectExileZoneId(game, mageObject, false);
}
public static UUID getObjectExileZoneId(Game game, MageObject mageObject, boolean previous) {
int zoneChangeCounter = 0;
if (mageObject instanceof Permanent) {
zoneChangeCounter = ((Permanent) mageObject).getZoneChangeCounter();
} else if (mageObject instanceof Card) {
zoneChangeCounter = ((Card) mageObject).getZoneChangeCounter();
}
if (zoneChangeCounter > 0 && previous) {
zoneChangeCounter--;
}
return getExileZoneId(getObjectZoneString(SOURCE_EXILE_ZONE_TEXT,mageObject.getId(), game, zoneChangeCounter, false), game);
}