| 294 | } |
| 295 | |
| 296 | setAILeagueStat (...args) { |
| 297 | // Convenience method for setting nested properties even if intermediate objects haven't been initialized |
| 298 | const adjustedLength = Math.max(args.length, 1); const keys = args.slice(0, adjustedLength - 1); let val = args[adjustedLength - 1] |
| 299 | let object = this.aiLeagueStats |
| 300 | const finalKey = keys.pop() |
| 301 | for (const key of Array.from(keys)) { |
| 302 | if (object[key] == null) { object[key] = {} } |
| 303 | object = object[key] |
| 304 | } |
| 305 | if (['rank', 'playerCount'].includes(finalKey)) { |
| 306 | val = val === 'unknown' ? null : parseInt(val, 10) |
| 307 | } |
| 308 | object[finalKey] = val; |
| 309 | (this.renderStatsDebounced != null ? this.renderStatsDebounced : (this.renderStatsDebounced = _.debounce(this.renderStats, 250)))() |
| 310 | return val |
| 311 | } |
| 312 | |
| 313 | getAILeagueStat (...keys) { |
| 314 | let val = this.aiLeagueStats |