mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 22:13:32 -04:00
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
|
||||
@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
|
||||
unless withWizards
|
||||
@selfWizardSprite.displayObject.visible = false
|
||||
@selfWizardSprite.labels.name.setText null
|
||||
|
||||
createIndieSprite: (indieSprite) ->
|
||||
unless thangType = @thangTypeFor indieSprite.thangType
|
||||
|
|
|
@ -29,8 +29,8 @@ module.exports = class ThangState
|
|||
value = thang[prop]
|
||||
if type is 'Vector'
|
||||
@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'
|
||||
@props.push = clone(value, true)
|
||||
else if type is 'object' or type is 'array'
|
||||
@props.push clone(value, true)
|
||||
else
|
||||
@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.
|
||||
stringPieces = ['\x1D'] # Group Separator
|
||||
for element in value
|
||||
if element and element.isThang
|
||||
element = element.id
|
||||
stringPieces.push element, '\x1E' # Record Separator(s)
|
||||
value = stringPieces.join('')
|
||||
specialKey = specialValuesToKeys[value]
|
||||
|
|
|
@ -42,12 +42,15 @@ module.exports.clone = clone = (obj, skipThangs=false) ->
|
|||
if skipThangs and obj.isThang
|
||||
return obj
|
||||
|
||||
if _.isArray obj
|
||||
return obj.slice()
|
||||
|
||||
if ArrayBufferView and obj instanceof ArrayBufferView
|
||||
newInstance = new obj.constructor obj
|
||||
else
|
||||
newInstance = new obj.constructor()
|
||||
for key of obj
|
||||
newInstance[key] = clone obj[key]
|
||||
return new obj.constructor obj
|
||||
|
||||
newInstance = new obj.constructor()
|
||||
for key of obj
|
||||
newInstance[key] = clone obj[key], skipThangs
|
||||
|
||||
newInstance
|
||||
|
||||
|
|
|
@ -40,3 +40,6 @@
|
|||
font-size: 13px
|
||||
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-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
|
||||
@thang = options.thang
|
||||
@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
|
||||
@globals[className] = klass
|
||||
@onMouseMove = _.throttle @onMouseMove, 25
|
||||
|
@ -33,17 +33,18 @@ module.exports = class DebugView extends View
|
|||
setVariableStates: (@variableStates) ->
|
||||
@update()
|
||||
|
||||
isIdentifier: (t) ->
|
||||
t and (t.type is 'identifier' or t.value is 'this' or @globals[t.value])
|
||||
|
||||
onMouseMove: (e) =>
|
||||
return if @destroyed
|
||||
pos = e.getDocumentPosition()
|
||||
endOfDoc = pos.row is @ace.getSession().getDocument().getLength() - 1
|
||||
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])
|
||||
while it.getCurrentTokenRow() is pos.row and not isIdentifier(token = it.getCurrentToken())
|
||||
endOfLine = it.getCurrentToken()?.index is it.$rowTokens.length - 1
|
||||
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()
|
||||
break unless token
|
||||
break if endOfDoc # Don't iterate backward on last line, since we might be way below.
|
||||
if isIdentifier token
|
||||
if @isIdentifier token
|
||||
# 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.
|
||||
start = it.getCurrentTokenColumn()
|
||||
|
@ -53,7 +54,7 @@ module.exports = class DebugView extends View
|
|||
break unless it.getCurrentToken()?.value is "."
|
||||
it.stepBackward()
|
||||
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
|
||||
start = it.getCurrentTokenColumn()
|
||||
chain.unshift token.value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue