import { GameEvent } from '../../../../../models/game-event' ; import { MinionsDiedEvent } from '../../../../../models/mainwindow/game-events/minions-died-event' ; import { RealTimeStatsState } from '../real-time-stats' ; import { EventParser } from './_event-parser' ; export class RTStatsMinionsKilledParser implements EventParser { applies ( gameEvent , currentState ) { return gameEvent . type === GameEvent . MINIONS_DIED ; } parse ( gameEvent , currentState ) { const [ , , localPlayer ] = gameEvent . parse ( ) ; const deadEnemyMinions = gameEvent . additionalData . deadMinions . filter ( ( deadMinion ) => { const isPlayer = deadMinion . ControllerId === localPlayer ?. PlayerId ; return ! isPlayer ; } ) ; if ( ! deadEnemyMinions ?. length ) { return currentState ; } return currentState . update ( { totalEnemyMinionsKilled : currentState . totalEnemyMinionsKilled + deadEnemyMinions . length , } as RealTimeStatsState ) ; } name ( ) { return 'RTStatsMinionsKilledParser' ; } }