* Delver Of Secrets - Fixed that the Reveal and to ask player did not happen during the resolving of the abilitys effect. Added info about transformation to log.

This commit is contained in:
LevelX2 2014-03-14 13:56:30 +01:00
parent f340ed29d0
commit 47af2cab75
4 changed files with 57 additions and 39 deletions

View file

@ -32,16 +32,23 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.keyword.TransformAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterInstantOrSorceryCard;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -65,7 +72,7 @@ public class DelverOfSecrets extends CardImpl<DelverOfSecrets> {
// At the beginning of your upkeep, look at the top card of your library. You may reveal that card. If an instant or sorcery card is revealed this way, transform Delver of Secrets.
this.addAbility(new TransformAbility());
this.addAbility(new DelverOfSecretsAbility());
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DelverOfSecretsEffect(), TargetController.YOU, false));
}
public DelverOfSecrets(final DelverOfSecrets card) {
@ -78,44 +85,44 @@ public class DelverOfSecrets extends CardImpl<DelverOfSecrets> {
}
}
class DelverOfSecretsAbility extends TriggeredAbilityImpl<DelverOfSecretsAbility> {
public DelverOfSecretsAbility() {
super(Zone.BATTLEFIELD, new TransformSourceEffect(true, false), false);
class DelverOfSecretsEffect extends OneShotEffect<DelverOfSecretsEffect> {
private static final FilterCard filter = new FilterInstantOrSorceryCard();
public DelverOfSecretsEffect() {
super(Outcome.Benefit);
this.staticText = "look at the top card of your library. You may reveal that card. If an instant or sorcery card is revealed this way, transform {this}";
}
public DelverOfSecretsAbility(DelverOfSecretsAbility ability) {
super(ability);
public DelverOfSecretsEffect(final DelverOfSecretsEffect effect) {
super(effect);
}
@Override
public DelverOfSecretsAbility copy() {
return new DelverOfSecretsAbility(this);
public DelverOfSecretsEffect copy() {
return new DelverOfSecretsEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
Player player = game.getPlayer(this.controllerId);
if (player != null && player.getLibrary().size() > 0) {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && sourcePermanent != null) {
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().getFromTop(game);
Cards cards = new CardsImpl();
cards.add(card);
player.lookAtCards("This card", cards, game);
if (player.chooseUse(Outcome.DrawCard, "Do you wish to reveal the card at the top of the liberary?", game))
{
player.revealCards("Delver of Secrets", cards, game);
if ((card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY))) {
return true;
player.lookAtCards(sourcePermanent.getName(), cards, game);
if (player.chooseUse(Outcome.DrawCard, "Do you wish to reveal the card at the top of the library?", game)) {
player.revealCards(sourcePermanent.getName(), cards, game);
if (filter.match(card, game)) {
return new TransformSourceEffect(true, true).apply(game, source);
}
}
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "At the beginning of your upkeep, look at the top card of your library. You may reveal that card. If an instant or sorcery card is revealed this way, transform Delver of Secrets";
}
}
}

View file

@ -47,12 +47,13 @@ public class InsectileAberration extends CardImpl<InsectileAberration> {
this.subtype.add("Human");
this.subtype.add("Insect");
// this card is the second face of double-faced card
// this card is the second face of double-faced card Delver of Secrets
this.nightCard = true;
this.power = new MageInt(3);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
}

View file

@ -43,6 +43,7 @@ import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
@ -88,14 +89,18 @@ class DarkConfidantEffect extends OneShotEffect<DarkConfidantEffect> {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
card.moveToZone(Zone.HAND, source.getId(), game, false);
player.loseLife(card.getManaCost().convertedManaCost(), game);
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards("top card from library by Dark Confidant", cards, game);
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player != null && sourcePermanent != null) {
if (player.getLibrary().size() > 0) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
player.revealCards(sourcePermanent.getName(), cards, game);
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
player.loseLife(card.getManaCost().convertedManaCost(), game);
}
return true;
}
}

View file

@ -75,11 +75,16 @@ public class TransformSourceEffect extends OneShotEffect<TransformSourceEffect>
if (permanent.canTransform()) {
// check not to transform twice the same side
if (permanent.isTransformed() != fromDayToNight) {
if (withoutTrigger) {
if (withoutTrigger) {
permanent.setTransformed(fromDayToNight);
} else {
permanent.transform(game);
}
if (fromDayToNight) {
game.informPlayers(new StringBuilder(permanent.getName()).append(" transforms into ").append(permanent.getSecondCardFace().getName()).toString());
} else {
game.informPlayers(new StringBuilder(permanent.getSecondCardFace().getName()).append(" transforms into ").append(permanent.getName()).toString());
}
}
}
return true;