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 MindrenderIlluciaParser implements EventParser { applies ( gameEvent , state ) { return false ; return ( state && ( gameEvent . type === GameEvent . MINDRENDER_ILLUCIA_START || gameEvent . type === GameEvent . MINDRENDER_ILLUCIA_END ) ) ; } async parse ( currentState , gameEvent ) { console . debug ( 'handling mindrender illucia' , gameEvent , currentState ) ; const newPlayerDeck = this . swapDecks ( currentState . playerDeck , currentState . opponentDeck ) ; const newOpponentDeck = this . swapDecks ( currentState . opponentDeck , currentState . playerDeck ) ; return currentState . update ( { playerDeck : newPlayerDeck , opponentDeck : newOpponentDeck , } as GameState ) ; } private swapDecks ( firstDeck , secondDeck ) { return firstDeck . update ( { cardsLeftInDeck : secondDeck . cardsLeftInDeck , cardsPlayedFromInitialDeck : secondDeck . cardsPlayedFromInitialDeck , deck : secondDeck . deck , deckList : secondDeck . deckList , dynamicZones : secondDeck . dynamicZones , hand : secondDeck . hand , unknownRealCardsInDeck : secondDeck . unknownRealCardsInDeck , deckstring : secondDeck . deckstring , } as DeckState ) ; } event ( ) { return 'MINDRENDER_ILLUCIA_START' ; } }