Cards ProteanHulkSearch(Game game, Ability source) { Cards cardsPicked = new CardsImpl(Zone.PICK); Player player = game.getPlayer(source.getControllerId()); if (player != null) { GameEvent event = GameEvent.getEvent( GameEvent.EventType.SEARCH_LIBRARY, source.getControllerId(), source.getControllerId(), source.getControllerId(), Integer.MAX_VALUE); if (!game.replaceEvent(event)) { int manaCostLeftToFetch = 6; int librarySearchLimit = event.getAmount(); FilterCard filter = new FilterCreatureCard( "number of creature cards with total converted mana cost 6 or less (6 CMC left)"); filter.add( new ConvertedManaCostPredicate(ComparisonType.LessThan, manaCostLeftToFetch + 1)); TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter); target.setCardLimit(librarySearchLimit); while (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { target.choose( Outcome.PutCreatureInPlay, source.getControllerId(), source.getControllerId(), game); Card card = player.getLibrary().remove(target.getFirstTarget(), game); if (card == null) { break; } cardsPicked.add(card); game.setZone(card.getId(), Zone.PICK); game.getState().getLookedAt(source.getControllerId()).add("Protean Hulk", cardsPicked); librarySearchLimit--; if (librarySearchLimit == 0) { break; } manaCostLeftToFetch -= card.getManaCost().convertedManaCost(); filter = new FilterCreatureCard( "number of creature cards with total converted mana cost 6 or less (" + manaCostLeftToFetch + " CMC left)"); filter.add( new ConvertedManaCostPredicate(ComparisonType.LessThan, manaCostLeftToFetch + 1)); target = new TargetCardInLibrary(0, 1, filter); target.setCardLimit(librarySearchLimit); } game.fireEvent( GameEvent.getEvent( GameEvent.EventType.LIBRARY_SEARCHED, source.getControllerId(), source.getControllerId())); } } return cardsPicked; }
@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller == null || sourcePermanent == null) { return false; } for (UUID playerId : controller.getInRange()) { Player player = game.getPlayer(playerId); String playerName = new StringBuilder(player.getLogName()).append("'s").toString(); if (source.getControllerId().equals(player.getId())) { playerName = "your"; } TargetCardInLibrary target = new TargetCardInLibrary( new FilterNonlandCard( new StringBuilder("nonland card from ") .append(playerName) .append(" library") .toString())); if (controller.searchLibrary(target, game, playerId)) { UUID targetId = target.getFirstTarget(); Card card = player.getLibrary().remove(targetId, game); if (card != null) { controller.moveCardToExileWithInfo( card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); } } player.shuffleLibrary(game); } ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source)); if (jaceExileZone == null) { return true; } FilterCard filter = new FilterCard("card to cast without mana costs"); TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId()); while (jaceExileZone.count(filter, game) > 0 && controller.choose(Outcome.PlayForFree, jaceExileZone, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { if (controller.cast(card.getSpellAbility(), game, true)) { game.getExile().removeCard(card, game); } } target.clearChosen(); } return true; }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Permanent attackingCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); if (you != null && attackingCreature != null) { FilterCard filter = new FilterCard("aura that could enchant the lone attacking creature"); filter.add(new SubtypePredicate("Aura")); filter.add(new AuraCardCanAttachToPermanentId(attackingCreature.getId())); if (you.chooseUse(Outcome.Benefit, "Do you want to search your library?", source, game)) { TargetCardInLibrary target = new TargetCardInLibrary(filter); target.setNotTarget(true); if (you.searchLibrary(target, game)) { if (target.getFirstTarget() != null) { Card aura = game.getCard(target.getFirstTarget()); game.getState().setValue("attachTo:" + aura.getId(), attackingCreature); aura.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), you.getId()); return attackingCreature.addAttachment(aura.getId(), game); } } } you.shuffleLibrary(game); } return false; }
@Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); if (you != null) { if (you.getLibrary().size() > 0) { TargetCardInLibrary target = new TargetCardInLibrary(filter); if (you.searchLibrary(target, game, you.getId())) { UUID targetId = target.getFirstTarget(); Card card = you.getLibrary().remove(targetId, game); if (card != null) { you.cast(card.getSpellAbility(), game, true); } } } you.shuffleLibrary(game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); if (player == null) { return false; } TargetCardInLibrary target = new TargetCardInLibrary(); if (player.searchLibrary(target, game)) { Card card = player.getLibrary().remove(target.getFirstTarget(), game); if (card != null) { card.moveToZone(Zone.EXILED, source.getSourceId(), game, false); player.shuffleLibrary(game); StringBuilder sb = new StringBuilder(); sb.append("Have ").append(player.getLogName()).append(" put ").append(card.getName()); sb.append(" in his hand? If none of his opponents says yes, he'll draw three cards."); boolean putInHand = false; Set<UUID> opponents = game.getOpponents(source.getControllerId()); for (UUID opponentUuid : opponents) { Player opponent = game.getPlayer(opponentUuid); if (opponent != null && !putInHand && opponent.chooseUse(Outcome.Neutral, sb.toString(), source, game)) { putInHand = true; } } if (putInHand) { game.getExile().getPermanentExile().remove(card); card.moveToZone(Zone.HAND, source.getSourceId(), game, false); } else { player.drawCards(3, game); } return true; } } player.shuffleLibrary(game); return false; }