mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 17:02:18 -05:00
commit
3b84917353
10 changed files with 35 additions and 18 deletions
|
@ -19,3 +19,9 @@ Whether you're novice or pro, the CodeCombat team is ready to help you implement
|
||||||
### [License](https://github.com/codecombat/codecombat/blob/master/LICENSE)
|
### [License](https://github.com/codecombat/codecombat/blob/master/LICENSE)
|
||||||
|
|
||||||
[MIT](https://github.com/codecombat/codecombat/blob/master/LICENSE) for the code, and [CC-BY](http://codecombat.com/legal) for the art and music. Please also [sign the CodeCombat contributor license agreement](http://codecombat.com/cla) so we can accept your pull requests. It is easy.
|
[MIT](https://github.com/codecombat/codecombat/blob/master/LICENSE) for the code, and [CC-BY](http://codecombat.com/legal) for the art and music. Please also [sign the CodeCombat contributor license agreement](http://codecombat.com/cla) so we can accept your pull requests. It is easy.
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
[![](https://dl.dropboxusercontent.com/u/138899/GitHub%20Wikis/challengepost.png)](http://codecombat.challengepost.com/?utm_source-github&utm_medium-oswidget&utm_campaign-codecombat)
|
||||||
|
|
||||||
|
[![](http://1-ps.googleusercontent.com/x/s.google-melange.appspot.com/www.google-melange.com/soc/content/2-1-20140225/images/gsoc/logo/920x156xbanner-gsoc2014.png.pagespeed.ic.gdr4t3Igca.png)](http://www.google-melange.com/gsoc/homepage/google/gsoc2014)
|
|
@ -102,6 +102,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
unless script
|
unless script
|
||||||
console.warn "Couldn't find script for", scriptID, "from scripts", @scripts, "when restoring session scripts."
|
console.warn "Couldn't find script for", scriptID, "from scripts", @scripts, "when restoring session scripts."
|
||||||
continue
|
continue
|
||||||
|
continue if script.repeats # repeating scripts are not 'rerun'
|
||||||
@triggered.push(scriptID)
|
@triggered.push(scriptID)
|
||||||
@ended.push(scriptID)
|
@ended.push(scriptID)
|
||||||
noteChain = @processScript(script)
|
noteChain = @processScript(script)
|
||||||
|
@ -131,6 +132,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
alreadyTriggered = script.id in @triggered
|
alreadyTriggered = script.id in @triggered
|
||||||
continue unless script.channel is channel
|
continue unless script.channel is channel
|
||||||
continue if alreadyTriggered and not script.repeats
|
continue if alreadyTriggered and not script.repeats
|
||||||
|
continue if script.lastTriggered? and script.repeats is 'session'
|
||||||
continue if script.lastTriggered? and new Date().getTime() - script.lastTriggered < 1
|
continue if script.lastTriggered? and new Date().getTime() - script.lastTriggered < 1
|
||||||
continue if script.neverRun
|
continue if script.neverRun
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ block content
|
||||||
if !me.get('anonymous')
|
if !me.get('anonymous')
|
||||||
//a(href="http://www.youtube.com/watch?v=IFvfZiJGDsw&list=HL1392928835&feature=mh_lolz").intro-button.btn.btn-primary.btn-lg Watch the Video
|
//a(href="http://www.youtube.com/watch?v=IFvfZiJGDsw&list=HL1392928835&feature=mh_lolz").intro-button.btn.btn-primary.btn-lg Watch the Video
|
||||||
|
|
||||||
a(href="/play/level/ladder-tutorial").intro-button.btn.btn-primary.btn-lg Play the Tutorial
|
a(href="/play/level/brawlwood-tutorial").intro-button.btn.btn-primary.btn-lg Play the Tutorial
|
||||||
|
|
||||||
hr
|
hr
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ module.exports = class ThangTypeHomeView extends View
|
||||||
'click button.new-model-submit': 'makeNewModel'
|
'click button.new-model-submit': 'makeNewModel'
|
||||||
'submit form': 'makeNewModel'
|
'submit form': 'makeNewModel'
|
||||||
'shown.bs.modal #new-model-modal': 'focusOnName'
|
'shown.bs.modal #new-model-modal': 'focusOnName'
|
||||||
|
'hidden.bs.modal #new-model-modal': 'onModalHidden'
|
||||||
|
|
||||||
getRenderData: ->
|
getRenderData: ->
|
||||||
c = super()
|
c = super()
|
||||||
|
@ -85,16 +86,21 @@ module.exports = class ThangTypeHomeView extends View
|
||||||
res = model.save()
|
res = model.save()
|
||||||
return unless res
|
return unless res
|
||||||
|
|
||||||
modal = @$el.find('.modal')
|
modal = @$el.find('#new-model-modal')
|
||||||
forms.clearFormAlerts(modal)
|
forms.clearFormAlerts(modal)
|
||||||
@showLoading(modal.find('.modal-body'))
|
@showLoading(modal.find('.modal-body'))
|
||||||
res.error =>
|
res.error =>
|
||||||
@hideLoading()
|
@hideLoading()
|
||||||
forms.applyErrorsToForm(modal, JSON.parse(res.responseText))
|
forms.applyErrorsToForm(modal, JSON.parse(res.responseText))
|
||||||
|
that = @
|
||||||
res.success ->
|
res.success ->
|
||||||
|
that.model = model
|
||||||
modal.modal('hide')
|
modal.modal('hide')
|
||||||
base = document.location.pathname[1..] + '/'
|
|
||||||
app.router.navigate(base + (model.get('slug') or model.id), {trigger:true})
|
onModalHidden: ->
|
||||||
|
# Can only redirect after the modal hidden event has triggered
|
||||||
|
base = document.location.pathname[1..] + '/'
|
||||||
|
app.router.navigate(base + (@model.get('slug') or @model.id), {trigger:true})
|
||||||
|
|
||||||
focusOnName: ->
|
focusOnName: ->
|
||||||
@$el.find('#name').focus()
|
@$el.find('#name').focus()
|
||||||
|
|
|
@ -54,8 +54,8 @@ module.exports = class ControlBarView extends View
|
||||||
c.ladderGame = @ladderGame
|
c.ladderGame = @ladderGame
|
||||||
c.homeLink = "/"
|
c.homeLink = "/"
|
||||||
levelID = @level.get('slug')
|
levelID = @level.get('slug')
|
||||||
if levelID in ["project-dota", "brawlwood", "ladder-tutorial"]
|
if levelID in ["brawlwood", "brawlwood-tutorial"]
|
||||||
levelID = 'project-dota' if levelID is 'ladder-tutorial'
|
levelID = 'brawlwood' if levelID is 'brawlwood-tutorial'
|
||||||
c.homeLink = "/play/ladder/" + levelID
|
c.homeLink = "/play/ladder/" + levelID
|
||||||
c
|
c
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = class CastButtonView extends View
|
||||||
# TODO: use a User setting instead of localStorage
|
# TODO: use a User setting instead of localStorage
|
||||||
delay = localStorage.getItem 'autocastDelay'
|
delay = localStorage.getItem 'autocastDelay'
|
||||||
delay ?= 5000
|
delay ?= 5000
|
||||||
if @levelID in ['project-dota', 'brawlwood', 'ladder-tutorial']
|
if @levelID in ['brawlwood', 'brawlwood-tutorial']
|
||||||
delay = 90019001
|
delay = 90019001
|
||||||
@setAutocastDelay delay
|
@setAutocastDelay delay
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,16 @@ module.exports = class SpellPaletteView extends View
|
||||||
allDocs = {}
|
allDocs = {}
|
||||||
for lc in lcs
|
for lc in lcs
|
||||||
for doc in (lc.get('propertyDocumentation') ? [])
|
for doc in (lc.get('propertyDocumentation') ? [])
|
||||||
allDocs[doc.name] ?= []
|
allDocs['__' + doc.name] ?= []
|
||||||
allDocs[doc.name].push doc
|
allDocs['__' + doc.name].push doc
|
||||||
if doc.type is 'snippet' then doc.owner = 'snippets'
|
if doc.type is 'snippet' then doc.owner = 'snippets'
|
||||||
#allDocs[doc.name] = doc for doc in (lc.get('propertyDocumentation') ? []) for lc in lcs
|
|
||||||
|
|
||||||
propStorage =
|
propStorage =
|
||||||
'this': 'programmableProperties'
|
'this': 'programmableProperties'
|
||||||
more: 'moreProgrammableProperties'
|
more: 'moreProgrammableProperties'
|
||||||
Math: 'programmableMathProperties'
|
Math: 'programmableMathProperties'
|
||||||
|
Array: 'programmableArrayProperties'
|
||||||
|
String: 'programmableStringProperties'
|
||||||
Vector: 'programmableVectorProperties'
|
Vector: 'programmableVectorProperties'
|
||||||
snippets: 'programmableSnippets'
|
snippets: 'programmableSnippets'
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -66,10 +67,10 @@ module.exports = class SpellPaletteView extends View
|
||||||
@entries = []
|
@entries = []
|
||||||
for owner, props of propGroups
|
for owner, props of propGroups
|
||||||
for prop in props
|
for prop in props
|
||||||
doc = _.find (allDocs[prop] ? []), (doc) ->
|
doc = _.find (allDocs['__' + prop] ? []), (doc) ->
|
||||||
return true if doc.owner is owner
|
return true if doc.owner is owner
|
||||||
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
||||||
console.log 'could not find doc for', prop, 'from', allDocs[prop], 'for', owner, 'of', propGroups unless doc
|
console.log 'could not find doc for', prop, 'from', allDocs['__' + prop], 'for', owner, 'of', propGroups unless doc
|
||||||
doc ?= prop
|
doc ?= prop
|
||||||
@entries.push @addEntry(doc, shortenize, tabbify, owner is 'snippets')
|
@entries.push @addEntry(doc, shortenize, tabbify, owner is 'snippets')
|
||||||
groupForEntry = (entry) ->
|
groupForEntry = (entry) ->
|
||||||
|
|
|
@ -129,7 +129,7 @@ module.exports = class TomeView extends View
|
||||||
@thangSpells[thang.id].push spellKey
|
@thangSpells[thang.id].push spellKey
|
||||||
unless method.cloneOf
|
unless method.cloneOf
|
||||||
skipProtectAPI = true #@getQueryVariable("skip_protect_api") is "true"
|
skipProtectAPI = true #@getQueryVariable("skip_protect_api") is "true"
|
||||||
skipFlow = @getQueryVariable("skip_flow") is "true" or @options.levelID is 'project-dota'
|
skipFlow = @getQueryVariable("skip_flow") is "true" or @options.levelID is 'brawlwood'
|
||||||
spell = @spells[spellKey] = new Spell programmableMethod: method, spellKey: spellKey, pathComponents: pathPrefixComponents.concat(pathComponents), session: @options.session, supermodel: @supermodel, skipFlow: skipFlow, skipProtectAPI: skipProtectAPI, worker: @worker
|
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
|
for thangID, spellKeys of @thangSpells
|
||||||
thang = world.getThangByID thangID
|
thang = world.getThangByID thangID
|
||||||
|
@ -151,7 +151,7 @@ module.exports = class TomeView extends View
|
||||||
@cast()
|
@cast()
|
||||||
|
|
||||||
cast: ->
|
cast: ->
|
||||||
if @options.levelID is 'project-dota'
|
if @options.levelID is 'brawlwood'
|
||||||
# For performance reasons, only includeFlow on the currently Thang.
|
# For performance reasons, only includeFlow on the currently Thang.
|
||||||
for spellKey, spell of @spells
|
for spellKey, spell of @spells
|
||||||
for thangID, spellThang of spell.thangs
|
for thangID, spellThang of spell.thangs
|
||||||
|
|
|
@ -145,7 +145,7 @@ ScriptSchema = c.object {
|
||||||
id: c.shortString(title: "ID", description: "A unique ID that other scripts can rely on in their Happens After prereqs, for sequencing.") # uniqueness?
|
id: c.shortString(title: "ID", description: "A unique ID that other scripts can rely on in their Happens After prereqs, for sequencing.") # uniqueness?
|
||||||
channel: c.shortString(title: "Event", format: 'event-channel', description: 'Event channel this script might trigger for, like "world:won".')
|
channel: c.shortString(title: "Event", format: 'event-channel', description: 'Event channel this script might trigger for, like "world:won".')
|
||||||
eventPrereqs: c.array {title: "Event Checks", description: "Logical checks on the event for this script to trigger.", format:'event-prereqs'}, EventPrereqSchema
|
eventPrereqs: c.array {title: "Event Checks", description: "Logical checks on the event for this script to trigger.", format:'event-prereqs'}, EventPrereqSchema
|
||||||
repeats: {title: "Repeats", description: "Whether this script can trigger more than once during a level.", type: 'boolean', "default": false}
|
repeats: {title: "Repeats", description: "Whether this script can trigger more than once during a level.", enum: [true, false, 'session'], "default": false}
|
||||||
scriptPrereqs: c.array {title: "Happens After", description: "Scripts that need to fire first."},
|
scriptPrereqs: c.array {title: "Happens After", description: "Scripts that need to fire first."},
|
||||||
c.shortString(title: "ID", description: "A unique ID of a script.")
|
c.shortString(title: "ID", description: "A unique ID of a script.")
|
||||||
notAfter: c.array {title: "Not After", description: "Do not run this script if any of these scripts have run."},
|
notAfter: c.array {title: "Not After", description: "Do not run this script if any of these scripts have run."},
|
||||||
|
|
|
@ -181,7 +181,8 @@ findNearestBetterSessionID = (sessionTotalScore, opponentSessionTotalScore, oppo
|
||||||
$gt:opponentSessionTotalScore + 0.5
|
$gt:opponentSessionTotalScore + 0.5
|
||||||
_id:
|
_id:
|
||||||
$ne: opponentSessionID
|
$ne: opponentSessionID
|
||||||
levelID: "project-dota"
|
"level.original": "52d97ecd32362bc86e004e87"
|
||||||
|
"level.majorVersion": 0
|
||||||
submitted: true
|
submitted: true
|
||||||
submittedCode:
|
submittedCode:
|
||||||
$exists: true
|
$exists: true
|
||||||
|
@ -280,7 +281,8 @@ updateSessionToSubmit = (sessionToUpdate, callback) ->
|
||||||
fetchInitialSessionsToRankAgainst = (opposingTeam, callback) ->
|
fetchInitialSessionsToRankAgainst = (opposingTeam, callback) ->
|
||||||
console.log "Fetching sessions to rank against for opposing team #{opposingTeam}"
|
console.log "Fetching sessions to rank against for opposing team #{opposingTeam}"
|
||||||
findParameters =
|
findParameters =
|
||||||
levelID: "project-dota"
|
"level.original": "52d97ecd32362bc86e004e87"
|
||||||
|
"level.majorVersion": 0
|
||||||
submitted: true
|
submitted: true
|
||||||
submittedCode:
|
submittedCode:
|
||||||
$exists: true
|
$exists: true
|
||||||
|
|
Loading…
Reference in a new issue