mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Including leather boots as required gear better. Labeling 'Your Skills'. Not showing a minus for incomplete goals. Adding script triggers for deleting required sample code.
This commit is contained in:
parent
9b29e9512f
commit
7da65dec5b
5 changed files with 40 additions and 5 deletions
|
@ -120,3 +120,6 @@ module.exports =
|
|||
'tome:maximize-toggled': c.object {title: 'Maximize Toggled', description: 'Published when the Tome has changed maximize/minimize state.'}
|
||||
|
||||
'tome:select-primary-sprite': c.object {title: 'Select Primary Sprite', description: 'Published to get the most important sprite\'s code selected.'}
|
||||
|
||||
'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'}
|
||||
|
|
|
@ -14,4 +14,5 @@ if entryGroupSlugs
|
|||
div(class="properties properties-" + slug + " nano-content")
|
||||
else
|
||||
// Hero; group by items, no tabs.
|
||||
h4(data-i18n="play_level.tome_your_skills")
|
||||
.properties
|
||||
|
|
|
@ -329,7 +329,7 @@ module.exports = class InventoryView extends CocoView
|
|||
'simple-boots': '53e237bf53457600003e3f05'
|
||||
'longsword': '53e218d853457600003e3ebe'
|
||||
'leather-tunic': '53e22eac53457600003e3efc'
|
||||
#'leather-boots': '53e2384453457600003e3f07'
|
||||
'leather-boots': '53e2384453457600003e3f07'
|
||||
'programmaticon-i': '53e4108204c00d4607a89f78'
|
||||
'crude-glasses': '53e238df53457600003e3f0b'
|
||||
'builders-hammer': '53f4e6e3d822c23505b74f42'
|
||||
|
@ -363,7 +363,7 @@ module.exports = class InventoryView extends CocoView
|
|||
inWorldMap = $('#world-map-view').length
|
||||
for slot, item of necessaryGear
|
||||
continue if item is 'leather-tunic' and inWorldMap # Don't tell them they need it until they need it in the level
|
||||
continue if equipment[slot] and not (item is 'builders-hammer' and equipment[slot] is gear.longsword)
|
||||
continue if equipment[slot] and not ((item is 'builders-hammer' and equipment[slot] is gear.longsword) or (item is 'leather-boots' and equipment[slot] is gear['simple-boots']))
|
||||
availableSlotSelector = "#available-equipment li[data-item-id='#{gear[item]}']"
|
||||
@highlightElement availableSlotSelector, delay: 500, sides: ['right'], rotation: Math.PI / 2
|
||||
@$el.find(availableSlotSelector).addClass 'should-equip'
|
||||
|
|
|
@ -4,7 +4,6 @@ template = require 'templates/play/level/goals'
|
|||
utils = require 'lib/utils'
|
||||
|
||||
stateIconMap =
|
||||
incomplete: 'glyphicon-minus'
|
||||
success: 'glyphicon-ok'
|
||||
failure: 'glyphicon-remove'
|
||||
|
||||
|
@ -61,7 +60,7 @@ module.exports = class LevelGoalsView extends CocoView
|
|||
# This should really get refactored, along with GoalManager, so that goals have a standard
|
||||
# representation of how many are done, how many are needed, what that means, etc.
|
||||
li = $('<li></li>').addClass("status-#{state.status}").text(text)
|
||||
li.prepend($('<i></i>').addClass('glyphicon').addClass(stateIconMap[state.status]))
|
||||
li.prepend($('<i></i>').addClass('glyphicon').addClass(iconClass) if iconClass = stateIconMap[state.status])
|
||||
list.append(li)
|
||||
goals.push goal
|
||||
if not firstRun and state.status is 'success' and @previousGoalStatus[goal.id] isnt 'success'
|
||||
|
|
|
@ -371,6 +371,7 @@ module.exports = class SpellView extends CocoView
|
|||
onCodeReload: (e) ->
|
||||
return unless e.spell is @spell
|
||||
@reloadCode true
|
||||
@ace.clearSelection()
|
||||
|
||||
reloadCode: (cast=true) ->
|
||||
@updateACEText @spell.originalSource
|
||||
|
@ -422,6 +423,7 @@ module.exports = class SpellView extends CocoView
|
|||
_.throttle @notifySpellChanged, 300
|
||||
_.throttle @updateLines, 500
|
||||
]
|
||||
onSignificantChange.push _.debounce @checkRequiredCode, 1500 if requiredCodePerLevel[@options.level.get('slug')]
|
||||
@onCodeChangeMetaHandler = =>
|
||||
return if @eventsSuppressed
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'code-change', volume: 0.5
|
||||
|
@ -564,7 +566,7 @@ module.exports = class SpellView extends CocoView
|
|||
guessWhetherFinished: (aether) ->
|
||||
valid = not aether.getAllProblems().length
|
||||
cursorPosition = @ace.getCursorPosition()
|
||||
currentLine = _.string.rtrim(@aceDoc.$lines[cursorPosition.row].replace(/[ \t]*\/\/[^"']*/g, '')) # trim // unless inside "
|
||||
currentLine = _.string.rtrim(@aceDoc.$lines[cursorPosition.row].replace(@singleLineCommentRegex(), '')) # trim // unless inside "
|
||||
endOfLine = cursorPosition.column >= currentLine.length # just typed a semicolon or brace, for example
|
||||
beginningOfLine = not currentLine.substr(0, cursorPosition.column).trim().length # uncommenting code, for example
|
||||
incompleteThis = /^(s|se|sel|self|t|th|thi|this)$/.test currentLine.trim()
|
||||
|
@ -575,6 +577,20 @@ module.exports = class SpellView extends CocoView
|
|||
else
|
||||
@recompile()
|
||||
|
||||
singleLineCommentRegex: ->
|
||||
return @_singleLineCommentRegex if @_singleLineCommentRegex
|
||||
commentStarts =
|
||||
javascript: '//'
|
||||
python: '#'
|
||||
coffeescript: '#'
|
||||
clojure: ';'
|
||||
lua: '--'
|
||||
io: '//'
|
||||
commentStart = commentStarts[@spell.language] or '//'
|
||||
@_singleLineCommentRegexp ?= new RegExp "[ \t]*#{commentStart}[^\"'\n]*", 'g'
|
||||
console.log 'got', @_singleLineCommentRegexp, 'from', "[ \t]*#{commentStart}[^\"']*", 'comment start is', commentStart, 'acuse lang is', @spell.language
|
||||
@_singleLineCommentRegexp
|
||||
|
||||
preload: ->
|
||||
# Send this code over to the God for preloading, but don't change the cast state.
|
||||
oldSource = @spell.source
|
||||
|
@ -829,6 +845,16 @@ module.exports = class SpellView extends CocoView
|
|||
onScriptStateChange: (e) ->
|
||||
@scriptRunning = if e.currentScript is null then false else true
|
||||
|
||||
checkRequiredCode: =>
|
||||
return if @destroyed
|
||||
source = @getSource().replace @singleLineCommentRegex(), ''
|
||||
for requiredCodeFragment in requiredCodePerLevel[@options.level.get('slug')]
|
||||
if source.indexOf(requiredCodeFragment) is -1
|
||||
@warnedCodeFragments ?= {}
|
||||
unless @warnedCodeFragments[requiredCodeFragment]
|
||||
Backbone.Mediator.publish 'tome:required-code-fragment-deleted', codeFragment: requiredCodeFragment
|
||||
@warnedCodeFragments[requiredCodeFragment] = true
|
||||
|
||||
destroy: ->
|
||||
$(@ace?.container).find('.ace_gutter').off 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
||||
@firepad?.dispose()
|
||||
|
@ -840,3 +866,9 @@ module.exports = class SpellView extends CocoView
|
|||
@debugView?.destroy()
|
||||
$(window).off 'resize', @onWindowResize
|
||||
super()
|
||||
|
||||
|
||||
requiredCodePerLevel =
|
||||
'true-names': ['Brak']
|
||||
'the-first-kithmaze': ['loop']
|
||||
'lowly-kithmen': ['findNearestEnemy']
|
||||
|
|
Loading…
Reference in a new issue