import { RawRequirement } from '../../../../../models/achievement/raw-requirement' ; import { GameEvent } from '../../../../../models/game-event' ; import { Requirement } from '../_requirement' ; export class BattlegroundsTriplePlayReq implements Requirement { private isCardDrawn : boolean ; constructor ( private readonly cardIds ) { } public static create ( rawReq ) { if ( ! rawReq . values ) { console . error ( 'invalid parameters for BattlegroundsTriplePlayReq' , rawReq ) ; } return new BattlegroundsTriplePlayReq ( rawReq . values ) ; } reset ( ) { this . isCardDrawn = undefined ; } afterAchievementCompletionReset ( ) { this . isCardDrawn = undefined ; } isCompleted ( ) { return this . isCardDrawn ; } test ( gameEvent ) { if ( gameEvent . type === GameEvent . CARD_DRAW_FROM_DECK || gameEvent . type === GameEvent . RECEIVE_CARD_IN_HAND ) { this . detectCardPlayedEvent ( gameEvent ) ; return ; } } private detectCardPlayedEvent ( gameEvent ) { const cardId = gameEvent . cardId ; const controllerId = gameEvent . controllerId ; const localPlayer = gameEvent . localPlayer ; const isPremium = gameEvent . additionalData . isPremium ; if ( this . cardIds . indexOf ( cardId ) !== - 1 && controllerId === localPlayer ?. PlayerId && isPremium ) { this . isCardDrawn = true ; } } }