@Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); if (controller != null && targetPlayer != null) { TargetCardInLibrary targetCard = new TargetCardInLibrary(filter); if (controller.searchLibrary(targetCard, game)) { Card card = game.getCard(targetCard.getFirstTarget()); if (card != null) { game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId()); if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { targetPlayer.addAttachment(card.getId(), game); } } } controller.shuffleLibrary(source, game); return true; } return false; }
@Override public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { int zcc = game.getState().getZoneChangeCounter(sourcePermanent.getId()); if (zcc == source.getSourceObjectZoneChangeCounter() || zcc == source.getSourceObjectZoneChangeCounter() + 1 || zcc == source.getSourceObjectZoneChangeCounter() + 2) { Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (permanent != null) { return permanent.addAttachment(source.getSourceId(), game); } else { Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null) { return player.addAttachment(source.getSourceId(), game); } if (!source.getTargets().isEmpty() && source.getTargets().get(0) instanceof TargetCard) { // e.g. Spellweaver Volute Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { return card.addAttachment(source.getSourceId(), game); } } } } } return false; }
game.getState().setValue("attachTo:" + card.getId(), targetPlayer.getId()); if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) { targetPlayer.addAttachment(card.getId(), game);
targetPermanent.addAttachment(sourcePermanent.getId(), game); } else if (targetPlayer != null) { targetPlayer.addAttachment(sourcePermanent.getId(), game); } else { return false;
targetPermanent.addAttachment(permanent.getId(), game); } else if (targetPlayer != null) { targetPlayer.addAttachment(permanent.getId(), game);