diff --git a/src/main/java/trap/report/TrapHelper.java b/src/main/java/trap/report/TrapHelper.java index d7a708a..9e23630 100644 --- a/src/main/java/trap/report/TrapHelper.java +++ b/src/main/java/trap/report/TrapHelper.java @@ -49,12 +49,11 @@ public Map> calculatePlayerIndividualTotal(Li playerIndividualTotal.put(r.getUniqueName(), new ArrayList<>()); } for (var playerRoundTotal : playerRoundTotals.values()) { - // clays, skeet, and fivestand are top 3 scores only, minimum 2 locations - var subtractScores = subtractScores(playerRoundTotal.getFirst().getType()); + var roundsToCount = getRoundsToCount(playerRoundTotal.getFirst().getType()); var indTotal = new ArrayList(); playerRoundTotal.sort(Comparator.comparingInt(RoundTotal::getTotal).reversed()); for (var t : playerRoundTotal) { - if (indTotal.size() < (3 - subtractScores)) { + if (indTotal.size() < (roundsToCount - 1)) { indTotal.add(new IndividualTotal(t.getLocationId(), t.getTeam(), t.getAthlete(), t.getClassification(), t.getGender(), t.getTotal(), t.getType())); } else { var locationIds = new HashSet(); @@ -94,11 +93,23 @@ public Map calculatePlayerFinalTotal(Map(); + roundCounts.put("singles", 4); + roundCounts.put("doubles", 4); + roundCounts.put("handicap", 4); + roundCounts.put("skeet", 3); + roundCounts.put("clays", 3); + roundCounts.put("fivestand", 3); + roundCounts.put("doublesskeet", 3); + return roundCounts; + } + + public static int getRoundsToCount(String type) { + return Integer.parseInt(determineRoundsToCount().get(type).toString()); + } } diff --git a/src/test/java/trap/report/TrapHelperTest.java b/src/test/java/trap/report/TrapHelperTest.java index 3e60558..e11dab4 100644 --- a/src/test/java/trap/report/TrapHelperTest.java +++ b/src/test/java/trap/report/TrapHelperTest.java @@ -735,4 +735,15 @@ void fivestandScoring3LocationsWithHigherScoresInOneLocation() { assertEquals("fivestand", playerFinalTotal.get(player1.getUniqueName()).getType()); } + @Test + void roundsToCount() { + assertEquals(4, trapHelper.getRoundsToCount("singles")); + assertEquals(4, trapHelper.getRoundsToCount("doubles")); + assertEquals(4, trapHelper.getRoundsToCount("handicap")); + + assertEquals(3, trapHelper.getRoundsToCount("skeet")); + assertEquals(3, trapHelper.getRoundsToCount("clays")); + assertEquals(3, trapHelper.getRoundsToCount("fivestand")); + assertEquals(3, trapHelper.getRoundsToCount("doublesskeet")); + } }