import { RawRequirement } from '../../../../models/achievement/raw-requirement' ; import { GameEvent } from '../../../../models/game-event' ; import { Requirement } from './_requirement' ; export class ExcludedScenarioIdReq implements Requirement { private isExcludedScenario : boolean ; constructor ( private readonly excludedScenarioIds ) { } public static create ( rawReq ) { if ( ! rawReq . values || rawReq . values . length === 0 ) { console . error ( 'invalid parameters for ScenarioIdReq' , rawReq ) ; } return new ExcludedScenarioIdReq ( rawReq . values . map ( ( id ) => parseInt ( id ) ) ) ; } reset ( ) { this . isExcludedScenario = undefined ; } afterAchievementCompletionReset ( ) { this . isExcludedScenario = undefined ; } isCompleted ( ) { return ! this . isExcludedScenario ; } test ( gameEvent ) { if ( gameEvent . type === GameEvent . MATCH_METADATA ) { this . handleEvent ( gameEvent ) ; } } private handleEvent ( gameEvent ) { if ( this . excludedScenarioIds . indexOf ( gameEvent . additionalData . metaData . ScenarioID ) !== - 1 ) { this . isExcludedScenario = true ; } } }