Merge branch 'game-dev-levels'

This commit is contained in:
Scott Erickson 2016-07-12 11:00:29 -07:00
commit 0b1e1ddcb4
8 changed files with 5 additions and 93 deletions

View file

@ -54,7 +54,7 @@ _.extend LevelSessionSchema.properties,
changed: c.date changed: c.date
title: 'Changed' title: 'Changed'
readOnly: true readOnly: true
dateFirstCompleted: {} # c.stringDate dateFirstCompleted: {} # c.stringDate
# title: 'Completed' # title: 'Completed'
# readOnly: true # readOnly: true
@ -62,9 +62,6 @@ _.extend LevelSessionSchema.properties,
team: c.shortString() team: c.shortString()
level: LevelSessionLevelSchema level: LevelSessionLevelSchema
screenshot:
type: 'string'
heroConfig: c.HeroConfigSchema heroConfig: c.HeroConfigSchema
state: c.object {}, state: c.object {},
@ -208,14 +205,6 @@ _.extend LevelSessionSchema.properties,
submittedCodeLanguage: submittedCodeLanguage:
type: 'string' type: 'string'
transpiledCode:
type: 'object'
additionalProperties:
type: 'object'
additionalProperties:
type: 'string'
format: 'code'
isRanking: isRanking:
type: 'boolean' type: 'boolean'
description: 'Whether this session is still in the first ranking chain after being submitted.' description: 'Whether this session is still in the first ranking chain after being submitted.'

View file

@ -1,14 +0,0 @@
#admin-level-sessions-view
.session_tile
display: inline-block
position: relative
margin: 8px
.session_info
position: absolute
top: 0
left: 0
right: 0
text-align: center
background: rgba(0, 0, 0, 0.5)
color: white

View file

@ -30,8 +30,6 @@ block content
h4 Entities h4 Entities
ul ul
li
a(href="/admin/level-sessions") Active Instances
li li
a(href="/admin/trial-requests") Trial Requests a(href="/admin/trial-requests") Trial Requests
li li

View file

@ -1,17 +0,0 @@
extends /templates/base
block content
h1 Latest Games
each session in view.sessions.models
- var url = '/play/level/'+session.get('levelID')+'?session='+session.id
.session_tile
a(href=url)
if session.get('screenshot')
img(src=session.get('screenshot'))
else
img(src="/images/generic-icon.png")
.session_info
.level_name= session.get('levelName')
.creator_name= session.get('creatorName')

View file

@ -1,19 +0,0 @@
RootView = require 'views/core/RootView'
template = require 'templates/admin/level_sessions'
LevelSession = require 'models/LevelSession'
CocoCollection = require 'collections/CocoCollection'
class LevelSessionCollection extends CocoCollection
url: '/db/level.session/x/active?project=screenshot,levelName,creatorName'
model: LevelSession
module.exports = class LevelSessionsView extends RootView
id: 'admin-level-sessions-view'
template: template
constructor: (options) ->
super options
@getLevelSessions()
getLevelSessions: ->
@sessions = @supermodel.loadCollection(new LevelSessionCollection(), 'sessions', {cache: false}).model

View file

@ -69,7 +69,6 @@ module.exports = class PlayLevelView extends RootView
'god:infinite-loop': 'onInfiniteLoop' 'god:infinite-loop': 'onInfiniteLoop'
'level:reload-from-data': 'onLevelReloadFromData' 'level:reload-from-data': 'onLevelReloadFromData'
'level:reload-thang-type': 'onLevelReloadThangType' 'level:reload-thang-type': 'onLevelReloadThangType'
'level:session-will-save': 'onSessionWillSave'
'level:started': 'onLevelStarted' 'level:started': 'onLevelStarted'
'level:loading-view-unveiling': 'onLoadingViewUnveiling' 'level:loading-view-unveiling': 'onLoadingViewUnveiling'
'level:loading-view-unveiled': 'onLoadingViewUnveiled' 'level:loading-view-unveiled': 'onLoadingViewUnveiled'
@ -112,7 +111,6 @@ module.exports = class PlayLevelView extends RootView
@gameUIState = new GameUIState() @gameUIState = new GameUIState()
$(window).on 'resize', @onWindowResize $(window).on 'resize', @onWindowResize
@saveScreenshot = _.throttle @saveScreenshot, 30000
application.tracker?.enableInspectletJS(@levelID) application.tracker?.enableInspectletJS(@levelID)
@ -594,15 +592,6 @@ module.exports = class PlayLevelView extends RootView
@bus.removeFirebaseData => @bus.removeFirebaseData =>
@bus.disconnect() @bus.disconnect()
onSessionWillSave: (e) ->
# Something interesting has happened, so (at a lower frequency), we'll save a screenshot.
#@saveScreenshot e.session
# Throttled
saveScreenshot: (session) =>
return unless screenshot = @surface?.screenshot()
session.save {screenshot: screenshot}, {patch: true, type: 'PUT'}
onContactClicked: (e) -> onContactClicked: (e) ->
Backbone.Mediator.publish 'level:contact-button-pressed', {} Backbone.Mediator.publish 'level:contact-button-pressed', {}
@openModalView contactModal = new ContactModal levelID: @level.get('slug') or @level.id, courseID: @courseID, courseInstanceID: @courseInstanceID @openModalView contactModal = new ContactModal levelID: @level.get('slug') or @level.id, courseID: @courseID, courseInstanceID: @courseInstanceID
@ -954,20 +943,6 @@ module.exports = class PlayLevelView extends RootView
console.error 'Failed to read sessionState in onRealTimeMultiplayerCast' console.error 'Failed to read sessionState in onRealTimeMultiplayerCast'
console.info 'Submitting my code' console.info 'Submitting my code'
# Transpiling code copied from scripts/transpile.coffee
# TODO: Should this live somewhere else?
transpiledCode = {}
for thang, spells of @session.get('code')
transpiledCode[thang] = {}
for spellID, spell of spells
spellName = thang + '/' + spellID
continue if @session.get('teamSpells') and not (spellName in @session.get('teamSpells')[@session.get('team')])
# console.log "PlayLevelView Transpiling spell #{spellName}"
aetherOptions = createAetherOptions functionName: spellID, codeLanguage: @session.get('submittedCodeLanguage'), includeFlow: true
aether = new Aether aetherOptions
transpiledCode[thang][spellID] = aether.transpile spell
# console.log "PlayLevelView transpiled code", transpiledCode
@session.set 'transpiledCode', transpiledCode
permissions = @session.get 'permissions' ? [] permissions = @session.get 'permissions' ? []
unless _.find(permissions, (p) -> p.target is 'public' and p.access is 'read') unless _.find(permissions, (p) -> p.target is 'public' and p.access is 'read')
permissions.push target:'public', access:'read' permissions.push target:'public', access:'read'

View file

@ -195,7 +195,7 @@ LevelHandler = class LevelHandler extends Handler
majorVersion: level.version.major majorVersion: level.version.major
creator: req.user._id+'' creator: req.user._id+''
query = Session.find(sessionQuery).select('-screenshot -transpiledCode') query = Session.find(sessionQuery)
# TODO: take out "code" as well, since that can get huge containing the transpiled code for the lat hero, and find another way of having the LadderSubmissionViews in the MyMatchesTab determine ranking readiness # TODO: take out "code" as well, since that can get huge containing the transpiled code for the lat hero, and find another way of having the LadderSubmissionViews in the MyMatchesTab determine ranking readiness
query.exec (err, results) => query.exec (err, results) =>
if err then @sendDatabaseError(res, err) else @sendSuccess res, results if err then @sendDatabaseError(res, err) else @sendSuccess res, results

View file

@ -84,9 +84,9 @@ LevelSessionSchema.pre 'save', (next) ->
LevelSessionSchema.statics.privateProperties = ['code', 'submittedCode', 'unsubscribed'] LevelSessionSchema.statics.privateProperties = ['code', 'submittedCode', 'unsubscribed']
LevelSessionSchema.statics.editableProperties = ['multiplayer', 'players', 'code', 'codeLanguage', 'completed', 'state', LevelSessionSchema.statics.editableProperties = ['multiplayer', 'players', 'code', 'codeLanguage', 'completed', 'state',
'levelName', 'creatorName', 'levelID', 'screenshot', 'levelName', 'creatorName', 'levelID',
'chat', 'teamSpells', 'submitted', 'submittedCodeLanguage', 'chat', 'teamSpells', 'submitted', 'submittedCodeLanguage',
'unsubscribed', 'playtime', 'heroConfig', 'team', 'transpiledCode', 'unsubscribed', 'playtime', 'heroConfig', 'team',
'browser'] 'browser']
LevelSessionSchema.statics.jsonSchema = jsonschema LevelSessionSchema.statics.jsonSchema = jsonschema
@ -94,7 +94,7 @@ LevelSessionSchema.set('toObject', {
transform: (doc, ret, options) -> transform: (doc, ret, options) ->
req = options.req req = options.req
return ret unless req # TODO: Make deleting properties the default, but the consequences are far reaching return ret unless req # TODO: Make deleting properties the default, but the consequences are far reaching
submittedCode = doc.get('submittedCode') submittedCode = doc.get('submittedCode')
unless req.user?.isAdmin() or req.user?.id is doc.get('creator') or ('employer' in (req.user?.get('permissions') ? [])) or not doc.get('submittedCode') # TODO: only allow leaderboard access to non-top-5 solutions unless req.user?.isAdmin() or req.user?.id is doc.get('creator') or ('employer' in (req.user?.get('permissions') ? [])) or not doc.get('submittedCode') # TODO: only allow leaderboard access to non-top-5 solutions
ret = _.omit ret, LevelSession.privateProperties ret = _.omit ret, LevelSession.privateProperties