| 815 | } |
| 816 | |
| 817 | onLoaded () { |
| 818 | super.onLoaded() |
| 819 | if (ThangType.heroConfigStats[this.get('original')]) { return } |
| 820 | // Cache certain component properties for quickly determining hero/item loadout aggregate stats |
| 821 | const components = this.get('components') || [] |
| 822 | if (!components.length) { return } |
| 823 | if ((this.get('gems') == null) && ( |
| 824 | (this.project && !/gems/.test(this.project)) || |
| 825 | (/project/.test(this.getURL()) && !/gems/.test(this.getURL())) || |
| 826 | ((this.collection != null ? this.collection.project : undefined) && !/gems/.test(this.collection != null ? this.collection.project : undefined)) || |
| 827 | (/project/.test(this.collection != null ? this.collection.getURL() : undefined) && !/gems/.test(this.collection != null ? this.collection.getURL() : undefined)) |
| 828 | )) { return } |
| 829 | const stats = { gems: this.get('gems') || 0 } |
| 830 | const itemConfig = __guard__(_.find(components, { original: LevelComponent.ItemID }), x => x.config) |
| 831 | const equipsConfig = __guard__(_.find(components, { original: LevelComponent.EquipsID }), x4 => x4.config) |
| 832 | if (itemConfig) { |
| 833 | stats.kind = 'item' |
| 834 | const speed = __guard__(itemConfig.stats != null ? itemConfig.stats.maxSpeed : undefined, x1 => x1.addend) |
| 835 | const health = __guard__(itemConfig.stats != null ? itemConfig.stats.maxHealth : undefined, x2 => x2.addend) |
| 836 | const attacksConfig = __guard__(_.find(components, { original: LevelComponent.AttacksID }), x3 => x3.config) |
| 837 | if (speed) { stats.speed = speed } |
| 838 | if (health) { stats.health = health } |
| 839 | if (attacksConfig) { |
| 840 | stats.attack = (attacksConfig.attackDamage != null ? attacksConfig.attackDamage : 3) / (attacksConfig.cooldown != null ? attacksConfig.cooldown : 1) |
| 841 | } |
| 842 | ThangType.heroConfigStats[this.get('original')] = stats |
| 843 | } else if (equipsConfig) { |
| 844 | stats.kind = 'hero' |
| 845 | stats.attackMultiplier = equipsConfig.attackDamageFactor != null ? equipsConfig.attackDamageFactor : 1 |
| 846 | stats.healthMultiplier = equipsConfig.maxHealthFactor != null ? equipsConfig.maxHealthFactor : 1 |
| 847 | const movesConfig = __guard__(_.find(components, { original: LevelComponent.MovesID }), x5 => x5.config) |
| 848 | const attackableConfig = __guard__(_.find(components, { original: LevelComponent.AttackableID }), x6 => x6.config) |
| 849 | if (movesConfig) { |
| 850 | stats.speed = movesConfig.maxSpeed != null ? movesConfig.maxSpeed : 3.6 |
| 851 | } |
| 852 | if (attackableConfig) { |
| 853 | stats.baseHealth = attackableConfig.maxHealth != null ? attackableConfig.maxHealth : 11 |
| 854 | } |
| 855 | ThangType.heroConfigStats[this.get('original')] = stats |
| 856 | } |
| 857 | return null |
| 858 | } |
| 859 | |
| 860 | static calculateStatsForHeroConfig (heroConfig, callback) { |
| 861 | // Load enough information from the ThangTypes involved in a hero configuration to show various stats the hero will have. |