import { RawRequirement } from '../../../../models/achievement/raw-requirement' ; import { GameEvent } from '../../../../models/game-event' ; import { Requirement } from './_requirement' ; export class ArmorAtEndReq implements Requirement { private hasCorrectArmorAtEnd : boolean ; constructor ( private readonly targetArmor ) { } public static create ( rawReq ) { if ( ! rawReq . values || rawReq . values . length === 0 ) { console . error ( 'invalid parameters for ArmorAtEndReq' , rawReq ) ; } return new ArmorAtEndReq ( parseInt ( rawReq . values [ 0 ] ) ) ; } reset ( ) { this . hasCorrectArmorAtEnd = undefined ; } afterAchievementCompletionReset ( ) { this . hasCorrectArmorAtEnd = undefined ; } isCompleted ( ) { return this . hasCorrectArmorAtEnd ; } test ( gameEvent ) { if ( gameEvent . type === GameEvent . GAME_END ) { this . handleEvent ( gameEvent ) ; } } private handleEvent ( gameEvent ) { if ( gameEvent . additionalData . report ?. LocalPlayer ?. ArmorLeft === this . targetArmor ) { this . hasCorrectArmorAtEnd = true ; } } }