public static final String createKey(Season season, int number) { return String.valueOf(season.getYear()) + ":" + season.getType().toString() + ":" + String.valueOf(number); }
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; }
public String getNewFilename() { switch (this.status) { case ADDED: { return ADDED_PLACEHOLDER_FILENAME; } case DOWNLOADED: case RENAMED: { String showName = ""; String seasonNum = ""; String titleString = ""; Calendar airDate = Calendar.getInstance(); ; try { Show show = ShowStore.getShow(this.showName); showName = show.getName(); Season season = show.getSeason(this.seasonNumber); if (season == null) { seasonNum = String.valueOf(this.seasonNumber); logger.log( Level.SEVERE, "Season #" + this.seasonNumber + " not found for show '" + this.showName + "'"); } else { seasonNum = String.valueOf(season.getNumber()); try { titleString = season.getTitle(this.episodeNumber); airDate.setTime(season.getAirDate(this.episodeNumber)); } catch (EpisodeNotFoundException e) { logger.log(Level.SEVERE, "Episode not found for '" + this.toString() + "'", e); } } } catch (ShowNotFoundException e) { showName = this.showName; logger.log(Level.SEVERE, "Show not found for '" + this.toString() + "'", e); } String newFilename = userPrefs.getRenameReplacementString(); // Ensure that all special characters in the replacement are quoted showName = Matcher.quoteReplacement(showName); showName = GlobalOverrides.getInstance().getShowName(showName); titleString = Matcher.quoteReplacement(titleString); // Make whatever modifications are required String episodeNumberString = new DecimalFormat("##0").format(this.episodeNumber); String episodeNumberWithLeadingZeros = new DecimalFormat("#00").format(this.episodeNumber); String episodeTitleNoSpaces = titleString.replaceAll(" ", "."); String seasonNumberWithLeadingZero = new DecimalFormat("00").format(this.seasonNumber); newFilename = newFilename.replaceAll(ReplacementToken.SHOW_NAME.getToken(), showName); newFilename = newFilename.replaceAll(ReplacementToken.SEASON_NUM.getToken(), seasonNum); newFilename = newFilename.replaceAll( ReplacementToken.SEASON_NUM_LEADING_ZERO.getToken(), seasonNumberWithLeadingZero); newFilename = newFilename.replaceAll(ReplacementToken.EPISODE_NUM.getToken(), episodeNumberString); newFilename = newFilename.replaceAll( ReplacementToken.EPISODE_NUM_LEADING_ZERO.getToken(), episodeNumberWithLeadingZeros); newFilename = newFilename.replaceAll(ReplacementToken.EPISODE_TITLE.getToken(), titleString); newFilename = newFilename.replaceAll( ReplacementToken.EPISODE_TITLE_NO_SPACES.getToken(), episodeTitleNoSpaces); // Date and times newFilename = newFilename.replaceAll( ReplacementToken.DATE_DAY_NUM.getToken(), formatDate(airDate, "d")); newFilename = newFilename.replaceAll( ReplacementToken.DATE_DAY_NUMLZ.getToken(), formatDate(airDate, "dd")); newFilename = newFilename.replaceAll( ReplacementToken.DATE_MONTH_NUM.getToken(), formatDate(airDate, "M")); newFilename = newFilename.replaceAll( ReplacementToken.DATE_MONTH_NUMLZ.getToken(), formatDate(airDate, "MM")); newFilename = newFilename.replaceAll( ReplacementToken.DATE_YEAR_FULL.getToken(), formatDate(airDate, "yyyy")); newFilename = newFilename.replaceAll( ReplacementToken.DATE_YEAR_MIN.getToken(), formatDate(airDate, "yy")); String resultingFilename = newFilename.concat(".").concat(StringUtils.getExtension(file.getName())); return StringUtils.sanitiseTitle(resultingFilename); } case BROKEN: default: return BROKEN_PLACEHOLDER_FILENAME; } }
public Fee charge(OverFourPeopleRoom fourPeopleRoom) { return season.charge(fourPeopleRoom); }
public Fee charge(ThreePeopleRoom threePeopleRoom) { return season.charge(threePeopleRoom); }
public Fee charge(TwoPeopleRoom twoPeopleRoom) { return season.charge(twoPeopleRoom); }
public Season getSeason(int season) { for (Season s : mSeasons) if (s.getSeason() == season) return s; return new Season(); }
public boolean hasSeason(int season) { for (Season s : mSeasons) if (s.getSeason() == season) return true; return false; }