Пример #1
0
  public void summarizePlayer(int playerID) {
    Player p = players.get(playerID);
    Map<Integer, Playing> playersGames = p.games;
    Set<Integer> gamesKeys = playersGames.keySet();
    Integer[] gameIDs = gamesKeys.toArray(new Integer[gamesKeys.size()]);

    System.out.println("Player: " + p);
    System.out.println("Total Gamerscore: " + p.getGamerScore());
    System.out.printf(
        "%4s %-20s %-16s %-16s %-16s \n", " ", "Game", "Achievements", "Gamerscore", "IGN");
    System.out.println(
        "--------------------------------------------------------------------------------");
    for (int i = 0; i < gameIDs.length; i++) {
      Game g = games.get(gameIDs[i]);
      Playing playerInfo = p.games.get(gameIDs[i]);
      int nPlayerAchieve = playerInfo.achievements.size();
      int nTotalAchieve = g.achievements.size();
      System.out.printf(
          "%4s %-20s %-16s %-16s %-16s \n",
          (i + 1 + "."),
          g,
          (nPlayerAchieve + "/" + nTotalAchieve),
          (playerInfo.getPoints() + " pts"),
          playerInfo.ign);
    }

    System.out.printf("\n%4s %-16s %-16s \n", " ", "Friend", "Gamerscore");
    System.out.println(
        "--------------------------------------------------------------------------------");
    printSortedPlayers(p.friends);
  }
Пример #2
0
 public void printComparisonData(Player p, Game g) {
   Playing gameInfo = p.games.get(g.gameID);
   ArrayList<Integer> achieved = gameInfo.achievements;
   System.out.println("Player: " + p);
   System.out.printf(
       "%d of %d total achievements achieved, %d pts \n",
       achieved.size(), g.achievements.size(), gameInfo.getPoints());
   for (int a : achieved) {
     System.out.printf("%4s %s \n", "-", achievements.get(a));
   }
   System.out.println();
 }
Пример #3
0
 public void achieve(int playerID, int gameID, int achievementID) {
   if (players.containsKey(playerID) && achievements.containsKey(achievementID)) {
     Player p = players.get(playerID);
     Achievement a = achievements.get(achievementID);
     if (p.games.containsKey(gameID)
         && !p.games.get(gameID).achievements.contains(achievementID)) {
       Playing playerInfo = p.games.get(gameID);
       int pointsEarned = a.points;
       playerInfo.achievements.add(achievementID);
       playerInfo.addPoints(pointsEarned);
       p.addPoints(pointsEarned);
       a.players.add(playerID);
     } else {
       // System.out.println("player does not play this game or already has this achievement");
     }
   } else {
     // System.out.println("player or achievement does not exist");
   }
 }