[DKA] Tower Geist

Rework of LookLibrary effects
This commit is contained in:
LevelX 2012-02-11 14:13:08 +01:00
parent 885c43d374
commit fa587ce7b7
3 changed files with 171 additions and 51 deletions

View file

@ -0,0 +1,75 @@
/*
*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*
*/
package mage.sets.darkascension;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
/**
*
* @author LevelX
*/
public class TowerGeist extends CardImpl<TowerGeist> {
public TowerGeist(UUID ownerId) {
super(ownerId, 53, "Tower Geist", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{U}");
this.expansionSetCode = "DKA";
this.subtype.add("Spirit");
this.color.setBlue(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Tower Geist enters the battlefield, look at the top two cards of your library. Put one of them into your hand and the other into your graveyard.
this.addAbility(new EntersBattlefieldTriggeredAbility(
new LookLibraryAndPickControllerEffect(new StaticValue(2), false, new StaticValue(1), new FilterCard(), Zone.GRAVEYARD, false, false)));
}
public TowerGeist(final TowerGeist card) {
super(card);
}
@Override
public TowerGeist copy() {
return new TowerGeist(this);
}
}

View file

@ -46,21 +46,32 @@ import mage.target.TargetCard;
*
* @author LevelX
*/
public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEffect {
protected FilterCard filter; // which kind of cards to reveal
protected DynamicValue numberToPick;
protected boolean revealPickedCards = true;
protected Zone targetPickedCards = Zone.HAND; // Hand, graveyard, library bottom, library top
protected Zone targetPickedCards = Zone.HAND; // HAND
protected int foundCardsToPick = 0;
protected boolean optional;
public LookLibraryAndPickControllerEffect(DynamicValue numberOfCards, boolean mayShuffleAfter, DynamicValue numberToPick, FilterCard pickFilter, boolean putOnTop) {
super(numberOfCards, mayShuffleAfter, putOnTop);
this(numberOfCards, mayShuffleAfter, numberToPick, pickFilter, putOnTop, true);
}
public LookLibraryAndPickControllerEffect(DynamicValue numberOfCards, boolean mayShuffleAfter, DynamicValue numberToPick, FilterCard pickFilter, boolean putOnTop, boolean reveal) {
this(numberOfCards, mayShuffleAfter, numberToPick, pickFilter, Zone.LIBRARY, putOnTop, reveal);
}
public LookLibraryAndPickControllerEffect(DynamicValue numberOfCards, boolean mayShuffleAfter, DynamicValue numberToPick, FilterCard pickFilter, Zone targetZoneLookedCards, boolean putOnTop, boolean reveal) {
super(Outcome.DrawCard, numberOfCards, mayShuffleAfter, targetZoneLookedCards, putOnTop);
this.numberToPick = numberToPick;
this.filter = pickFilter;
this.revealPickedCards = reveal;
}
public LookLibraryAndPickControllerEffect(final LookLibraryAndPickControllerEffect effect) {
public LookLibraryAndPickControllerEffect(final LookLibraryAndPickControllerEffect effect) {
super(effect);
this.numberToPick = effect.numberToPick.clone();
this.filter = effect.filter.copy();
@ -82,24 +93,32 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
@Override
protected void actionWithSelectedCards(Cards cards, Game game, Ability source, String windowName) {
// You may reveal a creature card from among them and put it into your hand.
Player player = game.getPlayer(source.getControllerId());
if (player != null && foundCardsToPick > 0 && player.chooseUse(Outcome.DrawCard, "Do you wish to reveal "+filter.getMessage()+" and put it into your hand?", game)) {
FilterCard pickFilter = filter.copy();
pickFilter.setMessage(filter.getMessage()+" to reveal and put into your hand");
TargetCard target = new TargetCard(Zone.PICK, pickFilter);
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(targetPickedCards, source.getId(), game, false);
if (revealPickedCards) {
Cards reveal = new CardsImpl(Zone.OUTSIDE);
reveal.add(card);
player.revealCards(windowName, reveal, game);
}
}
}
if (player != null && foundCardsToPick > 0) {
if (!optional || player.chooseUse(Outcome.DrawCard, "Do you wish to reveal "+filter.getMessage()+" and put it into your hand?", game)) {
FilterCard pickFilter = filter.copy();
// Set the pick message
StringBuilder sb = new StringBuilder(filter.getMessage()).append(" to ");
if (revealPickedCards) {
sb.append("reveal and ");
}
sb.append("put into your hand");
pickFilter.setMessage(sb.toString());
TargetCard target = new TargetCard(Zone.PICK, pickFilter);
if (player.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(targetPickedCards, source.getId(), game, false);
if (revealPickedCards) {
Cards reveal = new CardsImpl(Zone.OUTSIDE);
reveal.add(card);
player.revealCards(windowName, reveal, game);
}
}
}
}
}
}
@ -107,16 +126,24 @@ public class LookLibraryAndPickControllerEffect extends LookLibraryControllerEff
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
if (numberToPick.calculate(null, null) > 0) {
sb.append(". You may reveal a ");
sb.append(filter.getMessage()).append(" from among them and put it into your ").append(targetPickedCards.toString().toLowerCase());
sb.append(". Put the rest ");
if (putOnTop)
sb.append("back ");
else
sb.append("on the bottom of your library ");
sb.append("in any order");
if (revealPickedCards) {
sb.append(". You may reveal a ");
sb.append(filter.getMessage()).append(" from among them and put it into your ");
} else {
sb.append(". Put one of them into your ");
}
sb.append(targetPickedCards.toString().toLowerCase());
if (targetZoneLookedCards == Zone.LIBRARY) {
sb.append(". Put the rest ");
if (putOnTop)
sb.append("back ");
else
sb.append("on the bottom of your library ");
sb.append("in any order");
} else if (targetZoneLookedCards == Zone.GRAVEYARD) {
sb.append(" and the other into your graveyard");
}
}
// get text frame from super class and inject action text
return setText(mode, sb.toString());

View file

@ -54,6 +54,7 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
protected DynamicValue numberOfCards;
protected boolean mayShuffleAfter = false;
protected boolean putOnTop = true; // if false on put back on bottom of library
protected Zone targetZoneLookedCards; // GRAVEYARD, LIBRARY
public LookLibraryControllerEffect() {
this(1);
@ -75,11 +76,16 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
this(new StaticValue(numberOfCards), mayShuffleAfter, putOnTop);
}
public LookLibraryControllerEffect(DynamicValue numberOfCards, boolean mayShuffleAfter, boolean putOnTop) {
super(Outcome.Benefit);
this.numberOfCards = numberOfCards;
this.mayShuffleAfter = mayShuffleAfter;
this.putOnTop = putOnTop;
public LookLibraryControllerEffect(DynamicValue numberOfCards, boolean mayShuffleAfter, boolean putOnTop) {
this(Outcome.Benefit, numberOfCards, mayShuffleAfter, Zone.LIBRARY, putOnTop);
}
public LookLibraryControllerEffect(Outcome outcome, DynamicValue numberOfCards, boolean mayShuffleAfter, Zone targetZoneLookedCards, boolean putOnTop) {
super(outcome);
this.numberOfCards = numberOfCards;
this.mayShuffleAfter = mayShuffleAfter;
this.targetZoneLookedCards = targetZoneLookedCards;
this.putOnTop = putOnTop;
}
@ -87,6 +93,7 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
super(effect);
this.numberOfCards = effect.numberOfCards.clone();
this.mayShuffleAfter = effect.mayShuffleAfter;
this.targetZoneLookedCards = effect.targetZoneLookedCards;
this.putOnTop = effect.putOnTop;
}
@ -154,22 +161,33 @@ public class LookLibraryControllerEffect extends OneShotEffect<LookLibraryContro
* @param game
*/
protected void putCardsBack(Ability source, Player player, Cards cards, Game game) {
TargetCard target = new TargetCard(Zone.PICK, new FilterCard(this.getPutBackText()));
target.setRequired(true);
while (cards.size() > 1) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getId(), game, putOnTop);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
}
}
switch(targetZoneLookedCards) {
case LIBRARY:
TargetCard target = new TargetCard(Zone.PICK, new FilterCard(this.getPutBackText()));
target.setRequired(true);
while (cards.size() > 1) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(targetZoneLookedCards, source.getId(), game, putOnTop);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(targetZoneLookedCards, source.getId(), game, true);
}
break;
case GRAVEYARD:
for (Card card : cards.getCards(game)) {
card.moveToZone(Zone.GRAVEYARD, source.getId(), game, true);
}
break;
default:
// not supported yet
}
}
/**
* Check to shuffle library if allowed