Esempio n. 1
0
 public void TounamentTeamScoreRejectsNullParameters()
 {
     try
     {
         TournamentTeamScore ts = new TournamentTeamScore(null, null);
         Assert.Fail();
     }
     catch (ArgumentNullException)
     {
         return;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Get's results of a game
        /// </summary>
        public void CloseVoteAndSetResult()
        {
            Platform.Synchronize();
            Game.Status = GameStatus.Completed;

            // get votes
            long first_votes  = GetVoteCount(Game.Players[0].BotId);
            long second_votes = GetVoteCount(Game.Players[1].BotId);

            // set scores
            Game.Players[0].Score += first_votes * 10;
            Game.Players[1].Score += second_votes * 10;

            if (first_votes == second_votes)
            {
                if (Generator.Next(0, 1) == 1)
                {
                    Game.WinnerId          = Game.Players[1].BotId;
                    Game.Players[1].Score += Competition.PointsPerWin;
                }
                else
                {
                    Game.WinnerId          = Game.Players[0].BotId;
                    Game.Players[0].Score += Competition.PointsPerWin;
                }
            }
            else if (first_votes > second_votes)
            {
                Game.WinnerId          = Game.Players[0].BotId;
                Game.Players[0].Score += Competition.PointsPerWin;
            }
            else
            {
                Game.WinnerId          = Game.Players[1].BotId;
                Game.Players[1].Score += Competition.PointsPerWin;
            }


            Platform.DBManager.SaveChanges();

            // Set rounds
            TournamentTeamScore first  = null;
            TournamentTeamScore second = null;

            GetTeamFromPairing(Game.Players[0].BotId, ref first);
            GetTeamFromPairing(Game.Players[1].BotId, ref second);

            first.Score  = new HighestPointsScore(Game.Players[0].Score);
            second.Score = new HighestPointsScore(Game.Players[1].Score);

            Game.Players[0].Bot.BotScore += (int)Game.Players[0].Score;
            Game.Players[1].Bot.BotScore += (int)Game.Players[1].Score;
        }
Esempio n. 3
0
 public bool GetTeamFromPairing(long?bot, ref TournamentTeamScore team)
 {
     team = null;
     foreach (TournamentPairing pair in CurrentRound.Pairings)
     {
         foreach (TournamentTeamScore tts in pair.TeamScores)
         {
             if (tts.Team.TeamId == bot)
             {
                 team = tts;
                 return(true);
             }
         }
     }
     return(false);
 }