forked from External/mage
[DKA] Tower Geist
Rework of LookLibrary effects
This commit is contained in:
parent
885c43d374
commit
fa587ce7b7
3 changed files with 171 additions and 51 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue