()
| 549 | } |
| 550 | |
| 551 | getFrontFacingStats () { |
| 552 | let itemConfig, stat, value |
| 553 | const components = this.get('components') || [] |
| 554 | if (!(itemConfig = __guard__(_.find(components, { original: LevelComponent.ItemID }), x => x.config))) { |
| 555 | console.warn(this.get('name'), 'is not an item, but you are asking for its stats.') |
| 556 | return { props: [], stats: {} } |
| 557 | } |
| 558 | const stats = {} |
| 559 | let props = itemConfig.programmableProperties != null ? itemConfig.programmableProperties : [] |
| 560 | props = props.concat(itemConfig.moreProgrammableProperties != null ? itemConfig.moreProgrammableProperties : []) |
| 561 | props = _.without(props, 'canCast', 'spellNames', 'spells') |
| 562 | const object = itemConfig.stats != null ? itemConfig.stats : {} |
| 563 | for (stat in object) { |
| 564 | const modifiers = object[stat] |
| 565 | stats[stat] = this.formatStatDisplay(stat, modifiers) |
| 566 | } |
| 567 | for (stat of Array.from(itemConfig.extraHUDProperties != null ? itemConfig.extraHUDProperties : [])) { |
| 568 | if (stats[stat] == null) { stats[stat] = null } |
| 569 | } // Find it in the other Components. |
| 570 | for (const component of Array.from(components)) { |
| 571 | const config = component.config |
| 572 | if (!config) { continue } |
| 573 | for (stat in stats) { |
| 574 | value = stats[stat] |
| 575 | if ((value == null)) { |
| 576 | value = config[stat] |
| 577 | if (value == null) { continue } |
| 578 | stats[stat] = this.formatStatDisplay(stat, { setTo: value }) |
| 579 | if (stat === 'attackDamage') { |
| 580 | const dps = (value / (config.cooldown || 0.5)).toFixed(1) |
| 581 | stats[stat].display += ` (${dps} DPS)` |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | if (config.programmableSnippets) { |
| 586 | props = props.concat(config.programmableSnippets) |
| 587 | } |
| 588 | } |
| 589 | for (stat in stats) { |
| 590 | value = stats[stat] |
| 591 | if ((value == null)) { |
| 592 | stats[stat] = { name: stat, display: '???' } |
| 593 | } |
| 594 | } |
| 595 | const statKeys = _.keys(stats) |
| 596 | statKeys.sort() |
| 597 | props.sort() |
| 598 | const sortedStats = {} |
| 599 | for (const key of Array.from(statKeys)) { sortedStats[key] = stats[key] } |
| 600 | return { props, stats: sortedStats } |
| 601 | } |
| 602 | |
| 603 | formatStatDisplay (name, modifiers) { |
| 604 | let matchedShortName |
no test coverage detected