import { CardsFacadeService } from '@services/cards-facade.service' ; import { DeckCard } from '../../../models/decktracker/deck-card' ; import { DeckState } from '../../../models/decktracker/deck-state' ; import { GameState } from '../../../models/decktracker/game-state' ; import { GameEvent } from '../../../models/game-event' ; import { globalEffectTriggersEffects } from '../../hs-utils' ; import { LocalizationFacadeService } from '../../localization-facade.service' ; import { DeckManipulationHelper } from './deck-manipulation-helper' ; import { EventParser } from './event-parser' ; export class GlobalMinionEffectParser implements EventParser { constructor ( private readonly helper , private readonly allCards , private readonly i18n ) { } applies ( gameEvent , state ) { return ( gameEvent . type === GameEvent . SUB_SPELL_START && globalEffectTriggersEffects . includes ( gameEvent . additionalData ?. prefabId ) ) ; } async parse ( currentState , gameEvent ) { const [ cardId , controllerId , localPlayer ] = gameEvent . parse ( ) ; const isPlayer = controllerId === localPlayer . PlayerId ; const deck = isPlayer ? currentState . playerDeck : currentState . opponentDeck ; const refCard = this . allCards . getCard ( cardId ) ; const card = DeckCard . create ( { entityId : null , cardId : cardId , cardName : this . i18n . getCardName ( cardId , refCard . name ) , manaCost : refCard ?. cost , rarity : refCard ?. rarity ?. toLowerCase ( ) , zone : null , } as DeckCard ) ; const newGlobalEffects = this . helper . addSingleCardToZone ( deck . globalEffects , card ) ; const newPlayerDeck = deck . update ( { globalEffects : newGlobalEffects , } as DeckState ) ; return currentState . update ( { [ isPlayer ? 'playerDeck' : 'opponentDeck' ] : newPlayerDeck , } as any ) ; } event ( ) { return 'GlobalMinionEffectParser' ; } }