diff --git a/app/core/Router.coffee b/app/core/Router.coffee index a0f3ed408..60b28886e 100644 --- a/app/core/Router.coffee +++ b/app/core/Router.coffee @@ -149,7 +149,7 @@ module.exports = class CocoRouter extends Backbone.Router @navigate e, {trigger: true} routeDirectly: (path, args, options={}) -> - path = 'play/CampaignView' if window.serverConfig.picoCTF and not /^(views\/)?play/.test(path) + path = 'play/CampaignView' if window.serverConfig.picoCTF and not /^(views)?\/?play/.test(path) path = "views/#{path}" if not _.string.startsWith(path, 'views/') ViewClass = @tryToLoadModule path if not ViewClass and application.moduleLoader.load(path) diff --git a/app/lib/LevelLoader.coffee b/app/lib/LevelLoader.coffee index b93a02306..d9dd67feb 100644 --- a/app/lib/LevelLoader.coffee +++ b/app/lib/LevelLoader.coffee @@ -58,7 +58,7 @@ module.exports = class LevelLoader extends CocoClass @listenToOnce @level, 'sync', @onLevelLoaded onLevelLoaded: -> - if @courseID and @level.get('type', true) not in ['course', 'course-ladder'] + if (@courseID and @level.get('type', true) not in ['course', 'course-ladder']) or window.serverConfig.picoCTF # Because we now use original hero levels for both hero and course levels, we fake being a course level in this context. originalGet = @level.get @level.get = -> diff --git a/app/lib/LevelSetupManager.coffee b/app/lib/LevelSetupManager.coffee index a7cb843ba..1b66c5bf5 100644 --- a/app/lib/LevelSetupManager.coffee +++ b/app/lib/LevelSetupManager.coffee @@ -74,7 +74,7 @@ module.exports = class LevelSetupManager extends CocoClass @session.set 'heroConfig', {"thangType":raider,"inventory":{}} @onInventoryModalPlayClicked() return - if @level.get('type', true) in ['course', 'course-ladder'] + if @level.get('type', true) in ['course', 'course-ladder'] or window.serverConfig.picoCTF @onInventoryModalPlayClicked() return @heroesModal = new PlayHeroesModal({supermodel: @supermodel, session: @session, confirmButtonI18N: 'play.next', level: @level, hadEverChosenHero: @options.hadEverChosenHero}) diff --git a/app/views/play/CampaignView.coffee b/app/views/play/CampaignView.coffee index 4c95fa114..7ad727958 100644 --- a/app/views/play/CampaignView.coffee +++ b/app/views/play/CampaignView.coffee @@ -515,11 +515,12 @@ module.exports = class CampaignView extends RootView levelSlug = levelElement.data 'level-slug' session = @preloadedSession if @preloadedSession?.loaded and @preloadedSession.levelSlug is levelSlug @setupManager = new LevelSetupManager supermodel: @supermodel, levelID: levelSlug, levelPath: levelElement.data('level-path'), levelName: levelElement.data('level-name'), hadEverChosenHero: @hadEverChosenHero, parent: @, session: session - @$levelInfo.find('.level-info, .progress').toggleClass('hide') - @listenToOnce @setupManager, 'open', -> + unless @setupManager?.navigatingToPlay @$levelInfo.find('.level-info, .progress').toggleClass('hide') - @$levelInfo?.hide() - @setupManager.open() + @listenToOnce @setupManager, 'open', -> + @$levelInfo?.find('.level-info, .progress').toggleClass('hide') + @$levelInfo?.hide() + @setupManager.open() onClickViewSolutions: (e) -> levelElement = $(e.target).parents('.level-info-container') @@ -599,6 +600,7 @@ module.exports = class CampaignView extends RootView @$el.find(".course-version[data-level-original='#{levelOriginal}']").removeClass('hidden').data('course-id': courseInstance.get('courseID'), 'course-instance-id': courseInstance.id) preloadTopHeroes: -> + return if window.serverConfig.picoCTF for heroID in ['captain', 'knight'] url = "/db/thang.type/#{ThangType.heroes[heroID]}/version" continue if @supermodel.getModel url diff --git a/app/views/play/level/PlayLevelView.coffee b/app/views/play/level/PlayLevelView.coffee index ac8af7888..fb882374e 100644 --- a/app/views/play/level/PlayLevelView.coffee +++ b/app/views/play/level/PlayLevelView.coffee @@ -192,9 +192,9 @@ module.exports = class PlayLevelView extends RootView # TODO: Update terminology to always be opponentSession or otherSession # TODO: E.g. if it's always opponent right now, then variable names should be opponentSession until we have coop play @otherSession = @levelLoader.opponentSession - @worldLoadFakeResources = [] # first element (0) is 1%, last (100) is 100% + @worldLoadFakeResources = [] # first element (0) is 1%, last (99) is 100% for percent in [1 .. 100] - @worldLoadFakeResources.push @supermodel.addSomethingResource "world_simulation_#{percent}%", 1 + @worldLoadFakeResources.push @supermodel.addSomethingResource 1 onWorldLoadProgressChanged: (e) -> return unless e.god is @god diff --git a/server/lib/picoctf.coffee b/server/lib/picoctf.coffee index bd5544731..073e4f984 100644 --- a/server/lib/picoctf.coffee +++ b/server/lib/picoctf.coffee @@ -6,9 +6,9 @@ http = require 'http' authstr = new Buffer("#{config.picoCTF_auth.username}:#{config.picoCTF_auth.password}").toString 'base64' papi = (url, req, cb) -> - request + request url: "#{config.picoCTF_api_url}#{url}" - headers: + headers: Cookie: "flask=#{req.cookies.flask}" Authorization: 'Basic ' + authstr , cb @@ -35,6 +35,7 @@ class PicoStrategy name: data.team_name email: fakeEmail emailLower: fakeEmail + aceConfig: {language: 'javascript'} user.set 'testGroupNumber', Math.floor(Math.random() * 256) # also in app/core/auth user.save (err) => console.log "New user created!", user @@ -51,7 +52,7 @@ init = (app) -> res.json JSON.parse(body).data app.post '/picoctf/submit', (req, res) -> - request + request url: "#{config.picoCTF_APIURL}/submit" headers: Cookie: "flask=#{req.cookies.flask}" @@ -59,6 +60,6 @@ init = (app) -> , (err, rr, body) -> res.json JSON.parse(body) -module.exports = +module.exports = PicoStrategy: PicoStrategy - init: init \ No newline at end of file + init: init