mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Start to play picoCTF levels as course levels without hero selection
This commit is contained in:
parent
fe351be32e
commit
37fbd8ca21
6 changed files with 17 additions and 14 deletions
|
@ -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)
|
||||
|
|
|
@ -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 = ->
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
init: init
|
||||
|
|
Loading…
Reference in a new issue