import { RawRequirement } from '../../../../models/achievement/raw-requirement' ; import { GameEvent } from '../../../../models/game-event' ; import { Requirement } from './_requirement' ; export class GameWonReq implements Requirement { private isWon : boolean ; public static create ( rawReq ) { return new GameWonReq ( ) ; } reset ( ) { this . isWon = undefined ; } afterAchievementCompletionReset ( ) { this . isWon = undefined ; } isCompleted ( ) { return this . isWon ; } test ( gameEvent ) { if ( gameEvent . type === GameEvent . WINNER ) { this . detectGameResultEvent ( gameEvent ) ; return ; } } private detectGameResultEvent ( gameEvent ) { const winner = gameEvent . additionalData . winner ; const localPlayer = gameEvent . localPlayer ; if ( winner && localPlayer ?. Id === winner . Id ) { this . isWon = true ; } } }