 
   battle.once 'ratingsUpdated', =>
     for player in battle.players
-      @checkAndAwardAchievements(server, player)
+      @checkAndAwardAchievements(server, player.id, player.ratingKey)
 
 
 # Returns the achievements a player is eligible for, including already earned ones
-# id is the rating key used to identify the player
-checkAchievements = (id, next) ->
-  ratings.getRatio id, (err, ratio) ->
-    ratings.getStreak id, (err, streak) ->
+checkAchievements = (ratingKey, next) ->
+  ratings.getRatio ratingKey, (err, ratio) ->
+    ratings.getStreak ratingKey, (err, streak) ->
       achievements = ACHIEVEMENTS.filter((o) -> o.conditionFn(ratio, streak))
 
       # Send everything except the conditionFn attribute


# Notifies the server about achievements to add to the user
# All achievements are separated by server result and passed to next
notifyServer = (playerName, achievements, next) ->
  achievementsByStatus =
    success: []
    duplicate: []


        # Flag all of the achievements that have been earned
        achievementsToFlag = _.union(byStatus.success, byStatus.duplicate)
        flagEarned(playerId, achievementsToFlag)  if achievementsToFlag.length > 0

        # for each new achievement, notify the user if said user is online
        if byStatus.success.length > 0
          user = server.getUser(playerId)
          if user
            user.send('achievementsEarned', byStatus.success)

