namespace Models { export const enum AutomatchCriteria { FreeGames = ( 1 << 0 ) , RankedGames = ( 1 << 1 ) , RobotPlayers = ( 1 << 2 ) , HumanPlayers = ( 1 << 3 ) , UnrankedPlayers = ( 1 << 4 ) , BlitzSpeed = ( 1 << 5 ) , FastSpeed = ( 1 << 6 ) , MediumSpeed = ( 1 << 7 ) } export class AutomatchState { public maxHandicap : number ; public estimatedRank : string ; public criteria : AutomatchCriteria ; public seeking : boolean ; constructor ( ) { this . seeking = false ; } public mergePreferences ( preferences ) { let touch = false ; if ( this . maxHandicap != preferences . maxHandicap ) { this . maxHandicap = preferences . maxHandicap ; touch = true ; } if ( this . estimatedRank != preferences . estimatedRank ) { this . estimatedRank = preferences . estimatedRank ; touch = true ; } let criteria = 0 ; if ( preferences . freeOk ) criteria |= AutomatchCriteria . FreeGames ; if ( preferences . rankedOk ) criteria |= AutomatchCriteria . RankedGames ; if ( preferences . robotOk ) criteria |= AutomatchCriteria . RobotPlayers ; if ( preferences . humanOk ) criteria |= AutomatchCriteria . HumanPlayers ; if ( preferences . unrankedOk ) criteria |= AutomatchCriteria . UnrankedPlayers ; if ( preferences . blitzOk ) criteria |= AutomatchCriteria . BlitzSpeed ; if ( preferences . fastOk ) criteria |= AutomatchCriteria . FastSpeed ; if ( preferences . mediumOk ) criteria |= AutomatchCriteria . MediumSpeed ; if ( this . criteria != criteria ) { this . criteria = criteria ; touch = true ; } return touch ; } } }