Esempio n. 1
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. 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(this.getTargetPointer().getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    if (player == null || controller == null) {
      return false;
    }

    Cards cards = new CardsImpl();
    cards.addAll(player.getLibrary().getTopCards(game, 7));
    controller.moveCards(cards, Zone.EXILED, source, game);
    if (cards.getCards(new FilterCreatureCard(), game).size() > 0) {
      TargetCard target = new TargetCard(Zone.EXILED, new FilterCreatureCard());
      if (controller.chooseTarget(outcome, cards, target, source, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
          controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, false, null);
        }
      }
    }
    return true;
  }
Esempio n. 4
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player you = game.getPlayer(source.getControllerId());
    Cards cards = new CardsImpl();
    FilterCard filterWhite = new FilterCard("white card");
    filterWhite.add(new ColorPredicate(ObjectColor.WHITE));
    FilterCard filterBlue = new FilterCard("blue card");
    filterBlue.add(new ColorPredicate(ObjectColor.BLUE));
    FilterCard filterBlack = new FilterCard("black card");
    filterBlack.add(new ColorPredicate(ObjectColor.BLACK));
    FilterCard filterRed = new FilterCard("red card");
    filterRed.add(new ColorPredicate(ObjectColor.RED));
    FilterCard filterGreen = new FilterCard("green card");
    filterGreen.add(new ColorPredicate(ObjectColor.GREEN));
    TargetCardInLibrary targetWhite = new TargetCardInLibrary(filterWhite);
    TargetCardInLibrary targetBlue = new TargetCardInLibrary(filterBlue);
    TargetCardInLibrary targetBlack = new TargetCardInLibrary(filterBlack);
    TargetCardInLibrary targetRed = new TargetCardInLibrary(filterRed);
    TargetCardInLibrary targetGreen = new TargetCardInLibrary(filterGreen);

    if (you != null && you.getLibrary().size() > 0) {
      if (you.searchLibrary(targetWhite, game)) {
        if (targetWhite.getTargets().size() > 0) {
          for (UUID cardId : (List<UUID>) targetWhite.getTargets()) {
            Card card = you.getLibrary().remove(cardId, game);
            if (card != null) {
              cards.add(card);
            }
          }
        }
      }
    }
    if (you != null && you.getLibrary().size() > 0) {
      if (you.searchLibrary(targetBlue, game)) {
        if (targetBlue.getTargets().size() > 0) {
          for (UUID cardId : (List<UUID>) targetBlue.getTargets()) {
            Card card = you.getLibrary().remove(cardId, game);
            if (card != null) {
              cards.add(card);
            }
          }
        }
      }
    }
    if (you != null && you.getLibrary().size() > 0) {
      if (you.searchLibrary(targetBlack, game)) {
        if (targetBlack.getTargets().size() > 0) {
          for (UUID cardId : (List<UUID>) targetBlack.getTargets()) {
            Card card = you.getLibrary().remove(cardId, game);
            if (card != null) {
              cards.add(card);
            }
          }
        }
      }
    }
    if (you != null && you.getLibrary().size() > 0) {
      if (you.searchLibrary(targetRed, game)) {
        if (targetRed.getTargets().size() > 0) {
          for (UUID cardId : (List<UUID>) targetRed.getTargets()) {
            Card card = you.getLibrary().remove(cardId, game);
            if (card != null) {
              cards.add(card);
            }
          }
        }
      }
    }
    if (you != null && you.getLibrary().size() > 0) {
      if (you.searchLibrary(targetGreen, game)) {
        if (targetGreen.getTargets().size() > 0) {
          for (UUID cardId : (List<UUID>) targetGreen.getTargets()) {
            Card card = you.getLibrary().remove(cardId, game);
            if (card != null) {
              cards.add(card);
            }
          }
        }
      }
    }
    if (you != null) {
      you.revealCards("Conflux", cards, game);
      for (Card card : cards.getCards(game)) {
        card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
      }
      you.shuffleLibrary(source, game);
    }
    return true;
  }
Esempio n. 5
0
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
      return false;
    }

    Cards cards = new CardsImpl();
    int count = Math.min(player.getLibrary().size(), 3);
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
      }
    }
    player.revealCards("Jace, Architect of Thought", cards, game);

    Set<UUID> opponents = game.getOpponents(source.getControllerId());
    if (!opponents.isEmpty()) {
      Player opponent = null;
      if (opponents.size() > 1) {
        TargetOpponent targetOpponent = new TargetOpponent();
        if (player.chooseTarget(Outcome.Neutral, targetOpponent, source, game)) {
          opponent = game.getPlayer(targetOpponent.getFirstTarget());
        }
      }
      if (opponent == null) {
        opponent = game.getPlayer(opponents.iterator().next());
      }

      TargetCard target =
          new TargetCard(
              0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile"));
      target.setRequired(false);
      Cards pile1 = new CardsImpl();
      if (opponent.choose(Outcome.Neutral, cards, target, game)) {
        for (UUID targetId : (List<UUID>) target.getTargets()) {
          Card card = cards.get(targetId, game);
          if (card != null) {
            pile1.add(card);
            cards.remove(card);
          }
        }
      }
      player.revealCards("Pile 1 (Jace, Architect of Thought)", pile1, game);
      player.revealCards("Pile 2 (Jace, Architect of Thought)", cards, game);

      postPileToLog("Pile 1", pile1.getCards(game), game);
      postPileToLog("Pile 2", cards.getCards(game), game);

      Cards cardsToHand = cards;
      Cards cardsToLibrary = pile1;
      List<Card> cardPile1 = new ArrayList<>();
      List<Card> cardPile2 = new ArrayList<>();
      for (UUID cardId : pile1) {
        cardPile1.add(game.getCard(cardId));
      }
      for (UUID cardId : cards) {
        cardPile2.add(game.getCard(cardId));
      }

      boolean pileChoice =
          player.choosePile(
              Outcome.Neutral,
              "Choose a pile to to put into your hand.",
              cardPile1,
              cardPile2,
              game);
      if (pileChoice) {
        cardsToHand = pile1;
        cardsToLibrary = cards;
      }
      game.informPlayers(player.getLogName() + " chose pile" + (pileChoice ? "1" : "2"));

      for (UUID cardUuid : cardsToHand) {
        Card card = cardsToHand.get(cardUuid, game);
        if (card != null) {
          player.moveCards(card, null, Zone.HAND, source, game);
        }
      }

      player.putCardsOnBottomOfLibrary(cardsToLibrary, game, source, true);
      return true;
    }
    return false;
  }