1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-29 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";
// 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.
this.addAbility(new GreenManaAbility());

View file

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

View file

@ -53,7 +53,7 @@ public class ShelldockIsle extends CardImpl {
this.expansionSetCode = "LRW";
// Hideaway
this.addAbility(new HideawayAbility(this));
this.addAbility(new HideawayAbility());
// {tap}: Add {U} to your mana pool.
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.

View file

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

View file

@ -54,7 +54,7 @@ public class WindbriskHeights extends CardImpl {
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.)
this.addAbility(new HideawayAbility(this));
this.addAbility(new HideawayAbility());
// {tap}: Add {W} to your mana pool.
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.

View file

@ -33,7 +33,6 @@ import mage.constants.Duration;
import mage.constants.EffectType;
import mage.constants.Outcome;
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 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 (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);
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.
// 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").
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);
return controller.cast(card.getSpellAbility(), game, true);
}

View file

@ -64,7 +64,7 @@ import mage.util.CardUtil;
*/
public class HideawayAbility extends StaticAbility {
public HideawayAbility(Card card) {
public HideawayAbility() {
super(Zone.BATTLEFIELD, new EntersBattlefieldEffect(new TapSourceEffect(true)));
Ability ability = new EntersBattlefieldTriggeredAbility(new HideawayExileEffect(), false);
ability.setRuleVisible(false);
@ -93,7 +93,6 @@ public class HideawayAbility extends StaticAbility {
class HideawayExileEffect extends OneShotEffect {
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() {
super(Outcome.Benefit);
@ -111,46 +110,26 @@ class HideawayExileEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = 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);
}
Player controller = game.getPlayer(source.getControllerId());
Permanent hideawaySource = game.getPermanent(source.getSourceId());
if (cards.size() == 0 || hideawaySource == null) {
if (hideawaySource == null || controller == null) {
return false;
}
TargetCard target1 = new TargetCard(Zone.PICK, filter1);
if (player.choose(Outcome.Detriment, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToExile(CardUtil.getCardExileZoneId(game, source),
new StringBuilder("Hideaway (").append(hideawaySource.getName()).append(")").toString(),
source.getSourceId(), game);
card.setFaceDown(true, game);
}
target1.clearChosen();
}
Cards cards = new CardsImpl(Zone.LIBRARY);
cards.addAll(controller.getLibrary().getTopCards(game, 4));
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);
TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1);
if (controller.choose(Outcome.Detriment, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source),
"Hideaway (" + hideawaySource.getIdName() +")", source.getSourceId(), game, Zone.LIBRARY, false);
card.setFaceDown(true, game);
}
target2.clearChosen();
}
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
@ -179,24 +158,25 @@ class HideawayLookAtFaceDownCardEffect extends AsThoughEffectImpl {
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
Card card = game.getCard(sourceId);
if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard == null) {
return false;
}
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (game.getState().getZone(objectId) != Zone.EXILED
|| !game.getState().getCardState(objectId).isFaceDown()) {
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));
if (exile != null && exile.contains(sourceId)) {
Cards cards = new CardsImpl(card);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// only the controller can see the card, so return always false
controller.lookAtCards("Exiled with " + sourceCard.getName(), cards, game);
Card card = game.getCard(objectId);
if (exile != null && exile.contains(objectId) && card != null) {
Player player = game.getPlayer(affectedControllerId);
if (player != null) {
player.lookAtCards("Hideaway by " + sourcePermanet.getIdName(), card, game);
}
}
}
// only the current or a previous controller can see the card, so always return false for reveal request
return false;
}
}