Beispiel #1
0
        private void btnAddTeam_Click(object sender, EventArgs e)
        {
            IPlayerManipulations playerLogic = new PlayerLogic();
            ITeamManipulations   teamLogic   = new TeamLogic();
            List <PlayerType>    players     = new List <PlayerType>();

            if (tbTeamName.Text != "")
            {
                try
                {
                    for (int i = 0; i < clbPlayers.CheckedItems.Count; i++)
                    {
                        players.Add(playerLogic.GetPlayers()[clbPlayers.Items.IndexOf(clbPlayers.CheckedItems[i])]);
                    }
                    if (players.Count > 0)
                    {
                        teamLogic.AddOrUpdateTeam(new TeamType(tbTeamName.Text, players));
                        tbTeamName.Text = "";
                        UpdateTeamList();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error: Add Team", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Team needs a name.", "Error: Add Team", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            UpdateTree();
        }
Beispiel #2
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();
        }