Пример #1
0
 private void playCard(@NotNull SevensPlayer inputter, Card card, Card adjacentExtremeCard) {
   if (adjacentExtremeCard.getRank() != SEVEN) {
     extremeCards.remove(adjacentExtremeCard);
   }
   extremeCards.add(card);
   playedCards.get(card.getSuit()).add(card);
   inputter.playCard(card);
 }
Пример #2
0
  @Override
  protected void acceptCastInputAndPlayer(@NotNull CardInput input, @NotNull SevensPlayer inputter)
      throws Exception {
    turnManager.assertCurrentPlayer(inputter);

    Card card = input.getCard();
    if (!inputter.getHand().contains(card)) {
      throw new UnacceptableInputException(
          "Stop cheating!  You can't play a card that's not in your hand.");
    }
    Card adjacentExtremeCard = getAdjacentExtremeCard(card);
    if (adjacentExtremeCard == null) {
      throw new UnacceptableInputException("There is nowhere to play that card.");
    }
    playCard(inputter, card, adjacentExtremeCard);

    if (inputter.getHand().isEmpty()) {
      fireEvent(new PlayerResult(WIN, singleton(inputter)));
    } else {
      turnManager.next();
    }
  }