Example #1
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;
  }
Example #2
0
 @java.lang.Override
 public boolean apply(Game game, Ability source) {
   Player player = game.getPlayer(source.getControllerId());
   if (player.getHand().size() > 0) {
     TargetCard target = new TargetCard(Zone.HAND, filter);
     player.choose(Outcome.Benefit, player.getHand(), target, game);
     Card card = player.getHand().get(target.getFirstTarget(), game);
     if (card != null) {
       card.moveToExile(getId(), "Chrome Mox (Imprint)", source.getSourceId(), game);
       Permanent permanent = game.getPermanent(source.getSourceId());
       if (permanent != null) {
         permanent.imprint(card.getId(), game);
       }
       return true;
     }
   }
   return true;
 }
Example #3
0
  @Override
  public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
    Permanent sourcePermananent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
      if (sourcePermananent != null) {
        sourcePermananent.imprint(permanent.getId(), game);
        sourcePermananent.addInfo(
            "imprint",
            new StringBuilder("[Imprinted card - ")
                .append(permanent.getName())
                .append("]")
                .toString(),
            game);
      }
      return permanent.moveToExile(null, null, source.getSourceId(), game);
    }

    return false;
  }
Example #4
0
  @Override
  public boolean apply(Game game, Ability source) {
    Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
    Permanent eyeOfTheStorm = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (spell != null && eyeOfTheStorm != null) {
      Player spellController = game.getPlayer(spell.getControllerId());
      Card card = spell.getCard();
      if (spellController == null || card == null || !instantOrSorceryfilter.match(card, game)) {
        return false;
      }

      UUID exileZoneId =
          CardUtil.getExileZoneId(
              game, source.getSourceId(), eyeOfTheStorm.getZoneChangeCounter(game));
      if (spellController.moveCardsToExile(
          spell, source, game, true, exileZoneId, eyeOfTheStorm.getIdName())) {
        eyeOfTheStorm.imprint(card.getId(), game);

        if (eyeOfTheStorm.getImprinted() != null && eyeOfTheStorm.getImprinted().size() > 0) {
          CardsImpl copiedCards = new CardsImpl();
          for (UUID uuid : eyeOfTheStorm.getImprinted()) {
            card = game.getCard(uuid);

            // Check if owner of card is still in game
            if (card != null && game.getPlayer(card.getOwnerId()) != null) {
              if (card.isSplitCard()) {
                copiedCards.add(((SplitCard) card).getLeftHalfCard());
                copiedCards.add(((SplitCard) card).getRightHalfCard());
              } else {
                copiedCards.add(card);
              }
            }
          }

          boolean continueCasting = true;
          while (continueCasting) {
            continueCasting =
                copiedCards.size() > 1
                    && spellController.chooseUse(
                        outcome,
                        "Cast one of the copied cards without paying its mana cost?",
                        source,
                        game);

            Card cardToCopy;
            if (copiedCards.size() == 1) {
              cardToCopy = copiedCards.getCards(game).iterator().next();
            } else {
              TargetCard target = new TargetCard(1, Zone.EXILED, new FilterCard("card to copy"));
              spellController.choose(Outcome.Copy, copiedCards, target, game);
              cardToCopy = copiedCards.get(target.getFirstTarget(), game);
              copiedCards.remove(cardToCopy);
            }
            if (cardToCopy != null) {
              Card copy = game.copyCard(cardToCopy, source, source.getControllerId());
              if (spellController.chooseUse(
                  outcome, "Cast the copied card without paying mana cost?", source, game)) {
                spellController.cast(copy.getSpellAbility(), game, true);
              }
            }
          }
          return true;
        }
      }
    }
    return false;
  }