Exemple #1
0
  public void update(GameInfo gameInfo) {
    int races = gameInfo.getLocalPlayerRaces();
    CampaignLevel campaignLevel = gameInfo.getCampaignLevel();
    if (campaignLevel != null && gameInfo.won()) {
      int stars = gameInfo.getStarCount();
      campaignLevel.update(stars, gameInfo.getComputerLevel());
    }

    long xp = increaseXP(gameInfo);
    for (int race : Races.asArray(races)) {
      processRace(gameInfo, race, xp);
    }
    if (gameInfo.won()) wins++;
    else losses++;

    if (longestGame < gameInfo.getLength()) longestGame = gameInfo.getLength();
    if (shortestGame > gameInfo.getLength()) shortestGame = gameInfo.getLength();
    if (highestLevelBeaten < gameInfo.getComputerLevel())
      highestLevelBeaten = gameInfo.getComputerLevel();
    if (highestScore < xp) highestScore = xp;

    for (Achievement achievement : achievements) {
      if (achievement.executeIfNotCompleted(this)) {
        // add achievement to list if it was executed for the first time
        gameInfo.addAchievement(achievement);
      }
    }
  }
Exemple #2
0
 private void processRace(GameInfo gameInfo, int race, long xp) {
   xp = raceXP.get(race) + xp;
   raceXP.put(race, xp);
   if (gameInfo.won()) {
     switch (gameInfo.getGameType()) {
       case GameInfo.DEFENSE:
         int defenseWon = defensiveGamesWon.get(race);
         defensiveGamesWon.put(race, defenseWon + 1);
         break;
       case GameInfo.BATTLE:
         int battleWon = battleGamesWon.get(race);
         battleGamesWon.put(race, battleWon + 1);
         break;
       default:
         Modules.LOG.error(
             "PlayerStats", "Unknown game type in player stats " + gameInfo.getGameType());
     }
   }
 }