mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Play game-dev levels without API restrictions. Show game button in CourseDetailsView only when appropriate.
This commit is contained in:
parent
7e4733f07e
commit
5f95a4d158
4 changed files with 7 additions and 8 deletions
|
@ -93,12 +93,13 @@ module.exports = class LevelSession extends CocoModel
|
||||||
state.topScores = newTopScores
|
state.topScores = newTopScores
|
||||||
@set 'state', state
|
@set 'state', state
|
||||||
|
|
||||||
generateSpellsObject: ->
|
generateSpellsObject: (options={}) ->
|
||||||
|
{level} = options
|
||||||
{createAetherOptions} = require 'lib/aether_utils'
|
{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
|
spellThang = thang: {id: 'Hero Placeholder'}, aether: new Aether aetherOptions
|
||||||
spells = "hero-placeholder/plan": thang: spellThang, name: 'plan'
|
spells = "hero-placeholder/plan": thang: spellThang, name: 'plan'
|
||||||
source = @get('code')['hero-placeholder'].plan
|
source = @get('code')?['hero-placeholder']?.plan ? ''
|
||||||
try
|
try
|
||||||
spellThang.aether.transpile source
|
spellThang.aether.transpile source
|
||||||
catch e
|
catch e
|
||||||
|
|
|
@ -106,11 +106,11 @@ block content
|
||||||
if previousLevelCompleted || view.teacherMode || !passedLastCompletedLevel || levelStatus
|
if previousLevelCompleted || view.teacherMode || !passedLastCompletedLevel || levelStatus
|
||||||
- var i18n = level.isType('course-ladder') ? 'play.compete' : 'home.play';
|
- 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'))
|
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 levelOriginal = level.get('original');
|
||||||
- var session = view.levelSessions.find(function(session) { return session.get('level').original === levelOriginal });
|
- var session = view.levelSessions.find(function(session) { return session.get('level').original === levelOriginal });
|
||||||
if session
|
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
|
td
|
||||||
if view.userLevelStateMap[me.id]
|
if view.userLevelStateMap[me.id]
|
||||||
div= view.userLevelStateMap[me.id][level.get('original')]
|
div= view.userLevelStateMap[me.id][level.get('original')]
|
||||||
|
|
|
@ -33,7 +33,6 @@ module.exports = class CourseDetailsView extends RootView
|
||||||
@classroom = new Classroom()
|
@classroom = new Classroom()
|
||||||
@levels = new Levels()
|
@levels = new Levels()
|
||||||
@courseInstances = new CourseInstances()
|
@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 @ownedClassrooms.fetchMine({data: {project: '_id'}})
|
||||||
@supermodel.trackRequest(@courses.fetch().then(=>
|
@supermodel.trackRequest(@courses.fetch().then(=>
|
||||||
|
|
|
@ -9,7 +9,6 @@ Surface = require 'lib/surface/Surface'
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
Level = require 'models/Level'
|
Level = require 'models/Level'
|
||||||
LevelSession = require 'models/LevelSession'
|
LevelSession = require 'models/LevelSession'
|
||||||
{createAetherOptions} = require 'lib/aether_utils'
|
|
||||||
State = require 'models/State'
|
State = require 'models/State'
|
||||||
|
|
||||||
TEAM = 'humans'
|
TEAM = 'humans'
|
||||||
|
@ -70,7 +69,7 @@ module.exports = class PlayGameDevLevelView extends RootView
|
||||||
@surface.setWorld(@world)
|
@surface.setWorld(@world)
|
||||||
@scriptManager.initializeCamera()
|
@scriptManager.initializeCamera()
|
||||||
@renderSelectors '#info-col'
|
@renderSelectors '#info-col'
|
||||||
@spells = @session.generateSpellsObject()
|
@spells = @session.generateSpellsObject level: @level
|
||||||
@state.set('loading', false)
|
@state.set('loading', false)
|
||||||
|
|
||||||
.catch ({message}) =>
|
.catch ({message}) =>
|
||||||
|
|
Loading…
Reference in a new issue