import { NumericTurnInfo } from '@firestone-hs/hs-replay-xml-parser/dist/lib/model/numeric-turn-info' ; import { GameEvent } from '../../../../../models/game-event' ; import { RealTimeStatsState } from '../real-time-stats' ; import { EventParser } from './_event-parser' ; export class RTStatHeroPowerUsedParser implements EventParser { applies ( gameEvent , currentState ) { return gameEvent . type === GameEvent . HERO_POWER_USED ; } parse ( gameEvent , currentState ) { const [ , controllerId , localPlayer ] = gameEvent . parse ( ) ; const isPlayer = controllerId === localPlayer . PlayerId ; if ( ! isPlayer ) { return currentState ; } const existingUse = currentState . mainPlayerHeroPowersOverTurn . find ( ( info ) => info . turn === currentState . currentTurn ) ?. value ?? 0 ; const newPowers = [ ... currentState . mainPlayerHeroPowersOverTurn . filter ( ( info ) => info . turn !== currentState . currentTurn ) , { turn : currentState . currentTurn , value : existingUse + 1 , } , ] ; return currentState . update ( { mainPlayerHeroPowersOverTurn : newPowers , } as RealTimeStatsState ) ; } name ( ) { return 'RTStatHeroPowerUsedParser' ; } }