import { BattlegroundsState } from '../../../../models/battlegrounds/battlegrounds-state' ; import { BgsGame } from '../../../../models/battlegrounds/bgs-game' ; import { MemoryInspectionService } from '../../../plugins/memory-inspection.service' ; import { BgsInitMmrEvent } from '../events/bgs-init-mmr-event' ; import { BattlegroundsStoreEvent } from '../events/_battlegrounds-store-event' ; import { EventParser } from './_event-parser' ; export class BgsInitMmrParser implements EventParser { constructor ( private readonly memoryService ) { } public applies ( gameEvent , state ) { return state && state . currentGame && gameEvent . type === 'BgsInitMmrEvent' ; } public async parse ( currentState , event ) { const bgsInfo = await this . memoryService . getBattlegroundsInfo ( ) ; const mmr = bgsInfo ?. rating ; console . log ( '[bgs-mmr] mmrAtStart' , mmr ) ; return currentState . update ( { currentGame : currentState . currentGame . update ( { mmrAtStart : mmr , } as BgsGame ) , } as BattlegroundsState ) ; } }