1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-08 17:00:07 -09:00

Hideaway - Some minor fixes.

This commit is contained in:
LevelX2 2015-06-22 15:32:00 +02:00
parent 78188d6f24
commit 6fa1f4c2e0
8 changed files with 35 additions and 56 deletions

View file

@ -55,7 +55,7 @@ public class MosswortBridge extends CardImpl {
this.expansionSetCode = "C13"; this.expansionSetCode = "C13";
// Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.) // Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.)
this.addAbility(new HideawayAbility(this)); this.addAbility(new HideawayAbility());
// {tap}: Add {G} to your mana pool. // {tap}: Add {G} to your mana pool.
this.addAbility(new GreenManaAbility()); this.addAbility(new GreenManaAbility());

View file

@ -53,7 +53,7 @@ public class HowltoothHollow extends CardImpl {
this.expansionSetCode = "LRW"; this.expansionSetCode = "LRW";
// Hideaway // Hideaway
this.addAbility(new HideawayAbility(this)); this.addAbility(new HideawayAbility());
// {tap}: Add {B} to your mana pool. // {tap}: Add {B} to your mana pool.
this.addAbility(new BlackManaAbility()); this.addAbility(new BlackManaAbility());

View file

@ -53,7 +53,7 @@ public class ShelldockIsle extends CardImpl {
this.expansionSetCode = "LRW"; this.expansionSetCode = "LRW";
// Hideaway // Hideaway
this.addAbility(new HideawayAbility(this)); this.addAbility(new HideawayAbility());
// {tap}: Add {U} to your mana pool. // {tap}: Add {U} to your mana pool.
this.addAbility(new BlueManaAbility()); this.addAbility(new BlueManaAbility());
// {U}, {tap}: You may play the exiled card without paying its mana cost if a library has twenty or fewer cards in it. // {U}, {tap}: You may play the exiled card without paying its mana cost if a library has twenty or fewer cards in it.

View file

@ -61,7 +61,7 @@ public class SpinerockKnoll extends CardImpl {
this.expansionSetCode = "LRW"; this.expansionSetCode = "LRW";
// Hideaway // Hideaway
this.addAbility(new HideawayAbility(this)); this.addAbility(new HideawayAbility());
// {tap}: Add {R} to your mana pool. // {tap}: Add {R} to your mana pool.
this.addAbility(new RedManaAbility()); this.addAbility(new RedManaAbility());

View file

@ -54,7 +54,7 @@ public class WindbriskHeights extends CardImpl {
this.expansionSetCode = "LRW"; this.expansionSetCode = "LRW";
// Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.) // Hideaway (This land enters the battlefield tapped. When it does, look at the top four cards of your library, exile one face down, then put the rest on the bottom of your library.)
this.addAbility(new HideawayAbility(this)); this.addAbility(new HideawayAbility());
// {tap}: Add {W} to your mana pool. // {tap}: Add {W} to your mana pool.
this.addAbility(new WhiteManaAbility()); this.addAbility(new WhiteManaAbility());
// {W}, {tap}: You may play the exiled card without paying its mana cost if you attacked with three or more creatures this turn. // {W}, {tap}: You may play the exiled card without paying its mana cost if you attacked with three or more creatures this turn.

View file

@ -33,7 +33,6 @@ import mage.constants.Duration;
import mage.constants.EffectType; import mage.constants.EffectType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
/** /**
* *

View file

@ -70,7 +70,7 @@ public class HideawayPlayEffect extends OneShotEffect {
if (card.getCardType().contains(CardType.LAND)) { if (card.getCardType().contains(CardType.LAND)) {
// If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn. // If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn.
if (game.getActivePlayerId().equals(source.getControllerId()) && controller.canPlayLand()) { if (game.getActivePlayerId().equals(source.getControllerId()) && controller.canPlayLand()) {
if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Play ").append(card.getName()).append(" from Exile?").toString(), game)) { if (controller.chooseUse(Outcome.Benefit, "Play " + card.getLogName() + " from Exile?", game)) {
card.setFaceDown(false, game); card.setFaceDown(false, game);
return controller.playLand(card, game); return controller.playLand(card, game);
} }
@ -82,7 +82,7 @@ public class HideawayPlayEffect extends OneShotEffect {
// The land's last ability allows you to play the removed card as part of the resolution of that ability. // The land's last ability allows you to play the removed card as part of the resolution of that ability.
// Timing restrictions based on the card's type are ignored (for instance, if it's a creature or sorcery). // Timing restrictions based on the card's type are ignored (for instance, if it's a creature or sorcery).
// Other play restrictions are not (such as "Play [this card] only during combat"). // Other play restrictions are not (such as "Play [this card] only during combat").
if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Cast ").append(card.getName()).append(" without paying it's mana cost?").toString(), game)) { if (controller.chooseUse(Outcome.Benefit, "Cast "+ card.getLogName() + " without paying it's mana cost?", game)) {
card.setFaceDown(false, game); card.setFaceDown(false, game);
return controller.cast(card.getSpellAbility(), game, true); return controller.cast(card.getSpellAbility(), game, true);
} }

View file

@ -64,7 +64,7 @@ import mage.util.CardUtil;
*/ */
public class HideawayAbility extends StaticAbility { public class HideawayAbility extends StaticAbility {
public HideawayAbility(Card card) { public HideawayAbility() {
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new TapSourceEffect(true))); super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new TapSourceEffect(true)));
Ability ability = new EntersBattlefieldTriggeredAbility(new HideawayExileEffect(), false); Ability ability = new EntersBattlefieldTriggeredAbility(new HideawayExileEffect(), false);
ability.setRuleVisible(false); ability.setRuleVisible(false);
@ -93,7 +93,6 @@ public class HideawayAbility extends StaticAbility {
class HideawayExileEffect extends OneShotEffect { class HideawayExileEffect extends OneShotEffect {
private static FilterCard filter1 = new FilterCard("card to exile face down"); private static FilterCard filter1 = new FilterCard("card to exile face down");
private static FilterCard filter2 = new FilterCard("card to put on the bottom of your library");
public HideawayExileEffect() { public HideawayExileEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
@ -111,46 +110,26 @@ class HideawayExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Cards cards = new CardsImpl(Zone.PICK);
int count = Math.min(player.getLibrary().size(), 4);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
cards.add(card);
game.setZone(card.getId(), Zone.PICK);
}
Permanent hideawaySource = game.getPermanent(source.getSourceId()); Permanent hideawaySource = game.getPermanent(source.getSourceId());
if (cards.size() == 0 || hideawaySource == null) { if (hideawaySource == null || controller == null) {
return false; return false;
} }
TargetCard target1 = new TargetCard(Zone.PICK, filter1); Cards cards = new CardsImpl(Zone.LIBRARY);
if (player.choose(Outcome.Detriment, cards, target1, game)) { cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (cards.size() > 0) {
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1);
if (controller.choose(Outcome.Detriment, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game); Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) { if (card != null) {
cards.remove(card); cards.remove(card);
card.moveToExile(CardUtil.getCardExileZoneId(game, source), controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source),
new StringBuilder("Hideaway (").append(hideawaySource.getName()).append(")").toString(), "Hideaway (" + hideawaySource.getIdName() +")", source.getSourceId(), game, Zone.LIBRARY, false);
source.getSourceId(), game);
card.setFaceDown(true, game); card.setFaceDown(true, game);
} }
target1.clearChosen();
} }
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
if (cards.size() > 0) {
TargetCard target2 = new TargetCard(Zone.PICK, filter2);
while (player.isInGame() && cards.size() > 1) {
player.choose(Outcome.Benefit, cards, target2, game);
Card card = cards.get(target2.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
}
target2.clearChosen();
}
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
} }
return true; return true;
@ -179,24 +158,25 @@ class HideawayLookAtFaceDownCardEffect extends AsThoughEffectImpl {
} }
@Override @Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(sourceId); if (game.getState().getZone(objectId) != Zone.EXILED
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { || !game.getState().getCardState(objectId).isFaceDown()) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard == null) {
return false; return false;
} }
// TODO: Does not handle if a player had the control of the land permanent some time before
// we would need to add a watcher to handle this
Permanent sourcePermanet = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanet != null && sourcePermanet.getControllerId().equals(affectedControllerId)) {
ExileZone exile = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); ExileZone exile = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
if (exile != null && exile.contains(sourceId)) { Card card = game.getCard(objectId);
Cards cards = new CardsImpl(card); if (exile != null && exile.contains(objectId) && card != null) {
Player controller = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(affectedControllerId);
if (controller != null) { if (player != null) {
// only the controller can see the card, so return always false player.lookAtCards("Hideaway by " + sourcePermanet.getIdName(), card, game);
controller.lookAtCards("Exiled with " + sourceCard.getName(), cards, game);
} }
} }
} }
// only the current or a previous controller can see the card, so always return false for reveal request
return false; return false;
} }
} }