@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; } CardsImpl cards = new CardsImpl(); cards.addAll(controller.getLibrary().getTopCards(game, 1)); controller.revealCards(sourceObject.getIdName(), cards, game); Set<Card> cardsList = cards.getCards(game); Cards cardsToHand = new CardsImpl(); for (Card card : cardsList) { if (card.isCreature()) { cardsToHand.add(card); cards.remove(card); } } controller.moveCards(cardsToHand, Zone.HAND, source, game); return true; } }
public CardsImpl(Set<Card> cards) { for (Card card : cards) { this.add(card.getId()); } }
@Override public Card getRandom(Game game) { if (this.isEmpty()) { return null; } UUID[] cards = this.toArray(new UUID[this.size()]); MageObject object = game.getObject(cards[RandomUtil.nextInt(cards.length)]); // neccessary if permanent tokens are in the collection if (object instanceof Card) { return (Card) object; } return null; }
@Override public boolean apply(Game game, Ability source) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { CardsImpl libraryCards = new CardsImpl(); libraryCards.addAll(player.getLibrary().getCards(game)); player.moveCards(libraryCards, Zone.HAND, source, game); } } return true; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } if (player.searchLibrary(target, game)) { if (!target.getTargets().isEmpty()) { player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, tapped, false, false, null); } player.shuffleLibrary(source, game); return true; } if (forceShuffle) { player.shuffleLibrary(source, game); } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(getTargetPointer().getFirst(game, source)); if (controller == null) { return false; } CardsImpl toGraveyard = new CardsImpl(); for (Card card : controller.getLibrary().getCards(game)) { if (card != null) { toGraveyard.add(card); if (card.isLand()) { break; } } } controller.revealCards(source, toGraveyard, game); controller.moveCards(toGraveyard, Zone.GRAVEYARD, source, game); return true; } }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { CardsImpl toReveal = new CardsImpl(); Card toBattlefield = null; for (Card card : controller.getLibrary().getCards(game)) { toReveal.add(card); game.fireUpdatePlayersEvent(); if (card.isArtifact()) { toBattlefield = card; break; } } controller.revealCards(source, toReveal, game); controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game); int damage = toReveal.size(); toReveal.remove(toBattlefield); controller.putCardsOnBottomOfLibrary(toReveal, game, source, false); controller.damage(damage, source.getSourceId(), game, false, true); return true; } return false; } }
CardsImpl cards = new CardsImpl(); for (UUID uuid : PanopticMirror.getImprinted()) { Card card = game.getCard(uuid); if (card != null) { if (card.isSplitCard()) { cards.add(((SplitCard) card).getLeftHalfCard()); cards.add(((SplitCard) card).getRightHalfCard()); } else { cards.add(card); if (cards.size() == 1) { cardToCopy = cards.getCards(game).iterator().next(); } else { TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy")); controller.choose(Outcome.Copy, cards, target, game); cardToCopy = cards.get(target.getFirstTarget(), game);
public MeldCard(final MeldCard card) { super(card); this.topHalfCard = card.topHalfCard; this.bottomHalfCard = card.bottomHalfCard; this.topLastZoneChangeCounter = card.topLastZoneChangeCounter; this.bottomLastZoneChangeCounter = card.bottomLastZoneChangeCounter; this.halves = new CardsImpl(card.halves); this.isMelded = card.isMelded; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { CardsImpl toReveal = new CardsImpl(); Card nonLandCard = null; for (Card card : controller.getLibrary().getCards(game)) { toReveal.add(card); if (!card.isLand() && card.getConvertedManaCost() < 4) { nonLandCard = card; break; } } controller.revealCards(source, toReveal, game); if (nonLandCard != null && controller.chooseUse(outcome, "Cast " + nonLandCard.getLogName() + "without paying its mana cost?", source, game)) { controller.cast(nonLandCard.getSpellAbility(), game, true, new MageObjectReference(source.getSourceObject(game), game)); toReveal.remove(nonLandCard); } controller.putCardsOnBottomOfLibrary(toReveal, game, source, false); return true; } return false; }
return false; CardsImpl cards = new CardsImpl(); for (Card card : defendingPlayer.getLibrary().getCards(game)) { cards.add(card); if (card.isLand()) { break; if (!cards.isEmpty()) { ContinuousEffect effect = new BoostTargetEffect(cards.size(), 0, Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(creature, game)); game.addEffect(effect, source);
if (controller.searchLibrary(target, game)) { if (!target.getTargets().isEmpty()) { Cards cards = new CardsImpl(); for (UUID cardId : target.getTargets()) { Card card = controller.getLibrary().getCard(cardId, game); CardsImpl cardsToKeep = new CardsImpl(); if (cards.size() > 2) { cardsToKeep.addAll(cards); cardsToKeep.removeAll(targetDiscard.getTargets()); cards.removeAll(cardsToKeep);
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); if (controller != null && targetPlayer != null) { CardsImpl cards = new CardsImpl(targetPlayer.getLibrary().getTopCards(game, 3)); if (!cards.isEmpty()) { controller.lookAtCards(source, null, cards, game); TargetCard targetExile = new TargetCard(0, Integer.MAX_VALUE, Zone.LIBRARY, new FilterCard("cards to exile")); if (controller.choose(Outcome.Exile, cards, targetExile, game)) { Cards toExile = new CardsImpl(targetExile.getTargets()); controller.moveCards(toExile, Zone.EXILED, source, game); cards.removeAll(toExile); } controller.putCardsOnTopOfLibrary(cards, game, source, true); } return true; } return false; } }
public CardsImpl(Collection<UUID> cardIds) { if (cardIds != null) { this.addAll(cardIds); } }
@Override public void remove(Card card) { if (card == null) { return; } this.remove(card.getId()); }
@Override public Set<Card> getCards(Game game) { Set<Card> cards = new LinkedHashSet<>(); for (Iterator<UUID> it = this.iterator(); it.hasNext();) { // Changed to iterator because of ConcurrentModificationException UUID cardId = it.next(); Card card = game.getCard(cardId); if (card == null) { card = game.getPermanent(cardId); // needed to get TokenCard objects } if (card != null) { // this can happen during the cancelation (player concedes) of a game cards.add(card); } } return cards; }
@Override public Card get(UUID cardId, Game game) { if (this.contains(cardId)) { return game.getCard(cardId); } return null; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { TargetCard target = new TargetCardInHand(0, 2, new FilterLandCard("up to two land cards to put onto the battlefield tapped")); controller.chooseTarget(outcome, controller.getHand(), target, source, game); return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null); } return false; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null && controller.getLibrary().hasCards()) { CardsImpl cards = new CardsImpl(); for (Card card : controller.getLibrary().getCards(game)) { cards.add(card); if (!card.isLand()) { break; } } controller.revealCards(source, cards, game); controller.moveCards(cards, Zone.HAND, source, game); return true; } return false; } }