예제 #1
0
        public void PairAttendees()
        {
            allGames = dataStore.LoadAllGamesFromDataStore();
            allGames.Sort(gameComparer);
            List <clsMeetingAttendee> listRemainingAttendees = new List <clsMeetingAttendee>();

            foreach (clsMeetingAttendee attendee in listChallengeGameAttendees)
            {
                if (attendee.ChallengeGameAssigned == false)
                {
                    attendee.LastGame = allGames.GetPreviousGameForPlayer(attendee.Player);
                    listRemainingAttendees.Add(attendee);
                }
            }
            clsCompareAttendeesByRank rankComparer = new clsCompareAttendeesByRank();

            listRemainingAttendees.Sort(rankComparer);
            gameBoard = listRemainingAttendees.Count / 2;

            while (listRemainingAttendees.Count > 1)
            {
                clsChallengeGame nextGame = GetNextMatch(listRemainingAttendees);
                listChallengeGames.Add(nextGame);
                gameBoard--;
            }
        }
예제 #2
0
        private clsChallengeGame GetNextMatch(List <clsMeetingAttendee> listRemainingAttendees)
        {
            clsChallengeGame nextGame = new clsChallengeGame();

            nextGame.GameBoard  = gameBoard;
            nextGame.GameDate   = DateTime.Today;
            nextGame.GameResult = "None";

            clsMeetingAttendee whitePlayer = GetWhitePlayer(listRemainingAttendees);

            nextGame.WhitePlayerID            = whitePlayer.Player.PlayerID;
            whitePlayer.ChallengeGameAssigned = true;
            listRemainingAttendees.Remove(whitePlayer);
            clsMeetingAttendee blackPlayer = GetBlackPlayer(whitePlayer, listRemainingAttendees);

            nextGame.BlackPlayerID            = blackPlayer.Player.PlayerID;
            blackPlayer.ChallengeGameAssigned = true;
            listRemainingAttendees.Remove(blackPlayer);
            return(nextGame);
        }