mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Fixed headless client and transpile script
Really need to reactor the worker worlds to one script.
This commit is contained in:
parent
b5d52dac17
commit
eba3f36f0b
2 changed files with 15 additions and 14 deletions
|
@ -137,20 +137,18 @@ work = () ->
|
|||
|
||||
|
||||
self.onWorldError = onWorldError = (error) ->
|
||||
self.postMessage type: "end-load-frames"
|
||||
if error instanceof Aether.problems.UserCodeProblem
|
||||
#console.log "Aether userCodeProblem occured."
|
||||
unless self.postedErrors[error.key]
|
||||
problem = error.serialize()
|
||||
if error.isUserCodeProblem
|
||||
errorKey = error.userInfo.key
|
||||
if not errorKey or not self.postedErrors[errorKey]
|
||||
self.postMessage
|
||||
type: "user-code-problem"
|
||||
problem: problem
|
||||
|
||||
self.postedErrors[error.key] = problem
|
||||
problem: error
|
||||
self.postedErrors[errorKey] = error
|
||||
else
|
||||
console.log "Non-UserCodeError:", error.toString() + "\n" + error.stack or error.stackTrace
|
||||
self.cleanUp()
|
||||
|
||||
self.cleanUp()
|
||||
return true
|
||||
|
||||
self.onWorldLoadProgress = onWorldLoadProgress = (progress) ->
|
||||
#console.log "Worker onWorldLoadProgress"
|
||||
self.postMessage
|
||||
|
|
|
@ -13,19 +13,23 @@ Aether.addGlobal 'Vector', require '../app/lib/world/vector'
|
|||
Aether.addGlobal '_', _
|
||||
|
||||
transpileLevelSession = (sessionID, cb) ->
|
||||
query = LevelSession.findOne("_id": sessionID).select("submittedCode").lean()
|
||||
query = LevelSession.findOne("_id": sessionID).select("submittedCode submittedCodeLanguage").lean()
|
||||
query.exec (err, session) ->
|
||||
if err then return cb err
|
||||
submittedCode = session.submittedCode
|
||||
unless session.submittedCodeLanguage
|
||||
throw "SUBMITTED CODE LANGUAGE DOESN'T EXIST"
|
||||
else
|
||||
console.log "Transpiling code for session #{session._id} in language #{session.submittedCodeLanguage}"
|
||||
transpiledCode = {}
|
||||
console.log "Updating session #{sessionID}"
|
||||
#console.log "Updating session #{sessionID}"
|
||||
for thang, spells of submittedCode
|
||||
transpiledCode[thang] = {}
|
||||
for spellID, spell of spells
|
||||
|
||||
aetherOptions =
|
||||
problems: {}
|
||||
language: "javascript"
|
||||
language: session.submittedCodeLanguage
|
||||
functionName: spellID
|
||||
functionParameters: []
|
||||
yieldConditionally: spellID is "plan"
|
||||
|
@ -41,7 +45,6 @@ transpileLevelSession = (sessionID, cb) ->
|
|||
"_id": sessionID
|
||||
update =
|
||||
"transpiledCode": transpiledCode
|
||||
"submittedCodeLanguage": "javascript"
|
||||
query = LevelSession.update(conditions,update)
|
||||
|
||||
query.exec (err, numUpdated) -> cb err
|
||||
|
|
Loading…
Reference in a new issue