Пример #1
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;
  }
Пример #2
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 = Math.min(player.getLibrary().size(), 5);
    for (int i = 0; i < count; i++) {
      Card card = player.getLibrary().removeFromTop(game);
      if (card != null) {
        cards.add(card);
        game.setZone(card.getId(), Zone.PICK);
      }
    }
    player.revealCards("Fact or Fiction", cards, game);

    Set<UUID> opponents = game.getOpponents(source.getControllerId());
    if (!opponents.isEmpty()) {
      Player opponent = game.getPlayer(opponents.iterator().next());
      TargetCard target =
          new TargetCard(
              0, cards.size(), Zone.PICK, new FilterCard("cards to put in the first pile"));

      Cards pile1 = new CardsImpl();
      if (opponent.choose(Outcome.Neutral, cards, target, game)) {
        List<UUID> targets = target.getTargets();
        for (UUID targetId : targets) {
          Card card = cards.get(targetId, game);
          if (card != null) {
            pile1.add(card);
            cards.remove(card);
          }
        }
      }

      player.revealCards("Pile 1 (Fact or Fiction)", pile1, game);
      player.revealCards("Pile 2 (Fact or Fiction)", cards, game);

      Choice choice = new ChoiceImpl(true);
      choice.setMessage("Select a pile of cards to put into your hand:");

      StringBuilder sb = new StringBuilder("Pile 1: ");
      for (UUID cardId : pile1) {
        Card card = pile1.get(cardId, game);
        if (card != null) {
          sb.append(card.getName()).append("; ");
        }
      }
      sb.delete(sb.length() - 2, sb.length());
      choice.getChoices().add(sb.toString());

      sb = new StringBuilder("Pile 2: ");
      for (UUID cardId : cards) {
        Card card = cards.get(cardId, game);
        if (card != null) {
          sb.append(card.getName()).append("; ");
        }
      }
      sb.delete(sb.length() - 2, sb.length());
      choice.getChoices().add(sb.toString());

      Zone pile1Zone = Zone.GRAVEYARD;
      Zone pile2Zone = Zone.HAND;
      if (player.choose(Outcome.Neutral, choice, game)) {
        if (choice.getChoice().startsWith("Pile 1")) {
          pile1Zone = Zone.HAND;
          pile2Zone = Zone.GRAVEYARD;
        }
      }

      for (UUID cardUuid : pile1) {
        Card card = pile1.get(cardUuid, game);
        if (card != null) {
          card.moveToZone(pile1Zone, source.getId(), game, false);
        }
      }
      for (UUID cardUuid : cards) {
        Card card = cards.get(cardUuid, game);
        if (card != null) {
          card.moveToZone(pile2Zone, source.getId(), game, false);
        }
      }
    }

    return true;
  }
  @Override
  public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(targetPointer.getFirst(game, source));
    Player controller = game.getPlayer(source.getControllerId());
    Card sourceCard = game.getCard(source.getSourceId());
    if (player != null && controller != null) {
      if (revealAllCards) {
        this.numberCardsToReveal = new StaticValue(player.getHand().size());
      }
      int numberToReveal = this.numberCardsToReveal.calculate(game, source, this);
      if (numberToReveal > 0) {
        Cards revealedCards = new CardsImpl(Zone.HAND);
        numberToReveal = Math.min(player.getHand().size(), numberToReveal);
        if (player.getHand().size() > numberToReveal) {
          TargetCardInHand chosenCards =
              new TargetCardInHand(
                  numberToReveal,
                  numberToReveal,
                  new FilterCard("card in " + player.getLogName() + "'s hand"));
          chosenCards.setNotTarget(true);
          if (chosenCards.canChoose(player.getId(), game)
              && player.chooseTarget(
                  Outcome.Discard, player.getHand(), chosenCards, source, game)) {
            if (!chosenCards.getTargets().isEmpty()) {
              List<UUID> targets = chosenCards.getTargets();
              for (UUID targetid : targets) {
                Card card = game.getCard(targetid);
                if (card != null) {
                  revealedCards.add(card);
                }
              }
            }
          }
        } else {
          revealedCards.addAll(player.getHand());
        }

        player.revealCards(
            sourceCard != null ? sourceCard.getName() : "Discard", revealedCards, game);

        boolean result = true;
        int filteredCardsCount =
            revealedCards.count(filter, source.getSourceId(), source.getControllerId(), game);
        int numberToDiscard =
            Math.min(this.numberCardsToDiscard.calculate(game, source, this), filteredCardsCount);
        if (numberToDiscard > 0) {
          TargetCard target = new TargetCard(numberToDiscard, Zone.HAND, filter);
          if (controller.choose(Outcome.Benefit, revealedCards, target, game)) {
            for (Object targetId : target.getTargets()) {
              Card card = revealedCards.get((UUID) targetId, game);
              if (card != null) {
                if (!player.discard(card, source, game)) {
                  result = false;
                }
              }
            }
          }
        }
        return result;
      }
      return true;
    }
    return false;
  }