Fix random game results not being sent back

This commit is contained in:
Michael Schmatz 2014-05-22 09:02:57 -07:00
parent 48f5347075
commit 8fabbadff3

View file

@ -587,7 +587,8 @@ addMatchToSessions = (newScoreObject, callback) ->
#log.info "Writing match object to database..."
#use bind with async to do the writes
sessionIDs = _.pluck @clientResponseObject.sessions, 'sessionID'
async.each sessionIDs, updateMatchesInSession.bind(@,matchObject), (err) -> callback err
async.each sessionIDs, updateMatchesInSession.bind(@,matchObject), (err) ->
callback err
updateMatchesInSession = (matchObject, sessionID, callback) ->
currentMatchObject = {}
@ -608,7 +609,11 @@ updateMatchesInSession = (matchObject, sessionID, callback) ->
updateUserSimulationCounts = (reqUserID,callback) ->
incrementUserSimulationCount reqUserID, 'simulatedBy', (err) =>
if err? then return callback err
incrementUserSimulationCount @levelSession.creator, 'simulatedFor', callback unless @isRandomMatch
console.log "Incremented user simulation count!"
unless @isRandomMatch
incrementUserSimulationCount @levelSession.creator, 'simulatedFor', callback
else
callback null
incrementUserSimulationCount = (userID, type, callback) =>
inc = {}