예제 #1
0
파일: Week.java 프로젝트: jesselund/pegasys
 public static final String createKey(Season season, int number) {
   return String.valueOf(season.getYear())
       + ":"
       + season.getType().toString()
       + ":"
       + String.valueOf(number);
 }
예제 #2
0
 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;
 }
예제 #3
0
  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;
    }
  }
예제 #4
0
 public Fee charge(OverFourPeopleRoom fourPeopleRoom) {
   return season.charge(fourPeopleRoom);
 }
예제 #5
0
 public Fee charge(ThreePeopleRoom threePeopleRoom) {
   return season.charge(threePeopleRoom);
 }
예제 #6
0
 public Fee charge(TwoPeopleRoom twoPeopleRoom) {
   return season.charge(twoPeopleRoom);
 }
예제 #7
0
파일: Tvshow.java 프로젝트: Gasp92/Mizuu
 public Season getSeason(int season) {
   for (Season s : mSeasons) if (s.getSeason() == season) return s;
   return new Season();
 }
예제 #8
0
파일: Tvshow.java 프로젝트: Gasp92/Mizuu
 public boolean hasSeason(int season) {
   for (Season s : mSeasons) if (s.getSeason() == season) return true;
   return false;
 }