public void putCardToTopXPos(Card card, int pos, Game game) { if (card != null && pos > -1) { LinkedList<Card> save = new LinkedList<>(); int idx = 1; while (hasCards() && idx < pos) { idx++; save.add(removeFromTop(game)); } putOnTop(card, game); while (!save.isEmpty()) { putOnTop(save.removeLast(), game); } } }
/** * Return a card back to top. * * @param game Game context */ @Override public void undoAction(Game game) { for (int index = drawnCards.size() - 1; index >= 0; index--) { Card card = drawnCards.get(index); player.getHand().remove(card); player.getLibrary().putOnTop(card, game); } } }
public void putOnTop(Card card, Game game) { if (card.isOwnedBy(playerId)) { card.setZone(Zone.LIBRARY, game); library.addFirst(card.getId()); } else { game.getPlayer(card.getOwnerId()).getLibrary().putOnTop(card, game); } }
/** * Swap cards between specified card from library and any hand card. * * @param game * @param card Card to put to player's hand */ private static void swapWithAnyCard(Game game, Player player, Card card, Zone zone) { // Put the card in Exile to start. Otherwise the game doesn't know where to remove the card from. game.getExile().getPermanentExile().add(card); game.setZone(card.getId(), Zone.EXILED); switch (zone) { case BATTLEFIELD: card.putOntoBattlefield(game, Zone.EXILED, null, player.getId()); break; case LIBRARY: card.setZone(Zone.LIBRARY, game); game.getExile().getPermanentExile().remove(card); player.getLibrary().putOnTop(card, game); break; case STACK: card.cast(game, Zone.EXILED, card.getSpellAbility(), player.getId()); default: card.moveToZone(zone, null, game, false); } logger.info("Added card to player's " + zone.toString() + ": " + card.getName() + ", player = " + player.getName()); }
player.getLibrary().putOnTop(card, this);
game.setZone(card.getId(), Zone.COMMAND); } else { player.getLibrary().putOnTop(card, game);
for (Card card : chooseOrder( "order to put on top of library (last chosen will be topmost)", cards, owner, game)) { game.getPlayer(card.getOwnerId()).getLibrary().putOnTop(card, game);