protected void endRound(final EuchreGame game) throws GameException { final Participant winner = game._winningCard.getOwner(); final int teamNumber = game.getTeamNumber(winner) - 1; final int endScore = 1 + game.getTeamStatus(teamNumber).currentHandCount; game.getTeamStatus(teamNumber).currentHandCount = endScore; int totalRounds = ++game._roundNumber; game.doAddMessage( "<strong>%s (team %s) wins this trick, for a total of %d wins</strong>", game.getDisplayName(winner), teamNumber + 1, endScore); game.doClearPlayedCards(); int otherTeam = (0 == teamNumber) ? 1 : 0; final int makingTeam = game.getTeamNumber(game._maker) - 1; final int nonMakingTeam = (0 == makingTeam) ? 1 : 0; if (totalRounds >= 5) { game._roundNumber = 0; int affectedTeam; if (makingTeam == teamNumber && endScore == 5) { game.doAddMessage( "<strong>Team %s took every trick, and gets %d points.</strong>", teamNumber + 1, otherTeam + 1, 2); game.getTeamStatus(otherTeam).totalPoints += 2; affectedTeam = otherTeam; game._totalPts += 2; } else if (makingTeam == teamNumber && endScore >= 3) { game.doAddMessage("<strong>Team %s wins, and gets %d points.</strong>", teamNumber + 1, 1); game.getTeamStatus(teamNumber).totalPoints += 1; affectedTeam = teamNumber; game._totalPts += 1; } else { game.doAddMessage( "<strong>Team %s was Euchred! Team %s gets %d points.</strong>", makingTeam + 1, nonMakingTeam + 1, 2); game.getTeamStatus(nonMakingTeam).totalPoints += 2; affectedTeam = nonMakingTeam; game._totalPts += 2; } game.doSaveState(); game.doAdvanceTime(1000); if (game.getTeamStatus(affectedTeam).totalPoints >= game.getPointGoal()) { game.doAddMessage("<strong>Team %s wins the game!</strong>", affectedTeam + 1); game.doPayToTeam(affectedTeam + 1); game.getPlayerManager().getResetCurrentPlayer(); game.setCurrentPhase(EuchreGame.COMPLETE); game.doAddMessage("Enter 'Deal' or 'Quit'."); for (Participant p : game.getTeam(affectedTeam)) { if (p instanceof Player) { String type = "Win/Euchre"; String event = String.format("I won a game of Euchre!"); ((Player) p).doLogActivity(new ActivityEvent(type, event)); } } } else { game.setCurrentPhase(EuchreGame.DEALING); game.doCommand(EuchreCommand.Deal); } } else { game.getPlayerManager().setCurrentPlayer(winner); game._roundStartPlayer = winner; game._winningCard = null; } }