public void add(String name, Cards cards) { if (this.containsKey(name)) { this.get(name).addAll(cards); } else { this.put(name, cards.copy()); } }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Card sourceCard = game.getCard(source.getSourceId()); if (sourceCard == null) { return false; } Player player = game.getPlayer(source.getControllerId()); if (player != null && player.getLibrary().size() >= amount && player.chooseUse(outcome, new StringBuilder("Dredge ").append(sourceCard.getLogName()). append("? (").append(amount).append(" cards go from top of library to graveyard)").toString(), source, game)) { if (!game.isSimulation()) { game.informPlayers(new StringBuilder(player.getLogName()).append(" dredges ").append(sourceCard.getLogName()).toString()); } Cards cardsToGrave = new CardsImpl(); cardsToGrave.addAll(player.getLibrary().getTopCards(game, amount)); player.moveCards(cardsToGrave, Zone.GRAVEYARD, source, game); player.moveCards(sourceCard, Zone.HAND, source, game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); if (targetPlayer != null) { Cards cards = new CardsImpl(); cards.addAll(targetPlayer.getLibrary().getTopCards(game, amount)); return targetPlayer.moveCards(cards, Zone.EXILED, source, game); } 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(StaticFilters.FILTER_CARD_CREATURE, game)); controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.shuffleLibrary(source, game); return true; } return false; } }
@Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Player controller = game.getPlayer(controllerId); if (controller != null) { if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) { for (UUID targetId : targets.get(0).getTargets()) { Card card = game.getCard(targetId); if (card == null || game.getState().getZone(targetId) != Zone.GRAVEYARD) { return false; } exiledCards.add(card); } Cards cardsToExile = new CardsImpl(); cardsToExile.addAll(exiledCards); controller.moveCards(cardsToExile, Zone.EXILED, ability, game); paid = true; } } return paid; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, controller.getLibrary().size())); controller.moveCards(cards, Zone.EXILED, source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int count = controller.getLibrary().size(); Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, count)); controller.moveCards(cards, Zone.EXILED, source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); MageObject sourceObject = source.getSourceObject(game); if (player == null || targetPlayer == null || sourceObject == null) { return false; } Cards cards = new CardsImpl(); cards.addAll(player.getLibrary().getTopCards(game, amountCards.calculate(game, source, this))); player.revealCards(sourceObject.getIdName() + " - Top " + amountCards.toString() + "cards of " + targetPlayer.getName() + "\'s library", cards, game); return true; }
@Override public boolean apply(Game game, Ability source) { new ExileSourceEffect().apply(game, source); Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return false; } Cards cards = new CardsImpl(); cards.addAll(controller.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)); controller.putCardsOnTopOfLibrary(cards, game, source, false); controller.shuffleLibrary(source, game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller == null) { return false; } Cards toExile = new CardsImpl(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (TargetController.OPPONENT.equals(targetController) && playerId.equals(source.getControllerId())) { continue; } Player player = game.getPlayer(playerId); if (player != null) { toExile.addAll(player.getGraveyard()); } } controller.moveCards(toExile, Zone.EXILED, source, game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCardInLibrary targetCards = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter); Cards cards = new CardsImpl(); if (controller.searchLibrary(targetCards, game)) { cards.addAll(targetCards.getTargets()); } controller.revealCards(staticText, cards, game); controller.shuffleLibrary(source, game); if (!cards.isEmpty()) { controller.putCardsOnTopOfLibrary(cards, game, source, true); } return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); if (permanent != null && controller != null) { int amount = 0; amount += controller.getGraveyard().count(filter, game); if (amount > 0) { permanent.addCounters(CounterType.P1P1.createInstance(amount), source, game); } Cards cards = new CardsImpl(); cards.addAll(controller.getGraveyard().getCards(filter, game)); controller.moveCards(cards, Zone.EXILED, source, game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards cardsToReturn = new CardsImpl(); for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { cardsToReturn.addAll(player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)); } } controller.moveCards(cardsToReturn.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { int count = controller.getLibrary().size(); Cards cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, count)); controller.moveCards(cards, Zone.EXILED, source, game); for (Card card: controller.getGraveyard().getCards(game)) { controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true, true); } controller.shuffleLibrary(source, game); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { Cards toBattlefield = new CardsImpl(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { toBattlefield.addAll(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_BASIC_LAND, source.getSourceId(), controller.getId(), game)); } } controller.moveCards(toBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null); return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); FilterCard filter = new FilterCard("cards to put on the bottom of your library"); if (player != null) { int number = min(player.getLibrary().size(), 5); Set<Card> cards = player.getLibrary().getTopCards(game, number); Cards cardsRemaining = new CardsImpl(); cardsRemaining.addAll(cards); TargetCard target = new TargetCard(0, number, Zone.LIBRARY, filter); if (player.choose(Outcome.DrawCard, cardsRemaining, target, game)) { Cards pickedCards = new CardsImpl(target.getTargets()); cardsRemaining.removeAll(pickedCards); player.putCardsOnBottomOfLibrary(pickedCards, game, source, true); player.putCardsOnTopOfLibrary(cardsRemaining, game, source, true); return true; } } return false; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller == null || sourceObject == null) { return false; } Cards revealed = new CardsImpl(); revealed.addAll(controller.getLibrary().getTopCards(game, 10)); controller.revealCards(sourceObject.getIdName(), revealed, game); Player targetOpponent = game.getPlayer(source.getFirstTarget()); if (targetOpponent != null) { targetOpponent.moveCards(targetOpponent.getLibrary().getTopCards(game, new ChromaSanityGrindingCount(revealed).calculate(game, source, this)), Zone.GRAVEYARD, source, game); } return controller.putCardsOnBottomOfLibrary(revealed, game, source, true); }
@Override public boolean apply(Game game, Ability source) { Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (opponent != null && controller != null) { Cards cardsInHand = new CardsImpl(); cardsInHand.addAll(opponent.getHand()); if (!cardsInHand.isEmpty()) { TargetCard target = new TargetCard(1, Zone.HAND, new FilterNonlandCard()); if (controller.chooseTarget(outcome, cardsInHand, target, source, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { controller.cast(card.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); } } } return true; } return false; } }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); if (player != null && controller != null) { Cards revealedCards = new CardsImpl(); revealedCards.addAll(controller.getHand()); Card sourceCard = game.getCard(source.getSourceId()); player.revealCards((sourceCard != null ? sourceCard.getIdName() + " (" + sourceCard.getZoneChangeCounter(game) + ") (" : "Discard (") + controller.getName() + ")", revealedCards, game); TargetCard target = new TargetCard(Zone.HAND, new FilterCard()); if (player.choose(Outcome.Benefit, revealedCards, target, game)) { Card card = revealedCards.get(target.getFirstTarget(), game); if (card != null) { return player.discard(card, source, game); } } } return false; }
@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 ChoiceCreatureType(mageObject); if (controller.choose(outcome, typeChoice, game)) { 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(SubType.byDescription(typeChoice.getChoice()))); cardsToLibrary.addAll(controller.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)); controller.putCardsOnTopOfLibrary(cardsToLibrary, game, source, false); controller.shuffleLibrary(source, game); return true; } } return false; } }