mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-31 07:12:49 -04:00
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:
parent
8d0c467ed6
commit
35ef48b108
3 changed files with 13 additions and 4 deletions
app/views/play
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue