import { SceneMode } from '@firestone-hs/reference-data' ; import { MemoryUpdate } from '../../../../models/memory/memory-update' ; import { MercenariesOutOfCombatState } from '../../../../models/mercenaries/out-of-combat/mercenaries-out-of-combat-state' ; import { CardsFacadeService } from '../../../cards-facade.service' ; import { BroadcastEvent , Events } from '../../../events.service' ; import { MercenariesOutOfCombatParser } from './_mercenaries-out-of-combat-parser' ; export class MercenariesTreasureSelectionParser implements MercenariesOutOfCombatParser { constructor ( private readonly allCards ) { } public eventType = ( ) => Events . MEMORY_UPDATE ; public applies = ( state ) => ! ! state ; async parse ( state , event , currentScene ) { const changes = event . data [ 0 ] ; if ( changes . IsMercenariesSelectingTreasure && changes . MercenariesPendingTreasureSelection ) { const result = state . update ( { treasureSelection : { treasures : changes . MercenariesPendingTreasureSelection . Options . map ( ( option ) => this . allCards . getCardFromDbfId ( option ) ) , } , } ) ; return result ; } else if ( changes . IsMercenariesSelectingTreasure == null ) { return state ; } else if ( changes . IsMercenariesSelectingTreasure == false ) { return state . update ( { treasureSelection : null } ) ; } console . warn ( 'invalid case' , changes ) ; return state ; } }