From 8af62d53cda0d5b1e75fc2f994d078327eed2da9 Mon Sep 17 00:00:00 2001 From: Tay Yang Shun Date: Sat, 1 Mar 2014 01:55:30 +0800 Subject: [PATCH 1/6] Redirect to level editor only after modal hidden event is triggered. Fixes #438. --- app/views/kinds/SearchView.coffee | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/kinds/SearchView.coffee b/app/views/kinds/SearchView.coffee index 304a9e958..5e150c43a 100644 --- a/app/views/kinds/SearchView.coffee +++ b/app/views/kinds/SearchView.coffee @@ -24,6 +24,7 @@ module.exports = class ThangTypeHomeView extends View 'click button.new-model-submit': 'makeNewModel' 'submit form': 'makeNewModel' 'shown.bs.modal #new-model-modal': 'focusOnName' + 'hidden.bs.modal #new-model-modal': 'onModalHidden' getRenderData: -> c = super() @@ -85,16 +86,21 @@ module.exports = class ThangTypeHomeView extends View res = model.save() return unless res - modal = @$el.find('.modal') + modal = @$el.find('#new-model-modal') forms.clearFormAlerts(modal) @showLoading(modal.find('.modal-body')) res.error => @hideLoading() forms.applyErrorsToForm(modal, JSON.parse(res.responseText)) + that = @ res.success -> - modal.modal('hide') - base = document.location.pathname[1..] + '/' - app.router.navigate(base + (model.get('slug') or model.id), {trigger:true}) + that.model = model + modal.modal('hide') + + 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: -> @$el.find('#name').focus() From 2894d4f39c660c92f643e75dee28e0bf9415361f Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 28 Feb 2014 11:28:23 -0800 Subject: [PATCH 2/6] Set up session-repeating scripts. --- app/lib/scripts/ScriptManager.coffee | 2 ++ server/levels/level_schema.coffee | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/lib/scripts/ScriptManager.coffee b/app/lib/scripts/ScriptManager.coffee index fea1de010..004f7d854 100644 --- a/app/lib/scripts/ScriptManager.coffee +++ b/app/lib/scripts/ScriptManager.coffee @@ -102,6 +102,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass unless script console.warn "Couldn't find script for", scriptID, "from scripts", @scripts, "when restoring session scripts." continue + continue if script.repeats # repeating scripts are not 'rerun' @triggered.push(scriptID) @ended.push(scriptID) noteChain = @processScript(script) @@ -131,6 +132,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass alreadyTriggered = script.id in @triggered continue unless script.channel is channel 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.neverRun diff --git a/server/levels/level_schema.coffee b/server/levels/level_schema.coffee index 9b82c2446..d0d448267 100644 --- a/server/levels/level_schema.coffee +++ b/server/levels/level_schema.coffee @@ -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? 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 - 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."}, 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."}, From 52903cc0deae2962cda1523d9fab55fa0d8cbf80 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 28 Feb 2014 12:43:31 -0800 Subject: [PATCH 3/6] Using String and Array docs when appropriate now. --- app/views/play/level/tome/spell_palette_view.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/play/level/tome/spell_palette_view.coffee b/app/views/play/level/tome/spell_palette_view.coffee index e045d1842..f4c708a18 100644 --- a/app/views/play/level/tome/spell_palette_view.coffee +++ b/app/views/play/level/tome/spell_palette_view.coffee @@ -44,15 +44,16 @@ module.exports = class SpellPaletteView extends View allDocs = {} for lc in lcs for doc in (lc.get('propertyDocumentation') ? []) - allDocs[doc.name] ?= [] - allDocs[doc.name].push doc + allDocs['__' + doc.name] ?= [] + allDocs['__' + doc.name].push doc if doc.type is 'snippet' then doc.owner = 'snippets' - #allDocs[doc.name] = doc for doc in (lc.get('propertyDocumentation') ? []) for lc in lcs propStorage = 'this': 'programmableProperties' more: 'moreProgrammableProperties' Math: 'programmableMathProperties' + Array: 'programmableArrayProperties' + String: 'programmableStringProperties' Vector: 'programmableVectorProperties' snippets: 'programmableSnippets' count = 0 @@ -66,10 +67,10 @@ module.exports = class SpellPaletteView extends View @entries = [] for owner, props of propGroups for prop in props - doc = _.find (allDocs[prop] ? []), (doc) -> + doc = _.find (allDocs['__' + prop] ? []), (doc) -> return true if doc.owner is owner 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 @entries.push @addEntry(doc, shortenize, tabbify, owner is 'snippets') groupForEntry = (entry) -> From ee2a60d246257bbc6e39c3d7600d06505696a93e Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 28 Feb 2014 13:22:19 -0800 Subject: [PATCH 4/6] Updated README to point to GSoC and ChallengePost. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9ed94553b..192b6ff31 100644 --- a/README.md +++ b/README.md @@ -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) [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) \ No newline at end of file From 24b25b2d274224f80874b269b250f2ea1f9c53f5 Mon Sep 17 00:00:00 2001 From: Michael Schmatz Date: Fri, 28 Feb 2014 13:50:48 -0800 Subject: [PATCH 5/6] Replaced project-dota with level id and major version --- server/queues/scoring.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/queues/scoring.coffee b/server/queues/scoring.coffee index 40a6b2f21..08f0794d0 100644 --- a/server/queues/scoring.coffee +++ b/server/queues/scoring.coffee @@ -181,7 +181,8 @@ findNearestBetterSessionID = (sessionTotalScore, opponentSessionTotalScore, oppo $gt:opponentSessionTotalScore + 0.5 _id: $ne: opponentSessionID - levelID: "project-dota" + "level.original": "52d97ecd32362bc86e004e87" + "level.majorVersion": 0 submitted: true submittedCode: $exists: true @@ -280,7 +281,8 @@ updateSessionToSubmit = (sessionToUpdate, callback) -> fetchInitialSessionsToRankAgainst = (opposingTeam, callback) -> console.log "Fetching sessions to rank against for opposing team #{opposingTeam}" findParameters = - levelID: "project-dota" + "level.original": "52d97ecd32362bc86e004e87" + "level.majorVersion": 0 submitted: true submittedCode: $exists: true From 10795df7d96c7588b1a71808574837d0ae0064c4 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 28 Feb 2014 13:59:02 -0800 Subject: [PATCH 6/6] Renamed hardcoded project-dotas to brawlwoods. --- app/templates/play/ladder.jade | 2 +- app/views/play/level/control_bar_view.coffee | 4 ++-- app/views/play/level/tome/cast_button_view.coffee | 2 +- app/views/play/level/tome/tome_view.coffee | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/play/ladder.jade b/app/templates/play/ladder.jade index 66e05ff1b..1eb85a6f0 100644 --- a/app/templates/play/ladder.jade +++ b/app/templates/play/ladder.jade @@ -9,7 +9,7 @@ block content 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="/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 diff --git a/app/views/play/level/control_bar_view.coffee b/app/views/play/level/control_bar_view.coffee index 685452d81..392eb4ebf 100644 --- a/app/views/play/level/control_bar_view.coffee +++ b/app/views/play/level/control_bar_view.coffee @@ -54,8 +54,8 @@ module.exports = class ControlBarView extends View c.ladderGame = @ladderGame c.homeLink = "/" levelID = @level.get('slug') - if levelID in ["project-dota", "brawlwood", "ladder-tutorial"] - levelID = 'project-dota' if levelID is 'ladder-tutorial' + if levelID in ["brawlwood", "brawlwood-tutorial"] + levelID = 'brawlwood' if levelID is 'brawlwood-tutorial' c.homeLink = "/play/ladder/" + levelID c diff --git a/app/views/play/level/tome/cast_button_view.coffee b/app/views/play/level/tome/cast_button_view.coffee index 3fbd1af6b..98c8ab3c8 100644 --- a/app/views/play/level/tome/cast_button_view.coffee +++ b/app/views/play/level/tome/cast_button_view.coffee @@ -35,7 +35,7 @@ module.exports = class CastButtonView extends View # TODO: use a User setting instead of localStorage delay = localStorage.getItem 'autocastDelay' delay ?= 5000 - if @levelID in ['project-dota', 'brawlwood', 'ladder-tutorial'] + if @levelID in ['brawlwood', 'brawlwood-tutorial'] delay = 90019001 @setAutocastDelay delay diff --git a/app/views/play/level/tome/tome_view.coffee b/app/views/play/level/tome/tome_view.coffee index 5b525ad39..11fad104b 100644 --- a/app/views/play/level/tome/tome_view.coffee +++ b/app/views/play/level/tome/tome_view.coffee @@ -129,7 +129,7 @@ module.exports = class TomeView extends View @thangSpells[thang.id].push spellKey unless method.cloneOf 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 for thangID, spellKeys of @thangSpells thang = world.getThangByID thangID @@ -151,7 +151,7 @@ module.exports = class TomeView extends View @cast() cast: -> - if @options.levelID is 'project-dota' + if @options.levelID is 'brawlwood' # For performance reasons, only includeFlow on the currently Thang. for spellKey, spell of @spells for thangID, spellThang of spell.thangs