import { GameType } from '@firestone-hs/reference-data' ; import { GameEvent } from '../../../../../../models/game-event' ; import { normalizeHeroCardId } from '../../../../bgs-utils' ; import { RealTimeStatsState } from '../../real-time-stats' ; import { EventParser } from '../_event-parser' ; export class RTStatsBgsTriplesCreatedParser implements EventParser { applies ( gameEvent , currentState ) { return ( [ GameType . GT_BATTLEGROUNDS , GameType . GT_BATTLEGROUNDS_FRIENDLY ] . includes ( currentState . gameType ) && gameEvent . type === GameEvent . BATTLEGROUNDS_TRIPLE ) ; } parse ( gameEvent , currentState ) { const normaliedId = normalizeHeroCardId ( gameEvent . cardId ) ; const existingTriples = currentState . triplesPerHero [ normaliedId ] || 0 ; const newTriples = { ... currentState . triplesPerHero , [ normaliedId ] : existingTriples + 1 , } ; return currentState . update ( { triplesPerHero : newTriples , } as RealTimeStatsState ) ; } name ( ) { return 'RTStatsBgsTriplesCreatedParser' ; } }