import { RawRequirement } from '../../../../models/achievement/raw-requirement' ; import { GameEvent } from '../../../../models/game-event' ; import { Requirement } from './_requirement' ; export class MonsterHuntStepReq implements Requirement { private isCorrectStep = false ; private assignedStep : boolean ; constructor ( private readonly targetStep ) { } public static create ( rawReq ) { if ( ! rawReq . values || rawReq . values . length !== 1 ) { console . error ( 'invalid parameters for MonsterHuntStepReq' , rawReq ) ; } return new MonsterHuntStepReq ( parseInt ( rawReq . values [ 0 ] ) ) ; } reset ( ) { this . isCorrectStep = false ; this . assignedStep = false ; } afterAchievementCompletionReset ( ) { this . isCorrectStep = false ; this . assignedStep = false ; } isCompleted ( ) { return this . isCorrectStep ; } test ( gameEvent ) { if ( ! this . assignedStep && gameEvent . type === GameEvent . MONSTER_HUNT_STEP ) { this . isCorrectStep = gameEvent . additionalData . step === this . targetStep ; this . assignedStep = true ; } } }