protected void playCard( final EuchreGame game, final Participant participant, final int cardIndexToPlay) throws GameException { /* * R-E-0146: Play continues in clockwise order; each player must follow * suit if they have a R-E-0147: card of the suit led. The left bower is * considered a member of the trump suit R-E-0148: and not a member of * its native suit. */ final int currentPlayerIndex = game.getPlayerManager().getCurrentPlayerIndex(); final IndexCard cardToPlay = (IndexCard) game.getToken(new IndexPosition(currentPlayerIndex, cardIndexToPlay)); if (null == cardToPlay) /* * R-E-0103: The primary rule to remember when * playing euchre is that one is never required * R-E-0104: to trump, but one is required to * follow suit if possible to do so: if diamonds * R-E-0105: are led, a player with diamonds is * required to play a diamond. This differs from * R-E-0106: games such as pinochle. */ throw new GameLogicException( String.format("Could not find card in slot %d!", cardIndexToPlay)); final Suits leadingSuit = game.getLeadingSuit(); final boolean isLeadingSuit = (game.getEffectiveSuit(cardToPlay.getCard()) == leadingSuit); final boolean canLeadSuit = game.getPlayerCanLead(currentPlayerIndex); if (!isLeadingSuit && canLeadSuit) throw new GameLogicException(String.format("You must play a %s", leadingSuit.fullString())); game.doAddMessage( MessageType.Compact, "Played %s of %s ", cardToPlay.getCard().getRank().name(), cardToPlay.getCard().getSuit().fullString()); if (game.isWinningCard(cardToPlay)) { game._winningCard = cardToPlay; game.doAddMessage(MessageType.Compact, "<strong>(Currently Winning)</strong>"); } game.doAddMessage(""); cardToPlay.setPosition(new IndexPosition(EuchreLayout.POS_IN_PLAY, game._roundCardCount++)); cardToPlay.setPublic(); cardToPlay.setMovable(false); final Participant gotoNextPlayer = game.getPlayerManager().gotoNextPlayer(); if (game._roundStartPlayer.equals(gotoNextPlayer)) { endRound(game); } final Participant currentPlayer = game.getPlayerManager().getCurrentPlayer(); String displayName; if (null != currentPlayer) { displayName = game.getDisplayName(currentPlayer); } else { displayName = "<NULL>"; } game.doAddMessage(MessageType.Compact, "It is now %s's turn: ", displayName); }