Mirror ladder levels now copy source code to other side, too, not just transpiled code. Mirror sessions don't submit if there's a user code error.

This commit is contained in:
Nick Winter 2015-09-08 16:30:18 -07:00
parent 8d0c467ed6
commit 35ef48b108
3 changed files with 13 additions and 4 deletions

View file

@ -1,6 +1,7 @@
CocoView = require 'views/core/CocoView'
template = require 'templates/play/common/ladder_submission'
{createAetherOptions} = require 'lib/aether_utils'
LevelSession = require 'models/LevelSession'
module.exports = class LadderSubmissionView extends CocoView
className: 'ladder-submission-view'
@ -78,14 +79,20 @@ module.exports = class LadderSubmissionView extends CocoView
# Also submit the mirrorSession after the main session submits successfully.
mirrorAjaxData = _.clone ajaxData
mirrorAjaxData.session = @mirrorSession.id
mirrorCode = @mirrorSession.get('code')
if @session.get('team') is 'humans'
mirrorAjaxData.transpiledCode = 'hero-placeholder-1': transpiledCode['hero-placeholder']
mirrorCode['hero-placeholder-1'] = @session.get('code')['hero-placeholder']
else
mirrorAjaxData.transpiledCode = 'hero-placeholder': transpiledCode['hero-placeholder-1']
mirrorCode['hero-placeholder'] = @session.get('code')['hero-placeholder-1']
mirrorAjaxOptions = _.clone ajaxOptions
mirrorAjaxOptions.data = mirrorAjaxData
ajaxOptions.success = ->
$.ajax '/queue/scoring', mirrorAjaxOptions
ajaxOptions.success = =>
patch = code: mirrorCode, codeLanguage: @session.get('codeLanguage'), submittedCodeLanguage: @session.get('submittedCodeLanguage')
tempSession = new LevelSession _id: @mirrorSession.id
tempSession.save patch, patch: true, type: 'PUT', success: ->
$.ajax '/queue/scoring', mirrorAjaxOptions
$.ajax '/queue/scoring', ajaxOptions

View file

@ -101,7 +101,9 @@ module.exports = class CastButtonView extends CocoView
@casting = false
if @hasCastOnce # Don't play this sound the first time
@playSound 'cast-end', 0.5
_.delay (=> @ladderSubmissionView?.rankSession()), 1000 if @ladderSubmissionView
myHeroID = if me.team is 'ogres' then 'Hero Placeholder 1' else 'Hero Placeholder'
if @ladderSubmissionView and not e.world.thangMap[myHeroID]?.errorsOut
_.delay (=> @ladderSubmissionView?.rankSession()), 1000 if @ladderSubmissionView
@hasCastOnce = true
@updateCastButton()
@world = e.world

View file

@ -36,7 +36,7 @@ module.exports = class Spell
else
@setLanguage 'javascript'
@useTranspiledCode = @shouldUseTranspiledCode()
console.log 'Spell', @spellKey, 'is using transpiled code (should only happen if it\'s an enemy/spectate writable method).' if @useTranspiledCode
#console.log 'Spell', @spellKey, 'is using transpiled code (should only happen if it\'s an enemy/spectate writable method).' if @useTranspiledCode
@source = @originalSource
@parameters = p.parameters