Exemple #1
0
 public MatchResult GetMatchResult(int teamAID, int teamBID)
 {
     var mr = new MatchResult();
     mr.SetTeamAID(teamAID);
     mr.SetTeamBID(teamBID);
     mr.SetTeamAScore(teamAScore);
     mr.SetTeamBScore(teamBScore);
     return mr;
 }
 public void AddMatchResult(MatchResult match)
 {
     var matchResult = match.Clone();
     try
     {
         ladders[currentLadder].MatchPlayed(matchResult.GetMatchID(), matchResult);
     }
     catch (Exception e)
     {
     }
 }
 public void MatchStringTest()
 {
     var match = new MatchResult();
     match.SetTeamAID(1);
     match.SetTeamBID(2);
     var scoreTeamA = new Score();
     var scoreTeamB = new Score();
     match.SetTeamAScore(scoreTeamA);
     match.SetTeamBScore(scoreTeamB);
        // Assert.AreEqual(match.ToString(), "1: tag: 0, flag: 0, score 0, 2: tag: 0, flag: 0, score 0");
 }
 public MatchResult Clone()
 {
     var mr = new MatchResult();
     mr.SetMatchID(matchID);
     mr.SetTeamAID(teamAID);
     mr.SetTeamAScore(teamAScore);
     mr.SetTeamBID(teamBID);
     mr.SetTeamBScore(teamBScore);
     mr.SetPlayed(played);
     if (dummyGame)
     {
         mr.SetDummyGame(dummyGame);
     }
     return mr;
 }
 public void MatchWinnerTests()
 {
     var match = new MatchResult();
     match.SetTeamAID(1);
     match.SetTeamBID(2);
     var scoreTeamA = new Score();
     var scoreTeamB = new Score();
     for(int i = 0; i < 3; i++)
     {
         scoreTeamA.AddTag();
     }
     scoreTeamA.AddFlag();
     for(int i = 0; i < 10; i++)
     {
         scoreTeamB.AddTag();
     }
     match.SetTeamAScore(scoreTeamA);
     match.SetTeamBScore(scoreTeamB);
     Assert.AreEqual(2, match.GetWinner());
 }
Exemple #6
0
 private void LaunchGame(MatchResult matchPlayed)
 {
     //Have to clear the scores
     var liveMatchTab = mainWindow.liveMatch;
     mainWindow.ChangeLiveMatch();
     liveMatchTab.SetPlayed(matchPlayed);
 }
Exemple #7
0
 private void HandleListView_DoubleClick(object sender, RoutedEventArgs e)
 {
     var ladderTab = mainWindow.ladderView;
     try
     {
         matchSelected = ladderTab.GetTeamsSelectedTeam();
         if (!matchSelected.GetPlayed())
         {
             currentMatchID = matchSelected.GetMatchID();
             liveMatch.SetMatchType(MatchType.Ladder);
             LaunchGame(matchSelected);
         }
     }
     catch (NoGameSelectedException)
     {
         Console.WriteLine("No game selected");
     }
 }
Exemple #8
0
 public void SetMatch(int matchID, MatchResult matchPlayed)
 {
     ladderTiers[currentTier].SetMatch(matchID, matchPlayed);
 }
Exemple #9
0
 public void MatchPlayed(int ID, MatchResult mr)
 {
     mr.SetPlayed(true);
     ladderTiers[currentTier].SetMatch(ID, mr);
     var winnerID = mr.GetWinner();
     if (winnerID != -1)
     {
         if (currentTier + 1 != tierCount)
         {
             ladderTiers[currentTier + 1].AddTeam(winnerID, ID);
             if (ladderTiers[currentTier].AllMatchesPlayed())
             {
                 var breakTeams = ladderTiers[currentTier++].GetAllBreaks();
                 AddBreakTeams(breakTeams);
             }
         }
         else
         {
             this.tournamentWinnerID = winnerID;
             throw new TournamentWinnerException(winnerID);
         }
     }
     else
     {
         mr.SetPlayed(false);
     }
 }
        public void GenerateRandomMatches(List<int> teamIDs)
        {
            var cloneTeamIDs = LadderUtil.CloneIntList(teamIDs);
            var totalTeams = cloneTeamIDs.Count;
            var totalMatches = 0;
            var nextTier = LadderUtil.GetTierCount(totalTeams);
            totalMatches = (int)(totalTeams - Math.Pow(2, nextTier - 1));

            for (int i = 0; i < totalMatches; i++)
            {
                var teamAID = GetRandomTeam(cloneTeamIDs);
                var teamBID = GetRandomTeam(cloneTeamIDs);
                currentTeams.Add(teamAID);
                currentTeams.Add(teamBID);

                var match = new MatchResult();
                match.SetTeamAID(teamAID);
                match.SetTeamBID(teamBID);
                match.SetMatchID(i);
                matches.Add(i, match);
            }

            var tierMatches = Math.Pow(2, nextTier - 1);
            for (int i = totalMatches; i < tierMatches; i++)
            {
                var teamAId = GetRandomTeam(cloneTeamIDs);
                currentTeams.Add(teamAId);
                var match = new MatchResult();
                match.SetTeamAID(teamAId);
                match.SetDummyGame(true);
                matches.Add(i, match);
            }
        }
 public void SetMatch(int ID, MatchResult mr)
 {
     mr.SetPlayed(true);
     matches[ID] = mr.Clone();
 }
 public void SetPlayed(MatchResult matchPlayed)
 {
     this.matchPlayed = matchPlayed;
     SetTeams(matchPlayed.GetTeamAID(), matchPlayed.GetTeamAName(), cmbTeamA);
     SetTeams(matchPlayed.GetTeamBID(), matchPlayed.GetTeamBName(), cmbTeamB);
 }