Added support for player searching another players library

Fixed Haunting Echoes and Sadistic Sacrament to use this feature
This commit is contained in:
North 2012-04-24 22:57:28 +03:00
parent b5b1d3468d
commit fa0445b544
5 changed files with 75 additions and 65 deletions

View file

@ -28,23 +28,21 @@
package mage.sets.magic2010;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.List;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardsImpl;
import mage.filter.FilterCard;
import mage.filter.common.FilterBasicLandCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
/**
*
@ -85,22 +83,33 @@ class HauntingEchoesEffect extends OneShotEffect<HauntingEchoesEffect> {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
for (Card card: player.getGraveyard().getCards(game)) {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
for (Card card: targetPlayer.getGraveyard().getCards(game)) {
if (!filter.match(card)) {
card.moveToExile(null, "", source.getId(), game);
for (Card lcard: player.getLibrary().getCards(game)) {
if (lcard.getName().equals(card.getName())) {
lcard.moveToExile(null, "", source.getId(), game);
FilterCard filterCard = new FilterCard("cards named " + card.getName());
filterCard.getName().add(card.getName());
int count = targetPlayer.getLibrary().count(filterCard, game);
TargetCardInLibrary target = new TargetCardInLibrary(count, count, filterCard);
target.setRequired(true);
player.searchLibrary(target, game, targetPlayer.getId());
List<UUID> targets = target.getTargets();
for(UUID cardId : targets){
Card libraryCard = game.getCard(cardId);
if (libraryCard != null) {
libraryCard.moveToExile(null, "", source.getId(), game);
}
}
}
}
targetPlayer.shuffleLibrary(game);
return true;
}
game.getPlayer(source.getControllerId()).lookAtCards("Haunting Echoes", new CardsImpl(Zone.PICK, player.getLibrary().getCards(game)), game);
player.shuffleLibrary(game);
return true;
return false;
}
@Override

View file

@ -39,8 +39,6 @@ import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
@ -107,11 +105,8 @@ class SadisticSacramentEffect extends OneShotEffect<SadisticSacramentEffect> {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player != null && targetPlayer != null) {
Cards targetPlayersLibrary = new CardsImpl();
targetPlayersLibrary.addAll(targetPlayer.getLibrary().getCardList());
TargetCardInLibrary target = new TargetCardInLibrary(0, amount, new FilterCard("cards to exile"));
if (player.choose(Outcome.Benefit, targetPlayersLibrary, target, game)) {
if (player.searchLibrary(target, game, targetPlayer.getId())) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Card card = targetPlayer.getLibrary().remove(targetId, game);