mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
* 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:
parent
f340ed29d0
commit
47af2cab75
4 changed files with 57 additions and 39 deletions
|
|
@ -32,16 +32,23 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.TransformSourceEffect;
|
import mage.abilities.effects.common.TransformSourceEffect;
|
||||||
import mage.abilities.keyword.TransformAbility;
|
import mage.abilities.keyword.TransformAbility;
|
||||||
import mage.cards.Card;
|
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.TargetController;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.common.FilterInstantOrSorceryCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
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.
|
// 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 TransformAbility());
|
||||||
this.addAbility(new DelverOfSecretsAbility());
|
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new DelverOfSecretsEffect(), TargetController.YOU, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelverOfSecrets(final DelverOfSecrets card) {
|
public DelverOfSecrets(final DelverOfSecrets card) {
|
||||||
|
|
@ -78,44 +85,44 @@ public class DelverOfSecrets extends CardImpl<DelverOfSecrets> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DelverOfSecretsAbility extends TriggeredAbilityImpl<DelverOfSecretsAbility> {
|
class DelverOfSecretsEffect extends OneShotEffect<DelverOfSecretsEffect> {
|
||||||
|
|
||||||
public DelverOfSecretsAbility() {
|
private static final FilterCard filter = new FilterInstantOrSorceryCard();
|
||||||
super(Zone.BATTLEFIELD, new TransformSourceEffect(true, false), false);
|
|
||||||
|
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) {
|
public DelverOfSecretsEffect(final DelverOfSecretsEffect effect) {
|
||||||
super(ability);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DelverOfSecretsAbility copy() {
|
public DelverOfSecretsEffect copy() {
|
||||||
return new DelverOfSecretsAbility(this);
|
return new DelverOfSecretsEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
Player player = game.getPlayer(this.controllerId);
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
if (player != null && player.getLibrary().size() > 0) {
|
if (player != null && sourcePermanent != null) {
|
||||||
|
if (player.getLibrary().size() > 0) {
|
||||||
Card card = player.getLibrary().getFromTop(game);
|
Card card = player.getLibrary().getFromTop(game);
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
player.lookAtCards("This card", cards, game);
|
player.lookAtCards(sourcePermanent.getName(), cards, game);
|
||||||
if (player.chooseUse(Outcome.DrawCard, "Do you wish to reveal the card at the top of the liberary?", 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);
|
||||||
player.revealCards("Delver of Secrets", cards, game);
|
if (filter.match(card, game)) {
|
||||||
if ((card.getCardType().contains(CardType.INSTANT) || card.getCardType().contains(CardType.SORCERY))) {
|
return new TransformSourceEffect(true, true).apply(game, source);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
return false;
|
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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,13 @@ public class InsectileAberration extends CardImpl<InsectileAberration> {
|
||||||
this.subtype.add("Human");
|
this.subtype.add("Human");
|
||||||
this.subtype.add("Insect");
|
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.nightCard = true;
|
||||||
|
|
||||||
this.power = new MageInt(3);
|
this.power = new MageInt(3);
|
||||||
this.toughness = new MageInt(2);
|
this.toughness = new MageInt(2);
|
||||||
|
|
||||||
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import mage.cards.CardsImpl;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.TargetController;
|
import mage.constants.TargetController;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -88,14 +89,18 @@ class DarkConfidantEffect extends OneShotEffect<DarkConfidantEffect> {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null && player.getLibrary().size() > 0) {
|
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||||
Card card = player.getLibrary().removeFromTop(game);
|
if (player != null && sourcePermanent != null) {
|
||||||
if (card != null) {
|
if (player.getLibrary().size() > 0) {
|
||||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
Card card = player.getLibrary().removeFromTop(game);
|
||||||
player.loseLife(card.getManaCost().convertedManaCost(), game);
|
if (card != null) {
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
cards.add(card);
|
cards.add(card);
|
||||||
player.revealCards("top card from library by Dark Confidant", cards, game);
|
player.revealCards(sourcePermanent.getName(), cards, game);
|
||||||
|
player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
|
||||||
|
player.loseLife(card.getManaCost().convertedManaCost(), game);
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,16 @@ public class TransformSourceEffect extends OneShotEffect<TransformSourceEffect>
|
||||||
if (permanent.canTransform()) {
|
if (permanent.canTransform()) {
|
||||||
// check not to transform twice the same side
|
// check not to transform twice the same side
|
||||||
if (permanent.isTransformed() != fromDayToNight) {
|
if (permanent.isTransformed() != fromDayToNight) {
|
||||||
if (withoutTrigger) {
|
if (withoutTrigger) {
|
||||||
permanent.setTransformed(fromDayToNight);
|
permanent.setTransformed(fromDayToNight);
|
||||||
} else {
|
} else {
|
||||||
permanent.transform(game);
|
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;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue