mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Fixed coordinate hover cursors fighting flag cursors. Added suspect code check functionality for scripts to slap hands.
This commit is contained in:
parent
63c516c5f5
commit
0640f382ba
5 changed files with 38 additions and 12 deletions
|
@ -10,6 +10,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots'}
|
requiredGear: {feet: 'simple-boots'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['moveRight']
|
||||||
'gems-in-the-deep':
|
'gems-in-the-deep':
|
||||||
disableSpaces: true
|
disableSpaces: true
|
||||||
hidesSubmitUntilRun: true
|
hidesSubmitUntilRun: true
|
||||||
|
@ -71,6 +72,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', waist: 'leather-belt'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', waist: 'leather-belt'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['Brak']
|
||||||
'favorable-odds':
|
'favorable-odds':
|
||||||
disableSpaces: true
|
disableSpaces: true
|
||||||
hidesRunShortcut: true
|
hidesRunShortcut: true
|
||||||
|
@ -97,6 +99,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
|
requiredGear: {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['loop']
|
||||||
'haunted-kithmaze':
|
'haunted-kithmaze':
|
||||||
hidesRunShortcut: true
|
hidesRunShortcut: true
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
|
@ -105,6 +108,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
|
requiredGear: {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['loop']
|
||||||
'descending-further':
|
'descending-further':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
|
@ -140,6 +144,8 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses', torso: 'leather-tunic'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses', torso: 'leather-tunic'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['findNearestEnemy']
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'lowly-kithmen':
|
'lowly-kithmen':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
|
@ -147,6 +153,8 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses', torso: 'leather-tunic'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses', torso: 'leather-tunic'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
requiredCode: ['findNearestEnemy']
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'closing-the-distance':
|
'closing-the-distance':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
|
@ -154,6 +162,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', eyes: 'crude-glasses'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', eyes: 'crude-glasses'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'tactical-strike':
|
'tactical-strike':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
|
@ -161,12 +170,14 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', eyes: 'crude-glasses'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', eyes: 'crude-glasses'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'the-final-kithmaze':
|
'the-final-kithmaze':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
hidesCodeToolbar: true
|
hidesCodeToolbar: true
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'the-gauntlet':
|
'the-gauntlet':
|
||||||
hidesHUD: true
|
hidesHUD: true
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
|
@ -174,6 +185,7 @@ module.exports = LevelOptions =
|
||||||
hidesRealTimePlayback: true
|
hidesRealTimePlayback: true
|
||||||
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
|
requiredGear: {feet: 'simple-boots', 'right-hand': 'simple-sword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
|
||||||
restrictedGear: {feet: 'leather-boots'}
|
restrictedGear: {feet: 'leather-boots'}
|
||||||
|
suspectCode: [{name: 'lone-find-nearest-enemy', pattern: /^[ ]*(self|this|@)?[:.]?findNearestEnemy()/m}]
|
||||||
'kithgard-gates':
|
'kithgard-gates':
|
||||||
hidesSay: true
|
hidesSay: true
|
||||||
hidesCodeToolbar: true
|
hidesCodeToolbar: true
|
||||||
|
|
|
@ -6,6 +6,7 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
||||||
'surface:mouse-over': 'onMouseOver'
|
'surface:mouse-over': 'onMouseOver'
|
||||||
'surface:stage-mouse-down': 'onMouseDown'
|
'surface:stage-mouse-down': 'onMouseDown'
|
||||||
'camera:zoom-updated': 'onZoomUpdated'
|
'camera:zoom-updated': 'onZoomUpdated'
|
||||||
|
'level:flag-color-selected': 'onFlagColorSelected'
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
super()
|
super()
|
||||||
|
@ -60,6 +61,9 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
||||||
@hide()
|
@hide()
|
||||||
@show()
|
@show()
|
||||||
|
|
||||||
|
onFlagColorSelected: (e) ->
|
||||||
|
@placingFlag = Boolean e.color
|
||||||
|
|
||||||
hide: ->
|
hide: ->
|
||||||
return unless @label.parent
|
return unless @label.parent
|
||||||
@removeChild @label
|
@removeChild @label
|
||||||
|
@ -154,6 +158,6 @@ module.exports = class CoordinateDisplay extends createjs.Container
|
||||||
@y = sup.y
|
@y = sup.y
|
||||||
@addChild @background
|
@addChild @background
|
||||||
@addChild @label
|
@addChild @label
|
||||||
@addChild @pointMarker
|
@addChild @pointMarker unless @placingFlag
|
||||||
@updateCache()
|
@updateCache()
|
||||||
Backbone.Mediator.publish 'surface:coordinates-shown', {}
|
Backbone.Mediator.publish 'surface:coordinates-shown', {}
|
||||||
|
|
|
@ -122,6 +122,10 @@ module.exports =
|
||||||
'tome:required-code-fragment-deleted': c.object {title: 'Required Code Fragment Deleted', description: 'Published when a required code fragment is deleted from the sample code.', required: ['codeFragment']},
|
'tome:required-code-fragment-deleted': c.object {title: 'Required Code Fragment Deleted', description: 'Published when a required code fragment is deleted from the sample code.', required: ['codeFragment']},
|
||||||
codeFragment: {type: 'string'}
|
codeFragment: {type: 'string'}
|
||||||
|
|
||||||
|
'tome:suspect-code-fragment-added': c.object {title: 'Suspect Code Fragment Added', description: 'Published when a suspect code fragment is added to the sample code.', required: ['codeFragment']},
|
||||||
|
codeFragment: {type: 'string'}
|
||||||
|
codeLanguage: {type: 'string'}
|
||||||
|
|
||||||
'tome:winnability-updated': c.object {title: 'Winnability Updated', description: 'When we think we can now win (or can no longer win), we may want to emphasize the submit button versus the run button (or vice versa), so this fires when we get new goal states (even preloaded goal states) suggesting success or failure change.', required: ['winnable']},
|
'tome:winnability-updated': c.object {title: 'Winnability Updated', description: 'When we think we can now win (or can no longer win), we may want to emphasize the submit button versus the run button (or vice versa), so this fires when we get new goal states (even preloaded goal states) suggesting success or failure change.', required: ['winnable']},
|
||||||
winnable: {type: 'boolean'}
|
winnable: {type: 'boolean'}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ module.exports = class InventoryModal extends ModalView
|
||||||
locked = not (item.get('original') in me.items())
|
locked = not (item.get('original') in me.items())
|
||||||
locked = false if me.get('slug') is 'nick'
|
locked = false if me.get('slug') is 'nick'
|
||||||
|
|
||||||
if not item.getFrontFacingStats().props.length and not _.size item.getFrontFacingStats().stats # Temp: while there are placeholder items
|
if not item.getFrontFacingStats().props.length and not _.size(item.getFrontFacingStats().stats) and not locked # Temp: while there are placeholder items
|
||||||
null # Don't put into a collection
|
null # Don't put into a collection
|
||||||
else if locked and item.get('slug') isnt 'simple-boots'
|
else if locked and item.get('slug') isnt 'simple-boots'
|
||||||
@itemGroups.lockedItems.add(item)
|
@itemGroups.lockedItems.add(item)
|
||||||
|
|
|
@ -450,7 +450,8 @@ module.exports = class SpellView extends CocoView
|
||||||
_.throttle @updateLines, 500
|
_.throttle @updateLines, 500
|
||||||
_.throttle @hideProblemAlert, 500
|
_.throttle @hideProblemAlert, 500
|
||||||
]
|
]
|
||||||
onSignificantChange.push _.debounce @checkRequiredCode, 1500 if requiredCodePerLevel[@options.level.get('slug')]
|
onSignificantChange.push _.debounce @checkRequiredCode, 750 if LevelOptions[@options.level.get('slug')]?.requiredCode
|
||||||
|
onSignificantChange.push _.debounce @checkSuspectCode, 750 if LevelOptions[@options.level.get('slug')]?.suspectCode
|
||||||
@onCodeChangeMetaHandler = =>
|
@onCodeChangeMetaHandler = =>
|
||||||
return if @eventsSuppressed
|
return if @eventsSuppressed
|
||||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'code-change', volume: 0.5
|
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'code-change', volume: 0.5
|
||||||
|
@ -881,13 +882,26 @@ module.exports = class SpellView extends CocoView
|
||||||
checkRequiredCode: =>
|
checkRequiredCode: =>
|
||||||
return if @destroyed
|
return if @destroyed
|
||||||
source = @getSource().replace @singleLineCommentRegex(), ''
|
source = @getSource().replace @singleLineCommentRegex(), ''
|
||||||
for requiredCodeFragment in requiredCodePerLevel[@options.level.get('slug')]
|
requiredCodeFragments = LevelOptions[@options.level.get('slug')].requiredCode
|
||||||
|
for requiredCodeFragment in requiredCodeFragments
|
||||||
|
# Could make this obey regular expressions like suspectCode if needed
|
||||||
if source.indexOf(requiredCodeFragment) is -1
|
if source.indexOf(requiredCodeFragment) is -1
|
||||||
@warnedCodeFragments ?= {}
|
@warnedCodeFragments ?= {}
|
||||||
unless @warnedCodeFragments[requiredCodeFragment]
|
unless @warnedCodeFragments[requiredCodeFragment]
|
||||||
Backbone.Mediator.publish 'tome:required-code-fragment-deleted', codeFragment: requiredCodeFragment
|
Backbone.Mediator.publish 'tome:required-code-fragment-deleted', codeFragment: requiredCodeFragment
|
||||||
@warnedCodeFragments[requiredCodeFragment] = true
|
@warnedCodeFragments[requiredCodeFragment] = true
|
||||||
|
|
||||||
|
checkSuspectCode: =>
|
||||||
|
return if @destroyed
|
||||||
|
source = @getSource().replace @singleLineCommentRegex(), ''
|
||||||
|
suspectCodeFragments = LevelOptions[@options.level.get('slug')].suspectCode
|
||||||
|
for suspectCodeFragment in suspectCodeFragments
|
||||||
|
if suspectCodeFragment.pattern.test source
|
||||||
|
@warnedCodeFragments ?= {}
|
||||||
|
unless @warnedCodeFragments[suspectCodeFragment.name]
|
||||||
|
Backbone.Mediator.publish 'tome:suspect-code-fragment-added', codeFragment: suspectCodeFragment.name, codeLanguage: @spell.language
|
||||||
|
@warnedCodeFragments[suspectCodeFragment] = true
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
$(@ace?.container).find('.ace_gutter').off 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
$(@ace?.container).find('.ace_gutter').off 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
||||||
$(@ace?.container).find('.ace_gutter').off 'click', @onGutterClick
|
$(@ace?.container).find('.ace_gutter').off 'click', @onGutterClick
|
||||||
|
@ -900,11 +914,3 @@ module.exports = class SpellView extends CocoView
|
||||||
@debugView?.destroy()
|
@debugView?.destroy()
|
||||||
$(window).off 'resize', @onWindowResize
|
$(window).off 'resize', @onWindowResize
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
|
||||||
requiredCodePerLevel =
|
|
||||||
'dungeons-of-kithgard': ['moveRight']
|
|
||||||
'true-names': ['Brak']
|
|
||||||
'the-first-kithmaze': ['loop']
|
|
||||||
'haunted-kithmaze': ['loop']
|
|
||||||
'lowly-kithmen': ['findNearestEnemy']
|
|
||||||
|
|
Loading…
Reference in a new issue