Added method to player to put a list of cards on the bottom of the library in any order.

This commit is contained in:
LevelX2 2013-06-14 15:18:51 +02:00
parent 043fa36618
commit 4cf951399c
2 changed files with 47 additions and 1 deletions

View file

@ -241,6 +241,18 @@ public interface Player extends MageItem, Copyable<Player> {
boolean choose(Outcome outcome, Choice choice, Game game); boolean choose(Outcome outcome, Choice choice, Game game);
boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game); boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game);
boolean playMana(ManaCost unpaid, Game game); boolean playMana(ManaCost unpaid, Game game);
/**
* Moves the cards form <cards> to the bottom of the players library.
*
* @param cards - list of cards that have to be moved
* @param game - game
* @param anyOrder - true if player can determine the order of the cards
* @param source - source ability
* @return
*/
boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder);
// set the value for X spells and abilities // set the value for X spells and abilities
int announceXMana(int min, int max, String message, Game game, Ability ability); int announceXMana(int min, int max, String message, Game game, Ability ability);

View file

@ -28,7 +28,6 @@
package mage.players; package mage.players;
import java.awt.Event;
import mage.Constants.AsThoughEffectType; import mage.Constants.AsThoughEffectType;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
@ -77,7 +76,9 @@ import java.util.*;
import mage.Constants; import mage.Constants;
import mage.Constants.SpellAbilityType; import mage.Constants.SpellAbilityType;
import mage.cards.SplitCard; import mage.cards.SplitCard;
import mage.filter.FilterCard;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.target.TargetCard;
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable { public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
@ -605,6 +606,39 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
return true; return true;
} }
@Override
public boolean putCardsOnBottomOfLibrary(Cards cards, Game game, Ability source, boolean anyOrder) {
if (cards.size() != 0) {
if (!anyOrder) {
for (UUID cardId : cards) {
Card card =game.getCard(cardId);
if (card != null) {
card.moveToZone(Constants.Zone.LIBRARY, source.getSourceId(), game, false);
}
}
} else {
TargetCard target = new TargetCard(Constants.Zone.PICK, new FilterCard("card to put on the bottom of your library"));
target.setRequired(true);
while (cards.size() > 1) {
this.choose(Constants.Outcome.Neutral, cards, target, game);
Card chosenCard = cards.get(target.getFirstTarget(), game);
if (chosenCard != null) {
cards.remove(chosenCard);
chosenCard.moveToZone(Constants.Zone.LIBRARY, source.getSourceId(), game, false);
}
target.clearChosen();
}
if (cards.size() == 1) {
Card chosenCard = cards.get(cards.iterator().next(), game);
chosenCard.moveToZone(Constants.Zone.LIBRARY, source.getSourceId(), game, false);
}
}
}
return true;
}
@Override @Override
public boolean cast(SpellAbility ability, Game game, boolean noMana) { public boolean cast(SpellAbility ability, Game game, boolean noMana) {
if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) { if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) {