Beispiel #1
0
  public static int forecastScore(Forecast forecast) {

    int totalScore = 0;
    Match currentGame = forecast.getMatch();
    if (currentGame != null) {
      FinalScore finalScore = currentGame.getScore();
      if (finalScore != null) {

        // begin score calculate
        // calculate good winner
        if (hasGoodWinner(finalScore, forecast)) {
          totalScore += GOOD_WINNER_POINTS;
        }

        // calculate good team1 score
        if (finalScore.getScoreTeam1() == forecast.getScoreTeam1()) {
          totalScore += GOOD_SCORE_FOR_ONE_TEAM_POINTS;
        }

        // calculate good team2 score
        if (finalScore.getScoreTeam2() == forecast.getScoreTeam2()) {
          totalScore += GOOD_SCORE_FOR_ONE_TEAM_POINTS;
        }
        return totalScore * currentGame.getCoefficient();
      }
    }
    return totalScore;
  }
Beispiel #2
0
  /**
   * provide the forecast winner team. In case of draw on "knockout stage" game, return the team
   * declared as winner by the player
   *
   * @param forecast
   * @return the winner or null whether draw
   */
  public static Team getForecastWinner(Forecast forecast) {

    // team 1 win
    if (forecast.getScoreTeam1() > forecast.getScoreTeam2()) {
      return forecast.getMatch().getTeam1();
    }

    // team 2 win
    else if (forecast.getScoreTeam1() < forecast.getScoreTeam2()) {
      return forecast.getMatch().getTeam2();
    }

    // draw on regular time
    else {
      // in case of group stage game, there is no winner
      if (forecast.getMatch() instanceof GroupStageMatch) {
        return null;
      } else {
        return forecast.getWinner();
      }
    }
  }