public static bool TestPlayerScoreFormulaValid(Tournament tournament)
 {
     try
     {
         Dictionary <string, int> scorePerTag = new Dictionary <string, int>();
         foreach (var tag in tournament.Config.Tags)
         {
             scorePerTag[tag.Name] = 0;
         }
         // Calculated tags may depend on previous values to we have to iterate two times
         foreach (var tag in tournament.Config.Tags)
         {
             scorePerTag[tag.Name] = Matchup.CalculateTag(tag, scorePerTag, scorePerTag);
         }
         CalculatePlayerTotalScore(tournament, 0, scorePerTag);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Beispiel #2
0
        public void UpdateMatchupWithView()
        {
            SourceMatchup.CurrentResult = (Result)IndexCurrentResult;
            foreach (DataRow row in Tags.Rows)
            {
                var tagname = (string)row["Tag"];
                var player1 = (int)row[Player1Name];
                var player2 = (int)row[Player2Name];
                SourceMatchup.Player1Tags[tagname] = player1;
                SourceMatchup.Player2Tags[tagname] = player2;
            }
            foreach (var tag in SourceTournament.Config.Tags)
            {
                if (tag.Type != TagType.Calculated)
                {
                    continue;
                }
                SourceMatchup.Player1Tags[tag.Name] = Matchup.CalculateTag(tag, SourceMatchup.Player1Tags, SourceMatchup.Player2Tags);
                SourceMatchup.Player2Tags[tag.Name] = Matchup.CalculateTag(tag, SourceMatchup.Player2Tags, SourceMatchup.Player1Tags);
            }
            SourceTournament.UpdateRanking();

            SourceTournament.Save();

            // Band aid because there should be no need to execute this
            // to make the datagrid refresh
            var round            = SourceTournament.Rounds[SourceMatchup.Round - 1];
            var updated_matchups = new List <Matchup>();

            foreach (var matchup in round.Matchups)
            {
                updated_matchups.Add(matchup);
            }
            round.Matchups = updated_matchups;
            round.OnPropertyChanged("Matchups");
        }