mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-22 10:55:19 -04:00
Submit picoCTF solutions, show progress, disable sound
This commit is contained in:
parent
0b6390795a
commit
1ccad78782
6 changed files with 29 additions and 19 deletions
app
templates/play
views/play
server/lib
|
@ -138,7 +138,7 @@ else
|
|||
if me.isPremium()
|
||||
button.btn.btn-illustrated.btn-primary(data-i18n="nav.contact", data-toggle="coco-modal", data-target="core/ContactModal") Contact
|
||||
|
||||
button.btn.btn-lg.btn-inverse.campaign-control-button#volume-button(data-i18n="[title]play.adjust_volume", title="Adjust volume")
|
||||
button.btn.btn-lg.btn-inverse.campaign-control-button.picoctf-hide#volume-button(data-i18n="[title]play.adjust_volume", title="Adjust volume")
|
||||
.glyphicon.glyphicon-volume-off
|
||||
.glyphicon.glyphicon-volume-down
|
||||
.glyphicon.glyphicon-volume-up
|
||||
|
@ -152,7 +152,7 @@ if editorMode
|
|||
.glyphicon.glyphicon-refresh
|
||||
|
||||
if campaign && campaign.loaded
|
||||
h1#campaign-status
|
||||
h1#campaign-status.picoctf-hide
|
||||
.campaign-status-background
|
||||
.campaign-name
|
||||
- var fullName = i18n(campaign.attributes, 'fullName')
|
||||
|
|
|
@ -3,11 +3,11 @@ button.btn.btn-xs.btn-inverse#play-button.paused(title="Ctrl/Cmd + P: Toggle lev
|
|||
.glyphicon.glyphicon-pause
|
||||
.glyphicon.glyphicon-repeat
|
||||
|
||||
button.btn.btn-xs.btn-inverse#volume-button(title="Adjust volume")
|
||||
button.btn.btn-xs.btn-inverse.picoctf-hide#volume-button(title="Adjust volume")
|
||||
.glyphicon.glyphicon-volume-off
|
||||
.glyphicon.glyphicon-volume-down
|
||||
.glyphicon.glyphicon-volume-up
|
||||
button.btn.btn-xs.btn-inverse#music-button(title="Toggle Music")
|
||||
button.btn.btn-xs.btn-inverse.picoctf-hide#music-button(title="Toggle Music")
|
||||
span ♫
|
||||
|
||||
.scrubber
|
||||
|
|
|
@ -275,6 +275,16 @@ module.exports = class CampaignView extends RootView
|
|||
level.locked = false if @campaign?.get('name') in ['Auditions', 'Intro']
|
||||
level.locked = false if me.isInGodMode()
|
||||
#level.locked = false if level.slug is 'robot-ragnarok'
|
||||
level.disabled = true if level.adminOnly and @levelStatusMap[level.slug] not in ['started', 'complete']
|
||||
level.disabled = false if me.isInGodMode()
|
||||
level.color = 'rgb(255, 80, 60)'
|
||||
if level.requiresSubscription
|
||||
level.color = 'rgb(80, 130, 200)'
|
||||
if unlocksHero = _.find(level.rewards, 'hero')?.hero
|
||||
level.unlocksHero = unlocksHero
|
||||
if level.unlocksHero
|
||||
level.purchasedHero = level.unlocksHero in (me.get('purchased')?.heroes or [])
|
||||
|
||||
if window.serverConfig.picoCTF
|
||||
if problem = _.find(@picoCTFProblems or [], pid: level.picoCTFProblem)
|
||||
level.locked = false if problem.unlocked or level.slug is 'digital-graffiti'
|
||||
|
@ -285,15 +295,8 @@ module.exports = class CampaignView extends RootView
|
|||
|
||||
#{problem.category} - #{problem.score} points
|
||||
"""
|
||||
level.disabled = true if level.adminOnly and @levelStatusMap[level.slug] not in ['started', 'complete']
|
||||
level.disabled = false if me.isInGodMode()
|
||||
level.color = 'rgb(255, 80, 60)'
|
||||
if level.requiresSubscription
|
||||
level.color = 'rgb(80, 130, 200)'
|
||||
if unlocksHero = _.find(level.rewards, 'hero')?.hero
|
||||
level.unlocksHero = unlocksHero
|
||||
if level.unlocksHero
|
||||
level.purchasedHero = level.unlocksHero in (me.get('purchased')?.heroes or [])
|
||||
level.color = 'rgb(80, 130, 200)' if problem.solved
|
||||
|
||||
level.hidden = level.locked
|
||||
if level.concepts?.length
|
||||
level.displayConcepts = level.concepts
|
||||
|
|
|
@ -10,9 +10,9 @@ module.exports = class PicoCTFVictoryModal extends ModalView
|
|||
@session = options.session
|
||||
@level = options.level
|
||||
|
||||
console.log 'damn we got dat flag', options.world.picoCTFFlag
|
||||
@supermodel.addRequestResource(url: '/picoctf/submit', method: 'POST', data: {flag: options.world.picoCTFFlag}, success: (response) =>
|
||||
console.log 'submitted the flag and got response', response
|
||||
form = {flag: options.world.picoCTFFlag, pid: @level.picoCTFProblem.pid}
|
||||
@supermodel.addRequestResource(url: '/picoctf/submit', method: 'POST', data: form, success: (response) =>
|
||||
console.log 'submitted', form, 'and got response', response
|
||||
).load()
|
||||
|
||||
@playSound 'victory'
|
||||
|
|
|
@ -32,6 +32,7 @@ module.exports = class GameMenuModal extends ModalView
|
|||
context = super(context)
|
||||
docs = @options.level.get('documentation') ? {}
|
||||
submenus = ['guide', 'options', 'save-load', 'multiplayer']
|
||||
submenus = _.without submenus, 'options' if window.serverConfig.picoCTF
|
||||
submenus = _.without submenus, 'guide' unless docs.specificArticles?.length or docs.generalArticles?.length or window.serverConfig.picoCTF
|
||||
submenus = _.without submenus, 'save-load' unless me.isAdmin() or /https?:\/\/localhost/.test(window.location.href)
|
||||
submenus = _.without submenus, 'multiplayer' unless me.isAdmin() or (@level?.get('type') in ['ladder', 'hero-ladder', 'course-ladder'] and @level.get('slug') not in ['ace-of-coders', 'elemental-wars'])
|
||||
|
|
|
@ -37,6 +37,7 @@ class PicoStrategy
|
|||
email: fakeEmail
|
||||
emailLower: fakeEmail
|
||||
aceConfig: {language: 'javascript'}
|
||||
volume: 0
|
||||
user.set 'testGroupNumber', Math.floor(Math.random() * 256) # also in app/core/auth
|
||||
user.save (err) =>
|
||||
console.log "New user created!", user
|
||||
|
@ -53,10 +54,15 @@ init = (app) ->
|
|||
res.json JSON.parse(body).data
|
||||
|
||||
app.post '/picoctf/submit', (req, res) ->
|
||||
request
|
||||
url: "#{config.picoCTF_APIURL}/submit"
|
||||
request.post
|
||||
url: "#{config.picoCTF_api_url}/problems/submit"
|
||||
jar: false
|
||||
form:
|
||||
pid: req.body.pid
|
||||
key: req.body.flag
|
||||
token: req.cookies.token
|
||||
headers:
|
||||
Cookie: "flask=#{req.cookies.flask}"
|
||||
Cookie: "token=#{req.cookies.token};flask=#{req.cookies.flask}"
|
||||
Authorization: 'Basic ' + authstr
|
||||
, (err, rr, body) ->
|
||||
res.json JSON.parse(body)
|
||||
|
|
Loading…
Reference in a new issue