mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Merge branch 'master' into production
This commit is contained in:
commit
f4e30509e6
10 changed files with 59 additions and 32 deletions
|
@ -131,7 +131,9 @@ module.exports = class God extends CocoClass
|
|||
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', progress: event.data.progress
|
||||
|
||||
onNewWorldCreated: (e) ->
|
||||
console.log 'filtering', _.cloneDeep e.world.userCodeMap
|
||||
@currentUserCodeMap = @filterUserCodeMapWhenFromWorld e.world.userCodeMap
|
||||
console.log ' ... filtered into', _.cloneDeep e.world.userCodeMap
|
||||
|
||||
filterUserCodeMapWhenFromWorld: (worldUserCodeMap) ->
|
||||
newUserCodeMap = {}
|
||||
|
|
|
@ -46,9 +46,7 @@ module.exports = class LevelBus extends Bus
|
|||
incrementSessionPlaytime: =>
|
||||
if @playerIsIdle then return
|
||||
@changedSessionProperties.playtime = true
|
||||
if _.isNaN @session.get('playtime')
|
||||
@session.set 'playtime', 0 # Oops, corrupted some playtimes when moving to new defaults system. Fixed on 2014-10-06, but lost playtime data in between.
|
||||
@session.set('playtime', @session.get('playtime', true) + 1)
|
||||
@session.set('playtime', (@session.get('playtime') ? 0) + 1)
|
||||
|
||||
onPoint: ->
|
||||
return true unless @session?.get('multiplayer')
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports.createAetherOptions = (options) ->
|
|||
aetherOptions =
|
||||
functionName: options.functionName
|
||||
protectAPI: not options.skipProtectAPI
|
||||
includeFlow: false
|
||||
includeFlow: options.includeFlow
|
||||
yieldConditionally: options.functionName is 'plan'
|
||||
simpleLoops: true
|
||||
globals: ['Vector', '_']
|
||||
|
|
|
@ -442,7 +442,15 @@ module.exports = class World
|
|||
perf = {}
|
||||
perf.t0 = now()
|
||||
nFrames = endFrame - startFrame
|
||||
w = streamingWorld ? new World o.userCodeMap, classMap
|
||||
if streamingWorld
|
||||
w = streamingWorld
|
||||
# Make sure we get any Aether updates from the new frames into the already-deserialized streaming world Aethers.
|
||||
for thangID, methods of o.userCodeMap
|
||||
for methodName, serializedAether of methods
|
||||
for aetherStateKey in ['flow', 'metrics', 'style', 'problems']
|
||||
w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey]
|
||||
else
|
||||
w = new World o.userCodeMap, classMap
|
||||
[w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory]
|
||||
w[prop] = val for prop, val of o.trackedProperties
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ module.exports =
|
|||
entry: {type: 'object'}
|
||||
|
||||
'tome:spell-statement-index-updated': c.object {title: 'Spell Statement Index Updated', description: 'Published when the spell index is updated', required: ['statementIndex', 'ace']},
|
||||
statementIndex: {type: 'object'}
|
||||
statementIndex: {type: 'integer'}
|
||||
ace: {type: 'object'}
|
||||
|
||||
'tome:spell-beautify': c.object {title: 'Beautify', description: 'Published when you click the \'beautify\' button', required: []},
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
.spell-progress
|
||||
position: absolute
|
||||
height: 100%
|
||||
width: 40%
|
||||
left: 45%
|
||||
top: -50px
|
||||
width: 85%
|
||||
left: 10%
|
||||
display: inline-block
|
||||
cursor: pointer
|
||||
box-sizing: border-box
|
||||
|
|
|
@ -343,8 +343,8 @@ module.exports = class ThangsTabView extends CocoView
|
|||
wasSelected = target.hasClass 'selected'
|
||||
@$el.find('.add-thangs-palette .add-thang-palette-icon.selected').removeClass('selected')
|
||||
@selectAddThangType(if wasSelected then null else target.attr 'data-thang-type') unless key.alt or key.meta
|
||||
@addThangLank?.playSound? 'selected'
|
||||
target.addClass('selected') if @addThangType
|
||||
#false # was causing #1099, any reason to keep?
|
||||
|
||||
moveAddThangSelection: (direction) ->
|
||||
return unless @addThangType
|
||||
|
@ -366,7 +366,6 @@ module.exports = class ThangsTabView extends CocoView
|
|||
@addThangLank = @surface.lankBoss.addThangToLanks thang, @surface.lankBoss.layerAdapters['Floating']
|
||||
@addThangLank.notOfThisWorld = true
|
||||
@addThangLank.sprite.alpha = 0.75
|
||||
@addThangLank.playSound? 'selected'
|
||||
pos ?= x: Math.round(@world.width / 2), y: Math.round(@world.height / 2)
|
||||
@adjustThangPos @addThangLank, thang, pos
|
||||
else
|
||||
|
@ -399,9 +398,14 @@ module.exports = class ThangsTabView extends CocoView
|
|||
thang
|
||||
|
||||
adjustThangPos: (sprite, thang, pos) ->
|
||||
snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or {x: 0.01, y: 0.01} # Centimeter resolution by default
|
||||
pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2
|
||||
pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2
|
||||
if key.shift
|
||||
# Meter resolution when holding shift, not caring about thang size.
|
||||
pos.x = Math.round pos.x
|
||||
pos.y = Math.round pos.y
|
||||
else
|
||||
snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or x: 0.01, y: 0.01 # Centimeter resolution by default
|
||||
pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2
|
||||
pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2
|
||||
pos.z = thang.depth / 2
|
||||
thang.pos = pos
|
||||
thang.stateChanged = true
|
||||
|
|
|
@ -19,6 +19,7 @@ module.exports = class Spell
|
|||
@skipProtectAPI = options.skipProtectAPI
|
||||
@worker = options.worker
|
||||
@levelID = options.levelID
|
||||
@levelType = options.level.get('type', true)
|
||||
|
||||
p = options.programmableMethod
|
||||
@languages = p.languages ? {}
|
||||
|
@ -131,7 +132,7 @@ module.exports = class Spell
|
|||
aceConfig = me.get('aceConfig') ? {}
|
||||
writable = @permissions.readwrite.length > 0
|
||||
skipProtectAPI = @skipProtectAPI or not writable
|
||||
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI
|
||||
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI, includeFlow: @levelType is 'hero'
|
||||
aether = new Aether aetherOptions
|
||||
if @worker
|
||||
workerMessage =
|
||||
|
|
|
@ -100,11 +100,7 @@ module.exports = class SpellView extends CocoView
|
|||
@toggleControls null, @writable
|
||||
@aceSession.selection.on 'changeCursor', @onCursorActivity
|
||||
$(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
||||
# TODO: restore Zatanna when it totally stops the this.this.moveRight()(); problem
|
||||
#@zatanna = new Zatanna @ace,
|
||||
# liveCompletion: aceConfig.liveCompletion ? true
|
||||
# completers:
|
||||
# keywords: false
|
||||
@initAutocomplete aceConfig.liveCompletion ? true
|
||||
|
||||
createACEShortcuts: ->
|
||||
@aceCommands = aceCommands = []
|
||||
|
@ -191,8 +187,24 @@ module.exports = class SpellView extends CocoView
|
|||
@aceSession.setUndoManager(new UndoManager())
|
||||
@ace.clearSelection()
|
||||
|
||||
initAutocomplete: (@autocomplete) ->
|
||||
# TODO: Turn on more autocompletion based on level sophistication
|
||||
# TODO: E.g. using the language default snippets yields a bunch of crazy non-beginner suggestions
|
||||
# TODO: Options logic shouldn't exist both here and in updateAutocomplete()
|
||||
@zatanna = new Zatanna @ace,
|
||||
basic: false
|
||||
liveCompletion: false
|
||||
snippets: @autocomplete
|
||||
snippetsLangDefaults: false
|
||||
completers:
|
||||
keywords: false
|
||||
text: false
|
||||
|
||||
updateAutocomplete: (@autocomplete) ->
|
||||
@zatanna?.set 'snippets', @autocomplete
|
||||
|
||||
addZatannaSnippets: (e) ->
|
||||
return unless @zatanna
|
||||
return unless @zatanna and @autocomplete
|
||||
snippetEntries = []
|
||||
for owner, props of e.propGroups
|
||||
for prop in props
|
||||
|
@ -593,18 +605,20 @@ module.exports = class SpellView extends CocoView
|
|||
@aceSession.removeGutterDecoration row, 'executing'
|
||||
@aceSession.removeGutterDecoration row, 'executed'
|
||||
@decoratedGutter[row] = ''
|
||||
if not executed.length or (@spell.name is 'plan' and @spellThang.castAether.metrics.statementsExecuted < 20)
|
||||
lastExecuted = _.last executed
|
||||
showToolbarView = executed.length and (@spell.name isnt 'plan' or @spellThang.castAether.metrics.statementsExecuted > 20)
|
||||
|
||||
if showToolbarView
|
||||
statementIndex = Math.max 0, lastExecuted.length - 1
|
||||
@toolbarView?.toggleFlow true
|
||||
@toolbarView?.setCallState states[currentCallIndex], statementIndex, currentCallIndex, @spellThang.castAether.metrics
|
||||
lastExecuted = lastExecuted[0 .. @toolbarView.statementIndex] if @toolbarView?.statementIndex?
|
||||
else
|
||||
@toolbarView?.toggleFlow false
|
||||
@debugView?.setVariableStates {}
|
||||
return
|
||||
lastExecuted = _.last executed
|
||||
@toolbarView?.toggleFlow true
|
||||
statementIndex = Math.max 0, lastExecuted.length - 1
|
||||
@toolbarView?.setCallState states[currentCallIndex], statementIndex, currentCallIndex, @spellThang.castAether.metrics
|
||||
marked = {}
|
||||
lastExecuted = lastExecuted[0 .. @toolbarView.statementIndex] if @toolbarView?.statementIndex?
|
||||
gotVariableStates = false
|
||||
for state, i in lastExecuted
|
||||
for state, i in lastExecuted ? []
|
||||
[start, end] = state.range
|
||||
clazz = if i is lastExecuted.length - 1 then 'executing' else 'executed'
|
||||
if clazz is 'executed'
|
||||
|
@ -682,18 +696,17 @@ module.exports = class SpellView extends CocoView
|
|||
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
|
||||
@ace.setShowInvisibles aceConfig.invisibles # default false
|
||||
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
|
||||
@zatanna?.set 'liveCompletion', (aceConfig.liveCompletion ? false)
|
||||
@updateAutocomplete(aceConfig.liveCompletion ? false)
|
||||
|
||||
onChangeLanguage: (e) ->
|
||||
return unless @spell.canWrite()
|
||||
@aceSession.setMode @editModes[e.language]
|
||||
# @zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
|
||||
@zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
|
||||
wasDefault = @getSource() is @spell.originalSource
|
||||
@spell.setLanguage e.language
|
||||
@reloadCode true if wasDefault
|
||||
|
||||
onInsertSnippet: (e) ->
|
||||
console.log 'doc', e.doc, e.formatted
|
||||
snippetCode = null
|
||||
if e.doc.snippets?[e.language]?.code
|
||||
snippetCode = e.doc.snippets[e.language].code
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
"bootstrap": "~3.2.0",
|
||||
"validated-backbone-mediator": "~0.1.3",
|
||||
"jquery.browser": "~0.0.6",
|
||||
"zatanna": "~0.0.6",
|
||||
"zatanna": "https://github.com/differentmatt/zatanna.git#master",
|
||||
"modernizr": "~2.8.3",
|
||||
"backfire": "~0.3.0"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue