import { DeckState } from '../../../models/decktracker/deck-state' ; import { GameState } from '../../../models/decktracker/game-state' ; import { GameEvent } from '../../../models/game-event' ; import { EventParser } from './event-parser' ; export class JadeGolemParser implements EventParser { applies ( gameEvent , state ) { return state && gameEvent . type === GameEvent . JADE_GOLEM ; } async parse ( currentState , gameEvent ) { const [ , controllerId , localPlayer ] = gameEvent . parse ( ) ; const isPlayer = controllerId === localPlayer . PlayerId ; const deck = isPlayer ? currentState . playerDeck : currentState . opponentDeck ; const newPlayerDeck = Object . assign ( new DeckState ( ) , deck , { jadeGolemSize : gameEvent . additionalData . golemSize , } as DeckState ) ; return Object . assign ( new GameState ( ) , currentState , { [ isPlayer ? 'playerDeck' : 'opponentDeck' ] : newPlayerDeck , } ) ; } event ( ) { return GameEvent . JADE_GOLEM ; } }