|
1 | 1 | const divide = require('../../utils/divide'); |
| 2 | + |
| 3 | +class WarlordsClass { |
| 4 | + /** |
| 5 | + * @param {object} data Warlords data |
| 6 | + * @param {string} className |
| 7 | + */ |
| 8 | + constructor(data, className) { |
| 9 | + /** |
| 10 | + * Wins |
| 11 | + * @type {number} |
| 12 | + */ |
| 13 | + this.wins = data[`wins_${className}`] || 0; |
| 14 | + /** |
| 15 | + * Losses |
| 16 | + * @type {number} |
| 17 | + */ |
| 18 | + this.losses = data[`losses_${className}`] || 0; |
| 19 | + /** |
| 20 | + * WLRatio |
| 21 | + * @type {number} |
| 22 | + */ |
| 23 | + this.WLRatio = divide(this.wins, this.losses); |
| 24 | + /** |
| 25 | + * Games Played |
| 26 | + * @type {number} |
| 27 | + */ |
| 28 | + this.gamesPlayed = data[`${className}_plays`]; |
| 29 | + /** |
| 30 | + * Damage |
| 31 | + * @type {number} |
| 32 | + */ |
| 33 | + this.damage = data[`damage_${className}`] || 0; |
| 34 | + /** |
| 35 | + * Heal |
| 36 | + * @type {number} |
| 37 | + */ |
| 38 | + this.heal = data[`heal_${className}`] || 0; |
| 39 | + /** |
| 40 | + * Damage Prevented |
| 41 | + * @type {number} |
| 42 | + */ |
| 43 | + this.damagePrevented = data[`damage_prevented_${className}`] || 0; |
| 44 | + } |
| 45 | +} |
| 46 | + |
2 | 47 | /** |
3 | 48 | * Warlords class |
4 | 49 | */ |
@@ -56,7 +101,87 @@ class Warlords { |
56 | 101 | * Chosen class |
57 | 102 | * @type {string} |
58 | 103 | */ |
59 | | - this.class = data.chosen_class || 0; |
| 104 | + this.class = data.chosen_class || ''; |
| 105 | + /** |
| 106 | + * pyromancer |
| 107 | + * @type {WarlordsClass} |
| 108 | + */ |
| 109 | + this.pyromancer = new WarlordsClass(data, 'pyromancer'); |
| 110 | + /** |
| 111 | + * mage |
| 112 | + * @type {WarlordsClass} |
| 113 | + */ |
| 114 | + this.mage = new WarlordsClass(data, 'mage'); |
| 115 | + /** |
| 116 | + * thunderlord |
| 117 | + * @type {WarlordsClass} |
| 118 | + */ |
| 119 | + this.thunderlord = new WarlordsClass(data, 'thunderlord'); |
| 120 | + /** |
| 121 | + * shaman |
| 122 | + * @type {WarlordsClass} |
| 123 | + */ |
| 124 | + this.shaman = new WarlordsClass(data, 'shaman'); |
| 125 | + /** |
| 126 | + * earthwarden |
| 127 | + * @type {WarlordsClass} |
| 128 | + */ |
| 129 | + this.earthwarden = new WarlordsClass(data, 'earthwarden'); |
| 130 | + /** |
| 131 | + * aquamancer |
| 132 | + * @type {WarlordsClass} |
| 133 | + */ |
| 134 | + this.aquamancer = new WarlordsClass(data, 'aquamancer'); |
| 135 | + /** |
| 136 | + * paladin |
| 137 | + * @type {WarlordsClass} |
| 138 | + */ |
| 139 | + this.paladin = new WarlordsClass(data, 'paladin'); |
| 140 | + /** |
| 141 | + * avenger |
| 142 | + * @type {WarlordsClass} |
| 143 | + */ |
| 144 | + this.avenger = new WarlordsClass(data, 'avenger'); |
| 145 | + /** |
| 146 | + * warrior |
| 147 | + * @type {WarlordsClass} |
| 148 | + */ |
| 149 | + this.warrior = new WarlordsClass(data, 'warrior'); |
| 150 | + /** |
| 151 | + * defender |
| 152 | + * @type {WarlordsClass} |
| 153 | + */ |
| 154 | + this.defender = new WarlordsClass(data, 'defender'); |
| 155 | + /** |
| 156 | + * cryomancer |
| 157 | + * @type {WarlordsClass} |
| 158 | + */ |
| 159 | + this.cryomancer = new WarlordsClass(data, 'cryomancer'); |
| 160 | + /** |
| 161 | + * crusader |
| 162 | + * @type {WarlordsClass} |
| 163 | + */ |
| 164 | + this.crusader = new WarlordsClass(data, 'crusader'); |
| 165 | + /** |
| 166 | + * berserker |
| 167 | + * @type {WarlordsClass} |
| 168 | + */ |
| 169 | + this.berserker = new WarlordsClass(data, 'berserker'); |
| 170 | + /** |
| 171 | + * protector |
| 172 | + * @type {WarlordsClass} |
| 173 | + */ |
| 174 | + this.protector = new WarlordsClass(data, 'protector'); |
| 175 | + /** |
| 176 | + * revenant |
| 177 | + * @type {WarlordsClass} |
| 178 | + */ |
| 179 | + this.revenant = new WarlordsClass(data, 'revenant'); |
| 180 | + /** |
| 181 | + * spiritguard |
| 182 | + * @type {WarlordsClass} |
| 183 | + */ |
| 184 | + this.spiritguard = new WarlordsClass(data, 'spiritguard'); |
60 | 185 | } |
61 | 186 | } |
62 | 187 | module.exports = Warlords; |
0 commit comments