Ejemplo n.º 1
0
 @Override
 public boolean apply(Game game, Ability source) {
   UUID exileId = CardUtil.getCardExileZoneId(game, source);
   for (UUID opponentId : game.getOpponents(source.getControllerId())) {
     Player opponent = game.getPlayer(opponentId);
     if (opponent != null) {
       Cards cards = new CardsImpl();
       cards.addAll(opponent.getHand());
       for (UUID cardId : cards) {
         Card card = game.getCard(cardId);
         if (card != null) {
           card.moveToExile(exileId, "Ashiok, Nightmare Weaver", source.getSourceId(), game);
         }
       }
       cards.clear();
       cards.addAll(opponent.getGraveyard());
       for (UUID cardId : cards) {
         Card card = game.getCard(cardId);
         if (card != null) {
           card.moveToExile(exileId, "Ashiok, Nightmare Weaver", source.getSourceId(), game);
         }
       }
     }
   }
   return true;
 }
Ejemplo n.º 2
0
  private void exileCards(Player player, int count, Ability source, Game game) {
    int amount =
        Math.min(
            count,
            player.getHand().size()
                + game.getBattlefield().getAllActivePermanents(player.getId()).size());

    while (amount > 0) {
      Target target = new TargetControlledPermanent(0, 1, filter, true);
      if (target.canChoose(player.getId(), game)
          && player.choose(Outcome.Exile, target, source.getSourceId(), game)) {

        for (UUID targetId : target.getTargets()) {
          Permanent chosen = game.getPermanent(targetId);
          if (chosen != null) {
            chosen.moveToExile(source.getId(), "Descent into Madness", source.getSourceId(), game);
            amount--;
          }
        }
      }

      if (amount > 0) {
        TargetCard targetInHand = new TargetCard(Zone.HAND, filterInHand);
        if (targetInHand.canChoose(player.getId(), game)
            && player.choose(Outcome.Exile, player.getHand(), targetInHand, game)) {

          Card card = player.getHand().get(targetInHand.getFirstTarget(), game);
          if (card != null) {
            card.moveToExile(source.getId(), "Descent into Madness", source.getSourceId(), game);
            amount--;
          }
        }
      }
    }
  }
Ejemplo n.º 3
0
 @Override
 public boolean replaceEvent(GameEvent event, Ability source, Game game) {
   Card card = game.getCard(source.getFirstTarget());
   if (card != null) {
     card.moveToExile(null, "", source.getId(), game);
   }
   return true;
 }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
0
  @Override
  public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (card == null || permanent == null) {
      return false;
    }
    card.moveToExile(null, "Dimir Doppelganger", source.getSourceId(), game);
    Card cardToCopy = card.copy();
    cardToCopy.assignNewId();
    permanent.setName(cardToCopy.getName());
    permanent.getPower().setValue(cardToCopy.getPower().getValue());
    permanent.getToughness().setValue(cardToCopy.getToughness().getValue());
    permanent.getColor(game).setColor(cardToCopy.getColor(game));
    permanent.getManaCost().clear();
    permanent.getManaCost().add(cardToCopy.getManaCost());
    permanent.getCardType().clear();
    for (CardType type : cardToCopy.getCardType()) {
      if (!permanent.getCardType().contains(type)) {
        permanent.getCardType().add(type);
      }
    }
    permanent.getSubtype(game).clear();
    for (String type : cardToCopy.getSubtype(game)) {
      if (!permanent.getSubtype(game).contains(type)) {
        permanent.getSubtype(game).add(type);
      }
    }
    permanent.getSupertype().clear();
    for (String type : cardToCopy.getSupertype()) {
      if (!permanent.getSupertype().contains(type)) {
        permanent.getSupertype().add(type);
      }
    }
    permanent.removeAllAbilities(source.getSourceId(), game);
    // gains ability of Dimir Doppelganger
    Ability dimirDoppelgangerAbility =
        new SimpleActivatedAbility(
            Zone.BATTLEFIELD, new DimirDoppelgangerEffect(), new ManaCostsImpl("{1}{U}{B}"));
    dimirDoppelgangerAbility.addTarget(
        new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard")));
    permanent.addAbility(dimirDoppelgangerAbility, source.getSourceId(), game);

    for (Ability ability : cardToCopy.getAbilities()) {
      if (!permanent.getAbilities().contains(ability)) {
        permanent.addAbility(ability, source.getSourceId(), game);
      }
    }
    return true;
  }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
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;
  }
Ejemplo n.º 8
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;
 }
Ejemplo n.º 9
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player targetPlayer = game.getPlayer(source.getFirstTarget());
   Player controller = game.getPlayer(source.getControllerId());
   if (targetPlayer != null && controller != null) {
     TargetCardInYourGraveyard target = new TargetCardInYourGraveyard();
     target.setRequired(true);
     if (targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) {
       Card card = game.getCard(target.getFirstTarget());
       if (card != null) {
         targetPlayer.getGraveyard().remove(card);
         card.moveToExile(null, "", source.getId(), game);
         if (card.getCardType().contains(CardType.CREATURE)) {
           controller.gainLife(2, game);
         }
       }
       return true;
     }
   }
   return false;
 }