- Restore accidentally removed hardcoded Temporal Aperture

This commit is contained in:
Sol
2013-03-02 14:46:14 +00:00
parent 7b54bc2718
commit 050df94e49

View File

@@ -3,10 +3,15 @@ package forge.card.cardfactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import forge.Card;
import forge.Command;
import forge.Singletons;
import forge.card.cost.Cost;
import forge.card.mana.ManaCost;
import forge.card.spellability.Ability;
import forge.card.spellability.AbilityActivated;
import forge.card.spellability.Target;
import forge.control.input.Input;
@@ -193,5 +198,126 @@ class CardFactoryArtifacts {
ability.setStackDescription(sbStack.toString());
card.addSpellAbility(ability);
} // *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Temporal Aperture")) {
/*
* 5, Tap: Shuffle your library, then reveal the top card. Until end
* of turn, for as long as that card remains on top of your library,
* play with the top card of your library revealed and you may play
* that card without paying its mana cost. (If it has X in its mana
* cost, X is 0.)
*/
final Card[] topCard = new Card[1];
final Ability freeCast = new Ability(card, ManaCost.ZERO) {
@Override
public boolean canPlay() {
final PlayerZone lib = card.getController().getZone(ZoneType.Library);
return super.canPlay() && ((lib.size() > 0) && lib.get(0).equals(topCard[0]));
}
@Override
public void resolve() {
final Card freeCard = topCard[0];
final Player player = card.getController();
if (freeCard != null) {
if (freeCard.isLand()) {
if (player.canPlayLand(freeCard)) {
player.playLand(freeCard);
} else {
JOptionPane.showMessageDialog(null, "You can't play any more lands this turn.", "",
JOptionPane.INFORMATION_MESSAGE);
}
} else {
Singletons.getModel().getGame().getActionPlay().playCardWithoutManaCost(freeCard, player);
}
} else {
final StringBuilder sb = new StringBuilder();
sb.append("Error in ").append(cardName).append(". freeCard is null");
JOptionPane.showMessageDialog(null, sb.toString(), "", JOptionPane.INFORMATION_MESSAGE);
}
}
@Override
public boolean canPlayAI() {
return false;
}
};
freeCast.setDescription("Play the previously revealed top card of your library for free.");
final StringBuilder sb = new StringBuilder();
sb.append(cardName).append(" - play card without paying its mana cost.");
freeCast.setStackDescription(sb.toString());
class AbilityTemporalAperture extends AbilityActivated {
public AbilityTemporalAperture(final Card ca, final Cost co, final Target t) {
super(ca, co, t);
}
@Override
public AbilityActivated getCopy() {
AbilityActivated res = new AbilityTemporalAperture(getSourceCard(),
getPayCosts(), getTarget() == null ? null : new Target(getTarget()));
CardFactoryUtil.copySpellAbility(this, res);
return res;
}
private static final long serialVersionUID = -7328518969488588777L;
@Override
public void resolve() {
final PlayerZone lib = card.getController().getZone(ZoneType.Library);
if (lib.size() > 0) {
// shuffle your library
card.getController().shuffle();
// reveal the top card
topCard[0] = lib.get(0);
final StringBuilder sb = new StringBuilder();
sb.append("Revealed card:\n").append(topCard[0].getName());
JOptionPane.showMessageDialog(null, sb.toString(), card.getName(), JOptionPane.PLAIN_MESSAGE);
card.addSpellAbility(freeCast);
card.addExtrinsicKeyword("Play with the top card of your library revealed.");
Singletons.getModel().getGame().getEndOfTurn().addUntil(new Command() {
private static final long serialVersionUID = -2860753262177388046L;
@Override
public void execute() {
card.removeSpellAbility(freeCast);
card.removeExtrinsicKeyword("Play with the top card of your library revealed.");
}
});
}
} // resolve
@Override
public boolean canPlayAI() {
return false;
}
}
final Cost abCost = new Cost(card, "5 T", true);
final AbilityActivated ability = new AbilityTemporalAperture(card, abCost, null);
final StringBuilder sbStack = new StringBuilder();
sbStack.append(card).append(" - Shuffle your library, then reveal the top card.");
ability.setStackDescription(sbStack.toString());
final StringBuilder sbDesc = new StringBuilder();
sbDesc.append(abCost).append("Shuffle your library, then reveal the top card. ");
sbDesc.append("Until end of turn, for as long as that card remains on top of your ");
sbDesc.append("library, play with the top card of your library revealed ");
sbDesc.append("and you may play that card without paying its mana cost. ");
sbDesc.append("(If it has X in its mana cost, X is 0.)");
ability.setDescription(sbDesc.toString());
card.addSpellAbility(ability);
} // *************** END ************ END **************************
}
}