Merge branch 'master' of https://github.com/codecombat/codecombat
This commit is contained in:
commit
3bc0c1710e
6 changed files with 26 additions and 20 deletions
app
lib
styles/play/level
templates/play/level
views/play/level/tome
|
@ -96,11 +96,8 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
unless @indieSprites
|
unless @indieSprites
|
||||||
@indieSprites = []
|
@indieSprites = []
|
||||||
@indieSprites = (@createIndieSprite indieSprite for indieSprite in indieSprites) if indieSprites
|
@indieSprites = (@createIndieSprite indieSprite for indieSprite in indieSprites) if indieSprites
|
||||||
unless @selfWizardSprite
|
if withWizards and not @selfWizardSprite
|
||||||
@selfWizardSprite = @createWizardSprite thangID: "My Wizard", isSelf: true, sprites: @sprites
|
@selfWizardSprite = @createWizardSprite thangID: "My Wizard", isSelf: true, sprites: @sprites
|
||||||
unless withWizards
|
|
||||||
@selfWizardSprite.displayObject.visible = false
|
|
||||||
@selfWizardSprite.labels.name.setText null
|
|
||||||
|
|
||||||
createIndieSprite: (indieSprite) ->
|
createIndieSprite: (indieSprite) ->
|
||||||
unless thangType = @thangTypeFor indieSprite.thangType
|
unless thangType = @thangTypeFor indieSprite.thangType
|
||||||
|
|
|
@ -29,8 +29,8 @@ module.exports = class ThangState
|
||||||
value = thang[prop]
|
value = thang[prop]
|
||||||
if type is 'Vector'
|
if type is 'Vector'
|
||||||
@props.push value?.copy() # could try storing [x, y, z] or {x, y, z} here instead if this is expensive
|
@props.push value?.copy() # could try storing [x, y, z] or {x, y, z} here instead if this is expensive
|
||||||
else if type is 'object'
|
else if type is 'object' or type is 'array'
|
||||||
@props.push = clone(value, true)
|
@props.push clone(value, true)
|
||||||
else
|
else
|
||||||
@props.push value
|
@props.push value
|
||||||
|
|
||||||
|
@ -144,6 +144,8 @@ module.exports = class ThangState
|
||||||
# We make sure the array keys won't collide with any string keys by using some unprintable characters.
|
# We make sure the array keys won't collide with any string keys by using some unprintable characters.
|
||||||
stringPieces = ['\x1D'] # Group Separator
|
stringPieces = ['\x1D'] # Group Separator
|
||||||
for element in value
|
for element in value
|
||||||
|
if element and element.isThang
|
||||||
|
element = element.id
|
||||||
stringPieces.push element, '\x1E' # Record Separator(s)
|
stringPieces.push element, '\x1E' # Record Separator(s)
|
||||||
value = stringPieces.join('')
|
value = stringPieces.join('')
|
||||||
specialKey = specialValuesToKeys[value]
|
specialKey = specialValuesToKeys[value]
|
||||||
|
|
|
@ -42,12 +42,15 @@ module.exports.clone = clone = (obj, skipThangs=false) ->
|
||||||
if skipThangs and obj.isThang
|
if skipThangs and obj.isThang
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
if _.isArray obj
|
||||||
|
return obj.slice()
|
||||||
|
|
||||||
if ArrayBufferView and obj instanceof ArrayBufferView
|
if ArrayBufferView and obj instanceof ArrayBufferView
|
||||||
newInstance = new obj.constructor obj
|
return new obj.constructor obj
|
||||||
else
|
|
||||||
newInstance = new obj.constructor()
|
newInstance = new obj.constructor()
|
||||||
for key of obj
|
for key of obj
|
||||||
newInstance[key] = clone obj[key]
|
newInstance[key] = clone obj[key], skipThangs
|
||||||
|
|
||||||
newInstance
|
newInstance
|
||||||
|
|
||||||
|
|
|
@ -40,3 +40,6 @@
|
||||||
font-size: 13px
|
font-size: 13px
|
||||||
height: 24px
|
height: 24px
|
||||||
|
|
||||||
|
|
||||||
|
#level-done-button
|
||||||
|
display: none
|
||||||
|
|
|
@ -17,4 +17,4 @@ if spectateGame
|
||||||
|
|
||||||
button.btn.btn-xs.btn-inverse.banner#restart-button(title="Reload all custom code to reset level", data-i18n="play_level.restart") Restart
|
button.btn.btn-xs.btn-inverse.banner#restart-button(title="Reload all custom code to reset level", data-i18n="play_level.restart") Restart
|
||||||
|
|
||||||
button.btn.btn-xs.btn-primary.banner.secret#level-done-button(data-i18n="play_level.done") Done
|
button.btn.btn-xs.btn-primary.banner#level-done-button(data-i18n="play_level.done") Done
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = class DebugView extends View
|
||||||
@ace = options.ace
|
@ace = options.ace
|
||||||
@thang = options.thang
|
@thang = options.thang
|
||||||
@variableStates = {}
|
@variableStates = {}
|
||||||
@globals = {Math: Math, _: _} # ... add more as documented
|
@globals = {Math: Math, _: _, String: String, Number: Number, Array: Array, Object: Object} # ... add more as documented
|
||||||
for className, klass of serializedClasses
|
for className, klass of serializedClasses
|
||||||
@globals[className] = klass
|
@globals[className] = klass
|
||||||
@onMouseMove = _.throttle @onMouseMove, 25
|
@onMouseMove = _.throttle @onMouseMove, 25
|
||||||
|
@ -33,17 +33,18 @@ module.exports = class DebugView extends View
|
||||||
setVariableStates: (@variableStates) ->
|
setVariableStates: (@variableStates) ->
|
||||||
@update()
|
@update()
|
||||||
|
|
||||||
|
isIdentifier: (t) ->
|
||||||
|
t and (t.type is 'identifier' or t.value is 'this' or @globals[t.value])
|
||||||
|
|
||||||
onMouseMove: (e) =>
|
onMouseMove: (e) =>
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
pos = e.getDocumentPosition()
|
pos = e.getDocumentPosition()
|
||||||
endOfDoc = pos.row is @ace.getSession().getDocument().getLength() - 1
|
|
||||||
it = new TokenIterator e.editor.session, pos.row, pos.column
|
it = new TokenIterator e.editor.session, pos.row, pos.column
|
||||||
isIdentifier = (t) => t and (t.type is 'identifier' or t.value is 'this' or @globals[t.value])
|
endOfLine = it.getCurrentToken()?.index is it.$rowTokens.length - 1
|
||||||
while it.getCurrentTokenRow() is pos.row and not isIdentifier(token = it.getCurrentToken())
|
while it.getCurrentTokenRow() is pos.row and not @isIdentifier(token = it.getCurrentToken())
|
||||||
|
break if endOfLine or not token # Don't iterate beyond end or beginning of line
|
||||||
it.stepBackward()
|
it.stepBackward()
|
||||||
break unless token
|
if @isIdentifier token
|
||||||
break if endOfDoc # Don't iterate backward on last line, since we might be way below.
|
|
||||||
if isIdentifier token
|
|
||||||
# This could be a property access, like "enemy.target.pos" or "this.spawnedRectangles".
|
# This could be a property access, like "enemy.target.pos" or "this.spawnedRectangles".
|
||||||
# We have to realize this and dig into the nesting of the objects.
|
# We have to realize this and dig into the nesting of the objects.
|
||||||
start = it.getCurrentTokenColumn()
|
start = it.getCurrentTokenColumn()
|
||||||
|
@ -53,7 +54,7 @@ module.exports = class DebugView extends View
|
||||||
break unless it.getCurrentToken()?.value is "."
|
break unless it.getCurrentToken()?.value is "."
|
||||||
it.stepBackward()
|
it.stepBackward()
|
||||||
token = null # If we're doing a complex access like this.getEnemies().length, then length isn't a valid var.
|
token = null # If we're doing a complex access like this.getEnemies().length, then length isn't a valid var.
|
||||||
break unless isIdentifier(prev = it.getCurrentToken())
|
break unless @isIdentifier(prev = it.getCurrentToken())
|
||||||
token = prev
|
token = prev
|
||||||
start = it.getCurrentTokenColumn()
|
start = it.getCurrentTokenColumn()
|
||||||
chain.unshift token.value
|
chain.unshift token.value
|
||||||
|
|
Reference in a new issue