Don't use course hero in verifier / level editor for type: 'course' level

This commit is contained in:
Nick Winter 2016-07-13 10:04:43 -07:00
parent 0b1e1ddcb4
commit 872e83e9b7
8 changed files with 12 additions and 10 deletions

View file

@ -478,7 +478,7 @@ module.exports = class LevelLoader extends CocoClass
@world.difficulty = @session?.get('state')?.difficulty ? 0
if @observing
@world.difficulty = Math.max 0, @world.difficulty - 1 # Show the difficulty they won, not the next one.
serializedLevel = @level.serialize(@supermodel, @session, @opponentSession)
serializedLevel = @level.serialize {@supermodel, @session, @opponentSession, @headless, @sessionless}
@world.loadFromLevel serializedLevel, false
console.log 'World has been initialized from level loader.' if LOG

View file

@ -226,7 +226,7 @@ module.exports = class Simulator extends CocoClass
@levelLoader = null
setupGod: ->
@god.setLevel @level.serialize(@supermodel, @session, @otherSession)
@god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: true, sessionless: false}
@god.setLevelSessionIDs (session.sessionID for session in @task.getSessions())
@god.setWorldClassMap @world.classMap
@god.setGoalManager new GoalManager @world, @level.get('goals'), null, {headless: true}

View file

@ -12,7 +12,8 @@ module.exports = class Level extends CocoModel
urlRoot: '/db/level'
editableByArtisans: true
serialize: (supermodel, session, otherSession, cached=false) ->
serialize: (options) ->
{supermodel, session, otherSession, @headless, @sessionless, cached=false} = options
o = @denormalize supermodel, session, otherSession # hot spot to optimize
# Figure out Components
@ -146,7 +147,7 @@ module.exports = class Level extends CocoModel
levelThang.components.push placeholderComponent
# Load the user's chosen hero AFTER getting stats from default char
if /Hero Placeholder/.test(levelThang.id) and @get('type', true) in ['course']
if /Hero Placeholder/.test(levelThang.id) and @get('type', true) in ['course'] and not @headless and not @sessionless
heroThangType = me.get('heroConfig')?.thangType or ThangType.heroes.captain
levelThang.thangType = heroThangType if heroThangType

View file

@ -595,7 +595,7 @@ module.exports = class ThangsTabView extends CocoView
@level.set 'thangs', thangs
return if @editThangView
return if skipSerialization
serializedLevel = @level.serialize @supermodel, null, null, true
serializedLevel = @level.serialize {@supermodel, session: null, otherSession: null, headless: false, sessionless: true, cached: true}
try
@world.loadFromLevel serializedLevel, false
catch error

View file

@ -62,7 +62,7 @@ module.exports = class VerifierTest extends CocoClass
@solution = @levelLoader.session.solution
setupGod: ->
@god.setLevel @level.serialize @supermodel, @session
@god.setLevel @level.serialize {@supermodel, @session, otherSession: null, headless: true, sessionless: false}
@god.setLevelSessionIDs [@session.id]
@god.setWorldClassMap @world.classMap
@god.lastFlagHistory = @session.get('state').flagHistory

View file

@ -42,6 +42,7 @@ module.exports = class LadderView extends RootView
initialize: (options, @levelID, @leagueType, @leagueID) ->
@level = @supermodel.loadModel(new Level(_id: @levelID)).model
@level.once 'sync', =>
return if @destroyed
@levelDescription = marked(@level.get('description')) if @level.get('description')
@teams = teamDataFromLevel @level
@sessions = @supermodel.loadCollection(new LevelSessionsCollection(@levelID), 'your_sessions', {cache: false}).model

View file

@ -69,7 +69,7 @@ module.exports = class SpectateLevelView extends RootView
@load()
setLevel: (@level, @supermodel) ->
serializedLevel = @level.serialize @supermodel, @session, @otherSession
serializedLevel = @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false}
@god?.setLevel serializedLevel
if @world
@world.loadFromLevel serializedLevel, false
@ -106,7 +106,7 @@ module.exports = class SpectateLevelView extends RootView
#at this point, all requisite data is loaded, and sessions are not denormalized
team = @world.teamForPlayer(0)
@loadOpponentTeam(team)
@god.setLevel @level.serialize @supermodel, @session, @otherSession
@god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false}
@god.setLevelSessionIDs if @otherSession then [@session.id, @otherSession.id] else [@session.id]
@god.setWorldClassMap @world.classMap
@setTeam team

View file

@ -128,7 +128,7 @@ module.exports = class PlayLevelView extends RootView
@supermodel.collections = givenSupermodel.collections
@supermodel.shouldSaveBackups = givenSupermodel.shouldSaveBackups
serializedLevel = @level.serialize @supermodel, @session, @otherSession
serializedLevel = @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false}
@god?.setLevel serializedLevel
if @world
@world.loadFromLevel serializedLevel, false
@ -244,7 +244,7 @@ module.exports = class PlayLevelView extends RootView
@session.set 'multiplayer', false
setupGod: ->
@god.setLevel @level.serialize @supermodel, @session, @otherSession
@god.setLevel @level.serialize {@supermodel, @session, @otherSession, headless: false, sessionless: false}
@god.setLevelSessionIDs if @otherSession then [@session.id, @otherSession.id] else [@session.id]
@god.setWorldClassMap @world.classMap