private List<Standing> addNewMatchToStandings(List<Standing> standings, Match m) { Boolean standingFound = false; for (Perf p : m.getPerfs()) { for (Standing s : standings) { if (p.getPlayerKey().compareTo(s.getPlayerKey()) == 0) { standingFound = true; s.incrementMatchCount(); s.incrementFinishCount(p.getFinishPos()); s.updateWinPoints(this.season.lookupWinPointValue(p.getFinishPos())); for (Perf opp : m.getPerfs()) { if (p.getPlayerKey().compareTo(opp.getPlayerKey()) != 0) { // not p, updating p's standing relative to opp s.updateGapScore(opp.getPlayerKey(), p.getFinishPos() - opp.getFinishPos()); } } } } if (!standingFound) { Standing standing = new Standing( p.getPlayerKey(), // player key 0, // races completed 0, // win points this.season.lookupLeagueRacersPerMatch(), // possible finish positions this.season.lookupLeaguePlayersPerMatch()); // humans per race standing.incrementMatchCount(); standing.incrementFinishCount(p.getFinishPos()); standing.updateWinPoints(season.lookupWinPointValue(p.getFinishPos())); for (Perf opp : m.getPerfs()) { if (p.getPlayerKey().compareTo(opp.getPlayerKey()) != 0) { // not p, updating p's standing relative to opp // 2 positions "below" opp is actually +2 in gap points - 1st vs 3rd place standing.updateGapScore(opp.getPlayerKey(), p.getFinishPos() - opp.getFinishPos()); } } standings.add(standing); } standingFound = false; } return standings; }
protected static Standing getStanding(String date, Team team) { Standing standing = new Standing(); standing.setTeam(team); standing.setDate(LocalDate.parse(date, DateTimeFormat.forPattern("yyyy-MM-dd"))); standing.setRank((short) 2); standing.setOrdinalRank("2nd"); standing.setGamesWon((short) 95); standing.setGamesLost((short) 102); standing.setStreak("W1"); standing.setStreakType("Win"); standing.setStreakTotal((short) 1); standing.setGamesBack((float) 1.5); standing.setPointsFor((short) 2902); standing.setPointsAgainst((short) 3505); standing.setHomeWins((short) 40); standing.setHomeLosses((short) 60); standing.setAwayWins((short) 49); standing.setAwayLosses((short) 50); standing.setConferenceWins((short) 15); standing.setConferenceLosses((short) 11); standing.setLastFive("2-3"); standing.setLastTen("5-10"); standing.setGamesPlayed((short) 197); standing.setPointsScoredPerGame((float) 102.1); standing.setPointsAllowedPerGame((float) 105.1); standing.setWinPercentage((float) 0.505); standing.setPointDifferential((short) -2); standing.setPointDifferentialPerGame((float) -0.4); return standing; }