mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-02 11:58:10 -05:00
Merge pull request #1017 from codecombat/master
Add playtime, opponent name, totalScore to match
This commit is contained in:
commit
1b9b145da7
2 changed files with 13 additions and 6 deletions
|
@ -199,6 +199,8 @@ module.exports = class Simulator extends CocoClass
|
|||
sessionID: session.sessionID
|
||||
submitDate: session.submitDate
|
||||
creator: session.creator
|
||||
name: session.creatorName
|
||||
totalScore: session.totalScore
|
||||
metrics:
|
||||
rank: @calculateSessionRank session.sessionID, simulationResults.goalStates, @task.generateTeamToSessionMap()
|
||||
if session.sessionID is taskResults.originalSessionID
|
||||
|
|
|
@ -277,6 +277,7 @@ constructTaskObject = (taskMessageBody, message, callback) ->
|
|||
"levelID": session.levelID
|
||||
"creator": session.creator
|
||||
"creatorName":session.creatorName
|
||||
"totalScore": session.totalScore
|
||||
|
||||
taskObject.sessions.push sessionInformation
|
||||
callback null, taskObject, message
|
||||
|
@ -297,7 +298,7 @@ processTaskObject = (taskObject,taskLogObject, message, cb) ->
|
|||
getSessionInformation = (sessionIDString, callback) ->
|
||||
findParameters =
|
||||
_id: sessionIDString
|
||||
selectString = 'submitDate team submittedCode teamSpells levelID creator creatorName transpiledCode'
|
||||
selectString = 'submitDate team submittedCode teamSpells levelID creator creatorName transpiledCode totalScore'
|
||||
query = LevelSession
|
||||
.findOne(findParameters)
|
||||
.select(selectString)
|
||||
|
@ -445,6 +446,8 @@ addMatchToSessions = (newScoreObject, callback) ->
|
|||
matchObject.opponents[sessionID] = {}
|
||||
matchObject.opponents[sessionID].sessionID = sessionID
|
||||
matchObject.opponents[sessionID].userID = session.creator
|
||||
matchObject.opponents[sessionID].name = session.name
|
||||
matchObject.opponents[sessionID].totalScore = session.totalScore
|
||||
matchObject.opponents[sessionID].metrics = {}
|
||||
matchObject.opponents[sessionID].metrics.rank = Number(newScoreObject[sessionID].gameRanking)
|
||||
|
||||
|
@ -462,11 +465,13 @@ updateMatchesInSession = (matchObject, sessionID, callback) ->
|
|||
opponentsClone = _.omit opponentsClone, sessionID
|
||||
opponentsArray = _.toArray opponentsClone
|
||||
currentMatchObject.opponents = opponentsArray
|
||||
|
||||
sessionUpdateObject =
|
||||
$push: {matches: {$each: [currentMatchObject], $slice: -200}}
|
||||
#log.info "Updating session #{sessionID}"
|
||||
LevelSession.update {"_id":sessionID}, sessionUpdateObject, callback
|
||||
LevelSession.findOne {"_id": sessionID}, (err, session) ->
|
||||
session = session.toObject()
|
||||
currentMatchObject.playtime = session.playtime ? 0
|
||||
sessionUpdateObject =
|
||||
$push: {matches: {$each: [currentMatchObject], $slice: -200}}
|
||||
#log.info "Updating session #{sessionID}"
|
||||
LevelSession.update {"_id":sessionID}, sessionUpdateObject, callback
|
||||
|
||||
updateUserSimulationCounts = (reqUserID,callback) ->
|
||||
incrementUserSimulationCount reqUserID, 'simulatedBy', (err) =>
|
||||
|
|
Loading…
Reference in a new issue