Play game-dev levels without API restrictions. Show game button in CourseDetailsView only when appropriate.

This commit is contained in:
Nick Winter 2016-07-15 20:47:09 -07:00
parent 7e4733f07e
commit 5f95a4d158
4 changed files with 7 additions and 8 deletions

View file

@ -93,12 +93,13 @@ module.exports = class LevelSession extends CocoModel
state.topScores = newTopScores
@set 'state', state
generateSpellsObject: ->
generateSpellsObject: (options={}) ->
{level} = options
{createAetherOptions} = require 'lib/aether_utils'
aetherOptions = createAetherOptions functionName: 'plan', codeLanguage: @get('codeLanguage')
aetherOptions = createAetherOptions functionName: 'plan', codeLanguage: @get('codeLanguage'), skipProtectAPI: options.level?.isType('game-dev')
spellThang = thang: {id: 'Hero Placeholder'}, aether: new Aether aetherOptions
spells = "hero-placeholder/plan": thang: spellThang, name: 'plan'
source = @get('code')['hero-placeholder'].plan
source = @get('code')?['hero-placeholder']?.plan ? ''
try
spellThang.aether.transpile source
catch e

View file

@ -106,11 +106,11 @@ block content
if previousLevelCompleted || view.teacherMode || !passedLastCompletedLevel || levelStatus
- var i18n = level.isType('course-ladder') ? 'play.compete' : 'home.play';
button.btn.btn-success.btn-play-level(data-level-slug=level.get('slug'), data-i18n=i18n, data-level-id=level.get('original'))
if view.showGameDevButtons
if level.isType('game-dev')
- var levelOriginal = level.get('original');
- var session = view.levelSessions.find(function(session) { return session.get('level').original === levelOriginal });
if session
a.btn.btn-warning(href="/play/game-dev-level/#{level.get('slug')}/#{session.id}") Play Game Dev
a.btn.btn-warning(href="/play/game-dev-level/#{level.get('slug')}/#{session.id}?course=#{view.courseID}") Game
td
if view.userLevelStateMap[me.id]
div= view.userLevelStateMap[me.id][level.get('original')]

View file

@ -33,7 +33,6 @@ module.exports = class CourseDetailsView extends RootView
@classroom = new Classroom()
@levels = new Levels()
@courseInstances = new CourseInstances()
@showGameDevButtons = me.isAdmin() or window.amActually # TEMP while testing game dev level system
@supermodel.trackRequest @ownedClassrooms.fetchMine({data: {project: '_id'}})
@supermodel.trackRequest(@courses.fetch().then(=>

View file

@ -9,7 +9,6 @@ Surface = require 'lib/surface/Surface'
ThangType = require 'models/ThangType'
Level = require 'models/Level'
LevelSession = require 'models/LevelSession'
{createAetherOptions} = require 'lib/aether_utils'
State = require 'models/State'
TEAM = 'humans'
@ -70,7 +69,7 @@ module.exports = class PlayGameDevLevelView extends RootView
@surface.setWorld(@world)
@scriptManager.initializeCamera()
@renderSelectors '#info-col'
@spells = @session.generateSpellsObject()
@spells = @session.generateSpellsObject level: @level
@state.set('loading', false)
.catch ({message}) =>