Make sure works for multiplayer and future 'course' level hero selection

This commit is contained in:
Nick Winter 2016-01-12 08:41:18 -08:00
parent 345036f68f
commit 01a3ae6020

View file

@ -28,12 +28,12 @@ module.exports = class Level extends CocoModel
# Figure out ThangTypes' Components
tmap = {}
tmap[t.thangType] = true for t in o.thangs ? []
heroSelected = session.get('heroConfig').thangType
sessionHeroes = [session.get('heroConfig')?.thangType, otherSession?.get('heroConfig')?.thangType]
o.thangTypes = []
for tt in supermodel.getModels ThangType
if tmap[tt.get('original')] or
(tt.get('kind') isnt 'Hero' and tt.get('kind')? and tt.get('components') and not tt.notInLevel) or
(tt.get('kind') is 'Hero' and tt.get('original') is heroSelected)
(tt.get('kind') is 'Hero' and ((@get('type', true) in ['course', 'course-ladder']) or tt.get('original') in sessionHeroes))
o.thangTypes.push (original: tt.get('original'), name: tt.get('name'), components: $.extend(true, [], tt.get('components')))
@sortThangComponents o.thangTypes, o.levelComponents, 'ThangType'
@fillInDefaultComponentConfiguration o.thangTypes, o.levelComponents