@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getObject(source.getSourceId()); if (controller != null && mageObject != null) { Choice typeChoice = new ChoiceImpl(true); typeChoice.setMessage("Choose creature type"); typeChoice.setChoices(CardRepository.instance.getCreatureTypes()); while (!controller.choose(outcome, typeChoice, game)) { if (!controller.canRespond()) { return false; } } if (!game.isSimulation()) { game.informPlayers( mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice()); } Cards cardsToLibrary = new CardsImpl(); FilterCreatureCard filter = new FilterCreatureCard(); filter.add(new SubtypePredicate(typeChoice.getChoice())); cardsToLibrary.addAll( controller .getGraveyard() .getCards(filter, source.getSourceId(), source.getControllerId(), game)); controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false); controller.shuffleLibrary(game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards cards = new CardsImpl(); cards.addAll(controller.getGraveyard().getCards(new FilterCreatureCard(), game)); controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.shuffleLibrary(source, game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { boolean revealed = player .isTopCardRevealed(); // by looking at the cards with scry you have not to reveal the // next card player.setTopCardRevealed(false); Cards cards = new CardsImpl(); int count = Math.min(scryNumber, player.getLibrary().size()); if (count == 0) { return true; } for (int i = 0; i < count; i++) { Card card = player.getLibrary().removeFromTop(game); cards.add(card); } TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1); target1.setRequired(false); // move cards to the bottom of the library while (player.isInGame() && cards.size() > 0 && player.choose(Outcome.Detriment, cards, target1, game)) { Card card = cards.get(target1.getFirstTarget(), game); if (card != null) { cards.remove(card); player.moveCardToLibraryWithInfo( card, source.getSourceId(), game, Zone.LIBRARY, false, false); } target1.clearChosen(); } // move cards to the top of the library player.putCardsOnTopOfLibrary(cards, game, source, true); game.fireEvent( new GameEvent( GameEvent.EventType.SCRY, source.getControllerId(), source.getSourceId(), source.getControllerId())); player.setTopCardRevealed(revealed); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { List<Card> cards = new ArrayList<>(); List<Permanent> permanents = new ArrayList<>(); for (UUID targetId : targetPointer.getTargets(game, source)) { switch (game.getState().getZone(targetId)) { case BATTLEFIELD: Permanent permanent = game.getPermanent(targetId); if (permanent != null) { permanents.add(permanent); } break; case GRAVEYARD: Card card = game.getCard(targetId); if (card != null && game.getState().getZone(targetId).equals(Zone.GRAVEYARD)) { cards.add(card); } break; } } // Plow Under // 10/4/2004 The owner decides the order the two lands are stacked there. while (!cards.isEmpty()) { Card card = cards.iterator().next(); if (card != null) { Player owner = game.getPlayer(card.getOwnerId()); Cards cardsPlayer = new CardsImpl(); for (Iterator<Card> iterator = cards.iterator(); iterator.hasNext(); ) { Card next = iterator.next(); if (next.getOwnerId().equals(owner.getId())) { cardsPlayer.add(next); iterator.remove(); } } if (onTop) { owner.putCardsOnTopOfLibrary(cardsPlayer, game, source, true); } else { owner.putCardsOnBottomOfLibrary(cardsPlayer, game, source, true); } } } while (!permanents.isEmpty()) { Permanent permanent = permanents.iterator().next(); if (permanent != null) { Player owner = game.getPlayer(permanent.getOwnerId()); Cards cardsPlayer = new CardsImpl(); for (Iterator<Permanent> iterator = permanents.iterator(); iterator.hasNext(); ) { Permanent next = iterator.next(); if (next.getOwnerId().equals(owner.getId())) { cardsPlayer.add(next); iterator.remove(); } } if (onTop) { owner.putCardsOnTopOfLibrary(cardsPlayer, game, source, true); } else { owner.putCardsOnBottomOfLibrary(cardsPlayer, game, source, true); } } } return true; } return false; }