| 123 | } |
| 124 | |
| 125 | onItemsLoaded () { |
| 126 | let item |
| 127 | if (debugInventory) { console.log('Inside onItemsLoaded') } |
| 128 | for (item of this.items.models) { |
| 129 | item.notInLevel = true |
| 130 | const programmableConfig = __guard__(_.find(item.get('components'), c => c.config != null ? c.config.programmableProperties : undefined), x => x.config) |
| 131 | item.programmableProperties = ((programmableConfig != null ? programmableConfig.programmableProperties : undefined) || []).concat((programmableConfig != null ? programmableConfig.moreProgrammableProperties : undefined) || []) |
| 132 | } |
| 133 | this.itemsProgrammablePropertiesConfigured = true |
| 134 | if (me.isStudent() && !application.getHocCampaign()) { |
| 135 | this.equipment = __guard__(me.get('heroConfig'), x1 => x1.inventory) || {} |
| 136 | } else { |
| 137 | this.equipment = this.options.equipment || __guard__(this.options.session != null ? this.options.session.get('heroConfig') : undefined, x2 => x2.inventory) || __guard__(me.get('heroConfig'), x3 => x3.inventory) || {} |
| 138 | } |
| 139 | this.equipment = $.extend(true, {}, this.equipment) |
| 140 | if (debugInventory) { console.log('requireLevelEquipment called from onItemsLoaded') } |
| 141 | this.requireLevelEquipment() |
| 142 | this.itemGroups = {} |
| 143 | this.itemGroups.requiredPurchaseItems = new Backbone.Collection() |
| 144 | this.itemGroups.availableItems = new Backbone.Collection() |
| 145 | this.itemGroups.restrictedItems = new Backbone.Collection() |
| 146 | this.itemGroups.lockedItems = new Backbone.Collection() |
| 147 | this.itemGroups.subscriberItems = new Backbone.Collection() |
| 148 | for (const itemGroup of _.values(this.itemGroups)) { |
| 149 | itemGroup.comparator = function (m) { |
| 150 | let left |
| 151 | return (left = m.get('tier')) != null ? left : m.get('gems') |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | const equipped = _.values(this.equipment) |
| 156 | return (() => { |
| 157 | const result = [] |
| 158 | for (item of this.items.models) { |
| 159 | result.push(this.sortItem(item, equipped)) |
| 160 | } |
| 161 | return result |
| 162 | })() |
| 163 | } |
| 164 | |
| 165 | sortItem (item, equipped) { |
| 166 | let needle, needle1 |