示例#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
 @Nullable
 private Card getAdjacentExtremeCard(@NotNull Card card) {
   if (card.getRank() == SEVEN) {
     if (extremeCards.isEmpty()) {
       // You can only start the game with the seven of diamonds.
       return card == SEVEN_OF_DIAMONDS ? SEVEN_OF_DIAMONDS : null;
     } else {
       return card;
     }
   }
   return extremeCards
       .stream()
       .filter(extreme -> isAdjacent(card, extreme))
       .findAny()
       .orElse(null);
 }
示例#3
0
 private boolean isAdjacent(Card card, Card extreme) {
   return card.getSuit() == extreme.getSuit()
       && (card.getRank().getValue() == extreme.getRank().getValue() - 1
           || card.getRank().getValue() == extreme.getRank().getValue() + 1);
 }