Refactored defaults for Aether's fancy options, and overriding them with query parameters. Reduced non-dev-mode script debug logging.

This commit is contained in:
Nick Winter 2014-03-27 13:36:33 -07:00
parent c076bb1da8
commit 127c4a4e0f
3 changed files with 12 additions and 11 deletions

View file

@ -49,6 +49,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
@originalScripts = options.scripts
@view = options.view
@session = options.session
@debugScripts = @view.getQueryVariable 'dev'
@initProperties()
@addScriptSubscriptions()
@ -146,7 +147,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
continue unless @scriptPrereqsSatisfied(script)
continue unless scriptMatchesEventPrereqs(script, event)
# everything passed!
console.log "SCRIPT: Running script '#{script.id}'"
console.log "SCRIPT: Running script '#{script.id}'" if @debugScripts
script.lastTriggered = new Date().getTime()
@triggered.push(script.id) unless alreadyTriggered
noteChain = @processScript(script)
@ -206,7 +207,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
@notifyScriptStateChanged()
@scriptInProgress = true
@currentTimeouts = []
console.log "SCRIPT: Starting note group '#{nextNoteGroup.name}'"
console.log "SCRIPT: Starting note group '#{nextNoteGroup.name}'" if @debugScripts
for module in nextNoteGroup.modules
@processNote(note, nextNoteGroup) for note in module.startNotes()
if nextNoteGroup.script.duration
@ -220,7 +221,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
@ignoreEvents = true
for noteGroup, i in @noteGroupQueue
break unless noteGroup.skipMe
console.log "SCRIPT: Skipping note group '#{noteGroup.name}'"
console.log "SCRIPT: Skipping note group '#{noteGroup.name}'" if @debugScripts
@processNoteGroup(noteGroup)
for module in noteGroup.modules
notes = module.skipNotes()
@ -267,7 +268,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
return if @ending # kill infinite loops right here
@ending = true
return unless @currentNoteGroup?
console.log "SCRIPT: Ending note group '#{@currentNoteGroup.name}'"
console.log "SCRIPT: Ending note group '#{@currentNoteGroup.name}'" if @debugScripts
clearTimeout(timeout) for timeout in @currentTimeouts
for module in @currentNoteGroup.modules
@processNote(note, @currentNoteGroup) for note in module.endNotes()

View file

@ -196,12 +196,12 @@ module.exports = class CocoView extends Backbone.View
# Utilities
getQueryVariable: (param) ->
getQueryVariable: (param, defaultValue) ->
query = document.location.search.substring 1
pairs = (pair.split("=") for pair in query.split "&")
for pair in pairs
return decodeURIComponent(pair[1]) if pair[0] is param
null
for pair in pairs when pair[0] is param
return {"true": true, "false": false}[pair[1]] ? decodeURIComponent(pair[1])
defaultValue
getRootView: ->
view = @

View file

@ -128,9 +128,9 @@ module.exports = class TomeView extends View
spellKey = pathComponents.join '/'
@thangSpells[thang.id].push spellKey
unless method.cloneOf
skipProtectAPI = @getQueryVariable("skip_protect_api") is "true" or @options.levelID isnt 'brawlwood'
skipProtectAPI = false if @options.levelID is 'dungeon-arena'
skipFlow = @getQueryVariable("skip_flow") is "true" or @options.levelID is 'brawlwood'
skipProtectAPI = @getQueryVariable "skip_protect_api", not @options.ladderGame
skipFlow = @getQueryVariable "skip_flow", @options.levelID is 'brawlwood'
console.log 'skip protect api', skipProtectAPI, 'skip flow', skipFlow
spell = @spells[spellKey] = new Spell programmableMethod: method, spellKey: spellKey, pathComponents: pathPrefixComponents.concat(pathComponents), session: @options.session, supermodel: @supermodel, skipFlow: skipFlow, skipProtectAPI: skipProtectAPI, worker: @worker
for thangID, spellKeys of @thangSpells
thang = world.getThangByID thangID