| 601 | } |
| 602 | |
| 603 | formatStatDisplay (name, modifiers) { |
| 604 | let matchedShortName |
| 605 | const i18nKey = { |
| 606 | maxHealth: 'health', |
| 607 | maxSpeed: 'speed', |
| 608 | healthReplenishRate: 'regeneration', |
| 609 | attackDamage: 'attack', |
| 610 | attackRange: 'range', |
| 611 | shieldDefenseFactor: 'blocks', |
| 612 | visualRange: 'range', |
| 613 | throwDamage: 'attack', |
| 614 | throwRange: 'range', |
| 615 | bashDamage: 'attack', |
| 616 | backstabDamage: 'backstab', |
| 617 | }[name] |
| 618 | |
| 619 | if (i18nKey) { |
| 620 | name = $.i18n.t('choose_hero.' + i18nKey) |
| 621 | matchedShortName = true |
| 622 | } else { |
| 623 | name = _.string.humanize(name) |
| 624 | matchedShortName = false |
| 625 | } |
| 626 | |
| 627 | let format = '' |
| 628 | if (/(range|radius|distance|vision)$/i.test(name)) { format = 'm' } |
| 629 | if (/cooldown$/i.test(name)) { if (!format) { format = 's' } } |
| 630 | if (/speed$/i.test(name)) { if (!format) { format = 'm/s' } } |
| 631 | if (/(regeneration| rate)$/i.test(name)) { if (!format) { format = '/s' } } |
| 632 | let value = modifiers.setTo |
| 633 | if (/(blocks)$/i.test(name)) { |
| 634 | if (!format) { format = '%' } |
| 635 | value = (value * 100).toFixed(1) |
| 636 | } |
| 637 | if (_.isArray(value)) { value = value.join(', ') } |
| 638 | let display = [] |
| 639 | if (value != null) { display.push(`${value}${format}`) } |
| 640 | if (modifiers.addend > 0) { display.push(`+${modifiers.addend}${format}`) } |
| 641 | if (modifiers.addend < 0) { display.push(`${modifiers.addend}${format}`) } |
| 642 | if ((modifiers.factor != null) && (modifiers.factor !== 1)) { display.push(`x${modifiers.factor}`) } |
| 643 | display = display.join(', ') |
| 644 | display = display.replace(/9001m?/, 'Infinity') |
| 645 | return { name, display, matchedShortName } |
| 646 | } |
| 647 | |
| 648 | isSilhouettedItem () { |
| 649 | if ((this.get('gems') == null) && (this.get('tier') == null)) { return console.error(`Trying to determine whether ${this.get('name')} should be a silhouetted item, but it has no gem cost.`) } |