Ejemplo n.º 1
0
 // TODO implement may look at exile cards
 @Override
 public void mulligan(UUID playerId) {
   Player player = getPlayer(playerId);
   TargetCardInHand target =
       new TargetCardInHand(1, player.getHand().size(), new FilterCard("card to mulligan"));
   target.setNotTarget(true);
   target.setRequired(false);
   if (player.choose(Outcome.Exile, player.getHand(), target, this)) {
     int numCards = target.getTargets().size();
     for (UUID uuid : target.getTargets()) {
       Card card = player.getHand().get(uuid, this);
       if (card != null) {
         if (!mulliganedCards.containsKey(playerId)) {
           mulliganedCards.put(playerId, new CardsImpl());
         }
         player.getHand().remove(card);
         getExile().add(card);
         getState().setZone(card.getId(), Zone.EXILED);
         card.setFaceDown(true, this);
         mulliganedCards.get(playerId).add(card);
       }
     }
     int deduction = 1;
     if (freeMulligans > 0) {
       if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
         int used = usedFreeMulligans.get(player.getId());
         if (used < freeMulligans) {
           deduction = 0;
           usedFreeMulligans.put(player.getId(), used + 1);
         }
       } else {
         deduction = 0;
         {
         }
         usedFreeMulligans.put(player.getId(), 1);
       }
     }
     player.drawCards(numCards - deduction, this);
     fireInformEvent(
         new StringBuilder(player.getLogName())
             .append(" mulligans ")
             .append(numCards)
             .append(numCards == 1 ? " card" : " cards")
             .append(deduction == 0 ? " for free and draws " : " down to ")
             .append(Integer.toString(player.getHand().size()))
             .append(player.getHand().size() <= 1 ? " card" : " cards")
             .toString());
   }
 }
Ejemplo n.º 2
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.º 3
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);
     }
   }
 }
Ejemplo n.º 4
0
 @Override
 public boolean apply(Game game, Ability source) {
   Player controller = game.getPlayer(source.getControllerId());
   if (controller != null) {
     Permanent permanent =
         (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
     if (permanent != null) {
       List<UUID> imprinted = permanent.getImprinted();
       if (imprinted.size() > 0) {
         Card imprintedCard = game.getCard(imprinted.get(0));
         imprintedCard.setFaceDown(false, game);
         if (imprintedCard.getCardType().contains(CardType.CREATURE)) {
           controller.moveCards(imprintedCard, Zone.BATTLEFIELD, source, game);
         }
       }
     }
     return true;
   }
   return false;
 }