Beispiel #1
0
 /** Check all achievements. If an achievement is earned it is added to the achievements set. */
 public void checkAchievements() {
   for (Achievement achievement : Achievement.values()) {
     if (!(achievements.contains(achievement))) {
       // Player doesn't already have achievement, check if they do now
       if (achievement.isEarned(this)) {
         // Player earned a new achievement!
         achievements.add(achievement);
       }
     }
   }
   notifyObservers();
 }
Beispiel #2
0
 /** Prints the achievements using toString. */
 public void printAchievements() {
   for (Achievement data : achievements) {
     System.out.println(
         "Player " + username + " has earned the achievement " + data.toString() + "!");
   }
 }