Esempio n. 1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller == null) {
     return false;
   }
   Cards cards = new CardsImpl(Zone.LIBRARY);
   cards.addAll(controller.getLibrary().getTopCards(game, 7));
   if (!cards.isEmpty()) {
     TargetCard target =
         new TargetCard(
             Zone.LIBRARY, new FilterCreatureCard("creature card to put on the battlefield"));
     if (controller.choose(Outcome.PutCreatureInPlay, cards, target, game)) {
       Card card = cards.get(target.getFirstTarget(), game);
       if (card != null) {
         cards.remove(card);
         controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
       }
     }
     if (cards.size() > 0) {
       controller.putCardsOnBottomOfLibrary(cards, game, source, true);
     }
   }
   return true;
 }
Esempio n. 2
0
 @Override
 public boolean apply(Game game, Ability source) {
   TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
   Player player = game.getPlayer(source.getControllerId());
   if (player.searchLibrary(target, game)) {
     if (target.getTargets().size() > 0) {
       Cards revealed = new CardsImpl();
       for (UUID cardId : target.getTargets()) {
         Card card = player.getLibrary().getCard(cardId, game);
         revealed.add(card);
       }
       player.revealCards("Kodama's Reach", revealed, game);
       if (target.getTargets().size() == 2) {
         TargetCard target2 = new TargetCard(Zone.PICK, filter);
         player.choose(Outcome.Benefit, revealed, target2, game);
         Card card = revealed.get(target2.getFirstTarget(), game);
         if (card != null) {
           player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
           revealed.remove(card);
         }
         card = revealed.getCards(game).iterator().next();
         if (card != null) {
           player.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.LIBRARY);
         }
       } else if (target.getTargets().size() == 1) {
         Card card = revealed.getCards(game).iterator().next();
         if (card != null) {
           player.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId(), true);
         }
       }
     }
     player.shuffleLibrary(game);
     return true;
   }
   player.shuffleLibrary(game);
   return false;
 }
Esempio n. 3
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player != null) {
     Cards cardsPicked = this.ProteanHulkSearch(game, source);
     for (UUID cardId : cardsPicked) {
       Card card = game.getCard(cardId);
       if (card != null) {
         player.putOntoBattlefieldWithInfo(card, game, Zone.PICK, source.getSourceId());
       }
     }
     player.shuffleLibrary(game);
     return true;
   }
   return false;
 }
Esempio n. 4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card creatureCard = game.getCard(this.getTargetPointer().getFirst(game, source));
   Player controller = game.getPlayer(source.getControllerId());
   if (creatureCard != null && controller != null) {
     boolean result = false;
     if (game.getState().getZone(creatureCard.getId()).equals(Zone.GRAVEYARD)) {
       result =
           controller.putOntoBattlefieldWithInfo(
               creatureCard, game, Zone.GRAVEYARD, source.getSourceId());
     }
     controller.loseLife(creatureCard.getManaCost().convertedManaCost(), game);
     return result;
   }
   return false;
 }
Esempio n. 5
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    int cmc = 0;
    for (Cost cost : source.getCosts()) {
      if (cost instanceof PayVariableLoyaltyCost) {
        cmc = ((PayVariableLoyaltyCost) cost).getAmount();
      }
    }

    FilterCard filter =
        new FilterCreatureCard(
            new StringBuilder("creature card with converted mana cost {")
                .append(cmc)
                .append("} exiled with Ashiok, Nightmare Weaver")
                .toString());
    filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, cmc));
    Target target = new TargetCardInExile(filter, CardUtil.getCardExileZoneId(game, source));

    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
      if (player.chooseTarget(Outcome.PutCreatureInPlay, target, source, game)) {
        Card card = game.getCard(target.getFirstTarget());
        if (card != null
            && player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) {
          Permanent permanent = game.getPermanent(card.getId());
          if (permanent != null) {
            permanent.changeControllerId(source.getControllerId(), game);
          }
          ContinuousEffectImpl effect = new AshiokNightmareWeaverAddTypeEffect();
          effect.setTargetPointer(new FixedTarget(card.getId()));
          game.addEffect(effect, source);
          return true;
        }
      }
    }
    return false;
  }