Esempio n. 1
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   MageObject sourceObject = source.getSourceObject(game);
   if (controller != null && sourceObject != null) {
     Choice choice = new ChoiceImpl(true);
     choice.setMessage("Choose a creature type:");
     choice.setChoices(CardRepository.instance.getCreatureTypes());
     while (!controller.choose(Outcome.BoostCreature, choice, game)) {
       if (!controller.canRespond()) {
         return false;
       }
     }
     Cards revealedCards = new CardsImpl();
     while (controller.getLibrary().size() > 0) {
       Card card = controller.getLibrary().removeFromTop(game);
       if (card.getCardType().contains(CardType.CREATURE)
           && card.getSubtype().contains(choice.getChoice())) {
         controller.moveCards(card, Zone.BATTLEFIELD, source, game);
         break;
       }
       revealedCards.add(card);
     }
     controller.revealCards(sourceObject.getIdName(), revealedCards, game);
     controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
     controller.shuffleLibrary(source, game);
     return true;
   }
   return false;
 }
Esempio n. 2
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    if (player != null) {
      int max = amount.calculate(game, source);
      if (max != 0) {
        int numberOfCard = 0;

        while (player.getLibrary().size() > 0) {
          Card card = player.getLibrary().removeFromTop(game);
          if (card != null) {
            if (card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false)) {
              if (card.getCardType().contains(CardType.CREATURE)) {
                break;
              } else {
                numberOfCard++;
                if (numberOfCard >= max) {
                  break;
                }
              }
            }
          } else {
            return false;
          }
        }
      }
    }
    return true;
  }
Esempio n. 3
0
 @Override
 public boolean apply(Game game, Ability source) {
   Card creature = null;
   Player opponent = game.getPlayer(source.getFirstTarget());
   CardsImpl cards = new CardsImpl();
   boolean creatureFound = false;
   while (opponent.getLibrary().size() > 0 && !creatureFound) {
     Card card = opponent.getLibrary().removeFromTop(game);
     if (card != null) {
       if (card.getCardType().contains(CardType.CREATURE)) {
         creature = card;
         creatureFound = true;
       }
       if (!creatureFound) {
         cards.add(card);
       }
     }
   }
   if (!cards.isEmpty()) {
     opponent.revealCards("Telemin Performance", cards, game);
     opponent.moveCards(cards, Zone.GRAVEYARD, source, game);
   }
   if (creature != null) {
     return creature.putOntoBattlefield(
         game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
   }
   return false;
 }
Esempio n. 4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   MageObject sourceObject = source.getSourceObject(game);
   if (controller != null && sourceObject != null) {
     controller.shuffleLibrary(source, game);
     if (controller.getLibrary().size() > 0) {
       Card card = controller.getLibrary().removeFromTop(game);
       if (card != null) {
         controller.moveCardToExileWithInfo(
             card,
             source.getSourceId(),
             sourceObject.getIdName(),
             source.getSourceId(),
             game,
             Zone.LIBRARY,
             true);
         ContinuousEffect effect = new MindsDesireCastFromExileEffect();
         effect.setTargetPointer(new FixedTarget(card.getId()));
         game.addEffect(effect, source);
       }
     }
     return true;
   }
   return false;
 }
Esempio n. 5
0
 @Override
 public boolean apply(Game game, Ability source) {
   Permanent sourcePermanent =
       (Permanent)
           game.getLastKnownInformation(
               targetPointer.getFirst(game, source), Constants.Zone.BATTLEFIELD);
   if (sourcePermanent == null) {
     return false;
   }
   Player controller = game.getPlayer(source.getControllerId());
   if (controller == null) {
     return false;
   }
   Cards revealed = new CardsImpl();
   Card artifactCard = null;
   Cards nonArtifactCards = new CardsImpl();
   Player player = game.getPlayer(sourcePermanent.getControllerId());
   while (artifactCard == null && player.getLibrary().size() > 0) {
     Card card = player.getLibrary().removeFromTop(game);
     revealed.add(card);
     if (card.getCardType().contains(CardType.ARTIFACT)) artifactCard = card;
     else nonArtifactCards.add(card);
   }
   player.revealCards("Shape Anew", revealed, game);
   if (artifactCard != null) {
     artifactCard.putOntoBattlefield(
         game, Constants.Zone.LIBRARY, source.getId(), player.getId());
   }
   player.getLibrary().addAll(nonArtifactCards.getCards(game), game);
   player.shuffleLibrary(game);
   return true;
 }
Esempio n. 6
0
  @Override
  public boolean apply(Game game, Ability source) {

    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    Cards cards = new CardsImpl(Zone.PICK);
    int count = source.getManaCostsToPay().getX();
    count = Math.min(player.getLibrary().size(), count);
    boolean legendaryIncluded = false;
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
        if (filter.match(card, game)) {
          legendaryIncluded = true;
        }
        game.setZone(card.getId(), Zone.PICK);
      }
    }
    player.lookAtCards("Heroes' Podium", cards, game);

    // You may reveal a legendary creature card from among them and put it into your hand.
    if (!cards.isEmpty()
        && legendaryIncluded
        && player.chooseUse(
            outcome, "Put a legendary creature card into your hand?", source, game)) {
      if (cards.size() == 1) {
        Card card = cards.getRandom(game);
        cards.remove(card);
        card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
        return true;
      } else {
        TargetCard target = new TargetCard(Zone.PICK, filter);
        if (player.choose(outcome, cards, target, game)) {
          Card card = cards.get(target.getFirstTarget(), game);
          if (card != null) {
            cards.remove(card);
            card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
          }
        }
      }
    }

    // Put the rest on the bottom of your library in a random order
    while (cards.size() > 0) {
      Card card = cards.getRandom(game);
      if (card != null) {
        cards.remove(card);
        card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
      }
    }
    return true;
  }
Esempio n. 7
0
  @Override
  public boolean apply(Game game, Ability source) {
    boolean isMountain = false;
    Card sourceCard = game.getCard(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());

    if (player == null || sourceCard == null) {
      return false;
    }
    Cards cards = new CardsImpl(Zone.PICK);
    while (player.getLibrary().size() > 0) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
        if (card.getCardType().contains(CardType.LAND)) {
          if (card.getSubtype().contains("Mountain")) {
            isMountain = true;
          }
          break;
        }
      } else {
        break;
      }
    }
    player.revealCards(sourceCard.getName(), cards, game);
    int damage = cards.size();
    if (isMountain == true) {
      damage *= 2;
    }

    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    if (permanent != null) {
      permanent.damage(damage, source.getSourceId(), game, true, false);
    } else {
      Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
      if (targetPlayer != null) {
        targetPlayer.damage(damage, source.getSourceId(), game, false, true);
      }
    }

    TargetCard target =
        new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library"));
    target.setRequired(true);
    while (cards.size() > 1) {
      player.choose(Outcome.Neutral, cards, target, game);
      Card card = cards.get(target.getFirstTarget(), game);
      if (card != null) {
        cards.remove(card);
        card.moveToZone(Zone.PICK, source.getId(), game, false);
      }
      target.clearChosen();
    }

    return true;
  }
Esempio n. 8
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
      if (controller.getLibrary().size() > 0) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card == null) {
          return false;
        }
        controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
        if (card.getCardType().contains(CardType.CREATURE)) {
          FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
          boolean found = false;
          for (Permanent permanent :
              game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
            if (CardUtil.shareSubtypes(card, permanent, game)) {
              found = true;
              break;
            }
          }
          if (found) {
            game.informPlayers(
                sourceObject.getLogName()
                    + ": Found a creature that shares a creature type with the revealed card.");
            if (controller.chooseUse(Outcome.Benefit, "Cast the card?", source, game)) {
              controller.cast(card.getSpellAbility(), game, true);
            } else {
              game.informPlayers(
                  sourceObject.getLogName()
                      + ": "
                      + controller.getLogName()
                      + " canceled casting the card.");
              controller.getLibrary().putOnBottom(card, game);
            }
          } else {
            game.informPlayers(
                sourceObject.getLogName()
                    + ": No creature that shares a creature type with the revealed card.");
            controller.getLibrary().putOnBottom(card, game);
          }
        } else {
          game.informPlayers(
              sourceObject.getLogName() + ": Put " + card.getLogName() + " on the bottom.");
          controller.getLibrary().putOnBottom(card, game);
        }

        return true;
      }
    }
    return false;
  }
 @Override
 public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
   Player player = game.getPlayer(controllerId);
   if (player != null && player.getLibrary().size() >= numberOfCards) {
     paid = true;
     player.moveCards(
         player.getLibrary().getTopCards(game, numberOfCards),
         Zone.LIBRARY,
         Zone.GRAVEYARD,
         ability,
         game);
   }
   return paid;
 }
Esempio n. 10
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    Card card = player.getLibrary().getFromTop(game);
    if (card != null) {
      Cards cards = new CardsImpl();
      cards.add(card);
      player.lookAtCards("Explorer's Scope", cards, game);
      if (card.getCardType().contains(CardType.LAND)) {
        String message = "Put " + card.getName() + " onto the battlefield tapped?";
        if (player.chooseUse(Outcome.PutLandInPlay, message, game)) {
          if (card.putOntoBattlefield(
              game, Zone.LIBRARY, source.getId(), source.getControllerId())) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
              permanent.setTapped(true);
            }
          }
        }
      }
    }
    return true;
  }
Esempio n. 11
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. 12
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Cards cards = new CardsImpl(Zone.PICK);
    int count = Math.min(player.getLibrary().size(), 4);
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      cards.add(card);
      game.setZone(card.getId(), Zone.PICK);
    }

    if (cards.size() == 0) {
      return false;
    }
    TargetCard target1 = new TargetCard(Zone.PICK, filter1);
    if (player.choose(Outcome.Detriment, cards, target1, game)) {
      Card card = cards.get(target1.getFirstTarget(), game);
      if (card != null) {
        cards.remove(card);
        card.moveToExile(getId(), "Clone Shell (Imprint)", source.getSourceId(), game);
        card.setFaceDown(true, game);
        Permanent permanent = game.getPermanent(source.getSourceId());
        if (permanent != null) {
          permanent.imprint(card.getId(), game);
        }
      }
      target1.clearChosen();
    }

    if (cards.size() > 0) {
      TargetCard target2 = new TargetCard(Zone.PICK, filter2);
      while (player.canRespond() && cards.size() > 1) {
        player.choose(Outcome.Benefit, cards, target2, game);
        Card card = cards.get(target2.getFirstTarget(), game);
        if (card != null) {
          cards.remove(card);
          card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false);
        }
        target2.clearChosen();
      }
      Card card = cards.get(cards.iterator().next(), game);
      card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
    }

    return true;
  }
Esempio n. 13
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player != null && player.getLibrary().size() >= 200) {
     return true;
   }
   return false;
 }
Esempio n. 14
0
 @Override
 public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
   Player controller = game.getPlayer(controllerId);
   if (controller != null) {
     return controller.getLibrary().size() > 0;
   }
   return false;
 }
Esempio n. 15
0
  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;
  }
Esempio n. 16
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player != null) {
     boolean revealed =
         player
             .isTopCardRevealed(); // by looking at the cards with scry you have not to reveal the
                                   // next card
     player.setTopCardRevealed(false);
     Cards cards = new CardsImpl();
     int count = Math.min(scryNumber, player.getLibrary().size());
     if (count == 0) {
       return true;
     }
     for (int i = 0; i < count; i++) {
       Card card = player.getLibrary().removeFromTop(game);
       cards.add(card);
     }
     TargetCard target1 = new TargetCard(Zone.LIBRARY, filter1);
     target1.setRequired(false);
     // move cards to the bottom of the library
     while (player.isInGame()
         && cards.size() > 0
         && player.choose(Outcome.Detriment, cards, target1, game)) {
       Card card = cards.get(target1.getFirstTarget(), game);
       if (card != null) {
         cards.remove(card);
         player.moveCardToLibraryWithInfo(
             card, source.getSourceId(), game, Zone.LIBRARY, false, false);
       }
       target1.clearChosen();
     }
     // move cards to the top of the library
     player.putCardsOnTopOfLibrary(cards, game, source, true);
     game.fireEvent(
         new GameEvent(
             GameEvent.EventType.SCRY,
             source.getControllerId(),
             source.getSourceId(),
             source.getControllerId()));
     player.setTopCardRevealed(revealed);
     return true;
   }
   return false;
 }
Esempio n. 17
0
  @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;
  }
Esempio n. 18
0
  @Override
  public boolean apply(Game game, Ability source) {
    Cards cardsToCast = new CardsImpl();
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    MageObject sourceObject = source.getSourceObject(game);
    if (targetOpponent != null && sourceObject != null) {
      List<Card> allCards = targetOpponent.getLibrary().getTopCards(game, 7);
      Cards cards = new CardsImpl(Zone.LIBRARY, allCards);
      targetOpponent.revealCards(
          sourceObject.getIdName() + " - " + targetOpponent.getName() + "'s top library cards",
          cards,
          game);
      for (Card card : allCards) {
        if (filter.match(card, game)) {
          cardsToCast.add(card);
        }
      }
      // cast an instant or sorcery for free
      if (cardsToCast.size() > 0) {
        int numberOfSpells = 1;
        if (SpellMasteryCondition.getInstance().apply(game, source)) {
          numberOfSpells++;
        }
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {

          TargetCard target = new TargetCard(Zone.LIBRARY, filter); // zone should be ignored here
          target.setNotTarget(true);
          while (numberOfSpells > 0
              && cardsToCast.size() > 0
              && controller.chooseUse(
                  outcome,
                  "Cast an instant or sorcery card from among them for free?",
                  source,
                  game)
              && controller.choose(outcome, cardsToCast, target, game)) {
            Card card = cardsToCast.get(target.getFirstTarget(), game);
            if (card != null) {
              controller.cast(card.getSpellAbility(), game, true);
              numberOfSpells--;
              cardsToCast.remove(card);
              allCards.remove(card);
            }
            if (!controller.isInGame()) {
              return false;
            }
            target.clearChosen();
          }
        }

        targetOpponent.moveCards(allCards, Zone.LIBRARY, Zone.GRAVEYARD, source, game);
      }
      return true;
    }
    return false;
  }
Esempio n. 19
0
 @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;
 }
Esempio n. 20
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getFirstTarget());
   if (player != null && player.getLibrary().size() > 0) {
     Card card = player.getLibrary().getFromTop(game);
     Cards cards = new CardsImpl();
     cards.add(card);
     player.revealCards("Cerebral Eruption", cards, game);
     game.getState().setValue(source.getId().toString(), card);
     int damage = card.getManaCost().convertedManaCost();
     player.damage(damage, source.getId(), game, false, true);
     for (Permanent perm :
         game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
       perm.damage(damage, source.getId(), game, true, false);
     }
     return true;
   }
   return false;
 }
Esempio n. 21
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    if (player.getLibrary().size() > 0) {
      Card card = player.getLibrary().getFromTop(game);
      Cards cards = new CardsImpl();
      cards.add(card);
      player.revealCards("Pain Seer", cards, game);

      if (card != null && card.moveToZone(Zone.HAND, source.getSourceId(), game, false)) {
        player.loseLife(card.getManaCost().convertedManaCost(), game);
        return true;
      }
    }
    return false;
  }
Esempio n. 22
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player != null && controller != null) {
      Choice cardChoice = new ChoiceImpl();
      cardChoice.setChoices(CardRepository.instance.getNonLandNames());
      cardChoice.clearChoice();

      while (!controller.choose(Outcome.Exile, cardChoice, game)) {
        game.debugMessage("player canceled choosing name. retrying.");
      }

      String cardName = cardChoice.getChoice();
      game.informPlayers("CranialExtraction, named card: [" + cardName + "]");
      for (Card card : player.getGraveyard().getCards(game)) {
        if (card.getName().equals(cardName)) {
          card.moveToExile(null, "", source.getId(), game);
        }
      }
      for (Card card : player.getHand().getCards(game)) {
        if (card.getName().equals(cardName)) {
          card.moveToExile(null, "", source.getId(), game);
        }
      }
      for (Card card : player.getLibrary().getCards(game)) {
        if (card.getName().equals(cardName)) {
          card.moveToExile(null, "", source.getId(), game);
        }
      }
      controller.lookAtCards("CranialExtraction Hand", player.getHand(), game);
      controller.lookAtCards(
          "CranialExtraction Library",
          new CardsImpl(Zone.PICK, player.getLibrary().getCards(game)),
          game);
      player.shuffleLibrary(game);
    }
    return true;
  }
Esempio n. 23
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player.searchLibrary(target, game)) {
     for (UUID targetId : getTargets()) {
       Card card = player.getLibrary().getCard(targetId, game);
       if (card != null) {
         card.moveToExile(null, null, targetId, game);
       }
     }
     return true;
   }
   return false;
 }
  @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;
    }

    int highCMC = 0;
    List<Permanent> controlledArtifacts =
        game.getBattlefield()
            .getAllActivePermanents(new FilterArtifactPermanent(), controller.getId(), game);
    for (Permanent permanent : controlledArtifacts) {
      if (permanent.getSpellAbility() != null) {
        int cmc = permanent.getSpellAbility().getManaCosts().convertedManaCost();
        if (cmc > highCMC) {
          highCMC = cmc;
        }
      }
    }

    Cards cards = new CardsImpl();

    for (int i = 0; i < highCMC; i++) {
      Card card = controller.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
      }
    }
    controller.lookAtCards(sourcePermanent.getIdName(), cards, game);

    if (!cards.isEmpty()) {
      TargetCard target =
          new TargetCard(
              Zone.LIBRARY, new FilterArtifactCard("artifact card to put onto the battlefield"));
      if (target.canChoose(source.getSourceId(), controller.getId(), game)
          && controller.choose(Outcome.Benefit, cards, target, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
          controller.revealCards(sourcePermanent.getIdName(), new CardsImpl(card), game);
          cards.remove(card);
          controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
      }
    }

    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
  }
Esempio n. 25
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   Card sourceCard = game.getCard(source.getSourceId());
   if (controller == null || sourceCard == null) {
     return false;
   }
   if (controller.getLibrary().size() > 0) {
     controller.shuffleLibrary(game);
     Card card = controller.getLibrary().getFromTop(game);
     if (card == null) {
       return false;
     }
     controller.revealCards(sourceCard.getName(), new CardsImpl(card), game);
     if (card.getCardType().contains(CardType.LAND)) {
       String message = "Put " + card.getName() + " onto the battlefield?";
       if (controller.chooseUse(Outcome.PutLandInPlay, message, game)) {
         card.putOntoBattlefield(
             game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
         return sourceCard.moveToZone(Zone.HAND, source.getSourceId(), game, false);
       }
     } else {
       if (controller.chooseUse(
           outcome,
           new StringBuilder("Cast ")
               .append(card.getName())
               .append(" without paying its mana cost?")
               .toString(),
           game)) {
         return controller.cast(card.getSpellAbility(), game, true);
       }
     }
     return true;
   }
   return false;
 }
Esempio n. 26
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player sourcePlayer = game.getPlayer(source.getControllerId());
   for (UUID playerId : sourcePlayer.getInRange()) {
     Player player = game.getPlayer(playerId);
     if (player != null) {
       player.getLibrary().addAll(player.getHand().getCards(game), game);
       player.getLibrary().addAll(player.getGraveyard().getCards(game), game);
       player.shuffleLibrary(game);
       player.getHand().clear();
       player.getGraveyard().clear();
       player.drawCards(7, game);
     }
   }
   return true;
 }
Esempio n. 27
0
 @Override
 public boolean apply(Game game, Ability source) {
   boolean countered = false;
   StackObject stackObject = game.getStack().getStackObject(targetPointer.getFirst(game, source));
   if (game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
     countered = true;
   }
   if (stackObject != null) {
     Player controller = game.getPlayer(stackObject.getControllerId());
     if (controller != null) {
       controller.moveCards(
           controller.getLibrary().getTopCards(game, 2), Zone.GRAVEYARD, source, game);
     }
   }
   return countered;
 }
Esempio n. 28
0
 @Override
 public boolean apply(Game game, Ability source) {
   UUID exileId = CardUtil.getCardExileZoneId(game, source);
   Player opponent = game.getPlayer(this.getTargetPointer().getFirst(game, source));
   Player controller = game.getPlayer(source.getControllerId());
   if (opponent != null && controller != null) {
     for (int i = 0; i < 3; i++) {
       Card card = opponent.getLibrary().getFromTop(game);
       if (card != null) {
         controller.moveCardToExileWithInfo(
             card, exileId, "Ashiok, Nightmare Weaver", source.getSourceId(), game, Zone.LIBRARY);
       }
     }
     return true;
   }
   return false;
 }
Esempio n. 29
0
 @Override
 public boolean pay(
     Ability ability,
     Game game,
     UUID sourceId,
     UUID controllerId,
     boolean noMana,
     Cost costToPay) {
   Player controller = game.getPlayer(controllerId);
   if (controller != null) {
     card = controller.getLibrary().getFromTop(game);
     if (card != null) {
       paid = controller.moveCards(card, Zone.EXILED, ability, game);
     }
   }
   return paid;
 }
Esempio n. 30
0
 @Override
 public void endMulligan(UUID playerId) {
   // return cards to
   Player player = getPlayer(playerId);
   if (player != null && mulliganedCards.containsKey(playerId)) {
     for (Card card : mulliganedCards.get(playerId).getCards(this)) {
       if (card != null) {
         getExile().removeCard(card, this);
         player.getLibrary().putOnTop(card, this);
         getState().setZone(card.getId(), Zone.LIBRARY);
         card.setFaceDown(false, this);
       }
     }
     if (mulliganedCards.get(playerId).size() > 0) {
       player.shuffleLibrary(this);
     }
   }
 }