Example #1
0
        static void AddTeamMatch()
        {
            IPlayerManipulations playerLogic = new PlayerLogic();
            IGameManipulations gameLogic = new GameLogic();
            ITeamManipulations teamLogic = new TeamLogic();
            IMatchManipulations matchLogic = new MatchLogic();
            IRankingSource rankingLogic = new RankingLogic();

            List<PlayerType> players = playerLogic.GetPlayers();
            List<GameType> games = gameLogic.GetGames();
            // add team
            Console.WriteLine("-> adding teams...");
            Console.WriteLine("\t\t#Method AddOrUpdateTeam()");
            teamLogic.AddOrUpdateTeam(new TeamType("FirstTeam", new List<PlayerType> { players[0] }));
            teamLogic.AddOrUpdateTeam(new TeamType("SecondTeam", new List<PlayerType> { players[2] }));

            // print teams
            Console.WriteLine("\t\t#Method TeamType.ToString()");
            Console.WriteLine("------- Teams Game -------");
            foreach (TeamType t in teamLogic.GetTeams())
            {
                Console.WriteLine(t.ToString());
            }
            Console.WriteLine("------- @@@@@ -------\n\n");
            // wait for user
            Wait();

            // add match between 2 teams
            Console.WriteLine("-> adding team match...");
            Console.WriteLine("\t\t#Method GetTeams()");
            List<TeamType> teams = teamLogic.GetTeams();
            Console.WriteLine("\t\t#Method AddOrUpdateTeamMatch()");
            matchLogic.AddOrUpdateTeamMatch(new TeamMatch(MatchCategories.Competition, games[0], new List<TeamType> { teams[0], teams[1] }, new List<int> { 200, 3000 }));
            // print match
            Console.WriteLine("\t\t#Method GetMatchesForTeam()");
            Console.WriteLine("------- First Team Match -------");
            TeamMatch team = (TeamMatch)teamLogic.GetMatchesForTeam(teams[0])[0];
            Console.WriteLine(team.ToString());
            Console.WriteLine("------- @@@@@ -------\n\n");


            // print ranking
            Console.WriteLine("\t\t#Method GetGameRankingsAll()");
            Console.WriteLine("------- Ranking Game -------");
            foreach (PlayerGameRankingType g in rankingLogic.GetGameRankingsAll(games[0], ParticipantTypes.All))
            {
                Console.WriteLine(g.ToString());
            }
            Console.WriteLine("------- @@@@@ -------\n\n");
            // wait for user
            Wait();
        }
Example #2
0
 private void btnAddTeamMatch_Click(object sender, EventArgs e)
 {
     IMatchManipulations matchLogic = new MatchLogic();
     ITeamManipulations teamLogic = new TeamLogic();
     IGameManipulations gameLogic = new GameLogic();
     try
     {
         List<TeamType> teams = new List<TeamType>();
         MatchCategories cat = (MatchCategories)Enum.Parse(typeof(MatchCategories), downUpTeamCat.SelectedItem.ToString());
         GameType game = gameLogic.GetGames()[downUpTeamGame.SelectedIndex];
         List<int> scores = new List<int>();
         string[] parts = tbTeamScores.Text.Split(',');
         foreach (string s in parts)
         {
             scores.Add(int.Parse(s));
         }
         for (int i = 0; i < clTeamTeams.CheckedItems.Count; i++)
         {
             teams.Add(teamLogic.GetTeams()[clTeamTeams.Items.IndexOf(clTeamTeams.CheckedItems[i])]);
         }
         if ((teams.Count > 0) && (teams.Count == scores.Count))
         {
             matchLogic.AddOrUpdateTeamMatch(new TeamMatch(cat, game, teams, scores));
             tbTeamScores.Text = "";
         }
         else
         {
             MessageBox.Show("Invalid scores.", "Error: Add Match", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error: Add Match", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     UpdateTree();
 }