From ed17d967d27c09d15aa34cb696d8c509256b1b36 Mon Sep 17 00:00:00 2001 From: Daniel Fiore <taptapdan@gmail.com> Date: Thu, 7 Jan 2016 12:26:40 -0800 Subject: [PATCH] Fix thangTypes filtering in serialize --- app/models/Level.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/Level.coffee b/app/models/Level.coffee index df0a1efbf..5d39a3cfd 100644 --- a/app/models/Level.coffee +++ b/app/models/Level.coffee @@ -28,7 +28,13 @@ module.exports = class Level extends CocoModel # Figure out ThangTypes' Components tmap = {} tmap[t.thangType] = true for t in o.thangs ? [] - o.thangTypes = (original: tt.get('original'), name: tt.get('name'), components: $.extend(true, [], tt.get('components')) for tt in supermodel.getModels ThangType when tmap[tt.get('original')] or (tt.get('components') and not tt.notInLevel)) + heroSelected = session.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) + 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