import { NonFunctionProperties } from '../../../services/utils' ; import { BgsPostMatchStatsForReview } from '../../battlegrounds/bgs-post-match-stats-for-review' ; import { BgsStats } from '../../battlegrounds/stats/bgs-stats' ; import { PatchInfo } from '../../patches' ; import { GameStat } from '../stats/game-stat' ; import { BattlegroundsCategory } from './battlegrounds-category' ; import { BgsCustomSimulationState } from './simulator/bgs-custom-simulation-state' ; export class BattlegroundsAppState { readonly loading : boolean = true ; readonly categories : readonly BattlegroundsCategory [ ] = [ ] ; readonly globalStats : BgsStats = new BgsStats ( ) ; readonly perfectGames : readonly GameStat [ ] ; readonly currentBattlegroundsMetaPatch : PatchInfo ; readonly customSimulationState : BgsCustomSimulationState = new BgsCustomSimulationState ( ) ; readonly lastHeroPostMatchStats : readonly BgsPostMatchStatsForReview [ ] ; readonly lastHeroPostMatchStatsHeroId : string ; public static create ( base ) { return Object . assign ( new BattlegroundsAppState ( ) , base ) ; } public update ( base ) { return Object . assign ( new BattlegroundsAppState ( ) , this , base ) ; } public findCategory ( categoryId ) { const result = this . categories ?. find ( ( cat ) => cat . id === categoryId ) ; if ( result ) { return result ; } return this . categories ?. map ( ( cat ) => cat . categories ) ?. reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ?. find ( ( cat ) => cat . findCategory ( categoryId ) ) ; } public findReplay ( reviewId ) { return [ ... ( this . perfectGames ?? [ ] ) ] . find ( ( replay ) => replay . reviewId === reviewId ) ; } }