Exemplo n.º 1
0
        static void AddSoloMatch()
        {
            IPlayerManipulations playerLogic = new PlayerLogic();
            IGameManipulations gameLogic = new GameLogic();
            IMatchManipulations matchLogic = new MatchLogic();
            IRankingSource rankingLogic = new RankingLogic();

            // add match between 2 players
            List<PlayerType> players = playerLogic.GetPlayers();
            List<GameType> games = gameLogic.GetGames();
            Console.WriteLine("-> adding match (Solo)...");
            Console.WriteLine("\t\t#Method AddOrUpdateSoloMatch()");
            matchLogic.AddOrUpdateSoloMatch(new SoloMatch(new List<PlayerType> { players[0], players[2] }, new List<int> { 2500, 2300 }, MatchCategories.Competition, games[0]));
            // print match
            Console.WriteLine("\t\t#Method GetMatches()");
            Console.WriteLine("\t\t#Method SoloMatch.ToString()");
            Console.WriteLine("------- First Match -------");
            SoloMatch solo = (SoloMatch)matchLogic.GetMatches(games[0], ParticipantTypes.Solo, MatchCategories.Competition)[0];
            Console.WriteLine(solo.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();
        }
Exemplo n.º 2
0
 private void UpdatePlayerList()
 {
     clbPlayers.Items.Clear();
     clSoloMembers.Items.Clear();
     IPlayerManipulations playerLogic = new PlayerLogic();
     foreach (PlayerType player in playerLogic.GetPlayers())
     {
         clbPlayers.Items.Add($"Name: {player.Name}  Mail: {player.Mail}");
         clSoloMembers.Items.Add($"Name: {player.Name}  Mail: {player.Mail}");
     }
 }
Exemplo n.º 3
0
 static void AddPlayers()
 {
     IPlayerManipulations playerLogic = new PlayerLogic();
     // add players
     Console.WriteLine("-> adding players...");
     Console.WriteLine("\t\t#Method AddOrUpdatePlayer()");
     playerLogic.AddOrUpdatePlayer(new PlayerType("*****@*****.**", "Jonas", "Jonas_tag"));
     playerLogic.AddOrUpdatePlayer(new PlayerType("*****@*****.**", "Lien", "Lien_tag"));
     playerLogic.AddOrUpdatePlayer(new PlayerType("*****@*****.**", "Bart", "Bart_tag"));
     playerLogic.AddOrUpdatePlayer(new PlayerType("*****@*****.**", "Yana", "Yana_tag"));
     // print players
     Console.WriteLine("\t\t#Method PlayerType.ToString()");
     Console.WriteLine("------- Players -------");
     foreach (PlayerType p in playerLogic.GetPlayers())
     {
         Console.WriteLine("  " + p.ToString());
     }
     Console.WriteLine("------- @@@@@ -------\n\n");
     // wait for user
     Wait();
 }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private void UpdateTree()
        {
            IRankingSource rankingLogic = new RankingLogic();
            IGameManipulations gameLogic = new GameLogic();
            ITeamManipulations teamLogic = new TeamLogic();
            IPlayerManipulations playerLogic = new PlayerLogic();
            IMatchManipulations matchLogic = new MatchLogic();

            List<GameType> games = gameLogic.GetGames();
            List<TeamType> teams = teamLogic.GetTeams();
            List<PlayerType> players = playerLogic.GetPlayers();

            // ranking tree
            treeRankings.BeginUpdate();
            treeRankings.Nodes.Clear();
            for (int i = 0; i < games.Count; i++)
            {
                List<PlayerGameRankingType> r = rankingLogic.GetGameRankingsAll(games[i], ParticipantTypes.All);
                treeRankings.Nodes.Add(games[i].Name);
                for (int j = 0; j < r.Count; j++)
                {
                    treeRankings.Nodes[i].Nodes.Add("Player: " + r[j].Player.Name);
                    treeRankings.Nodes[i].Nodes[j].Nodes.Add("Mail: " + r[j].Player.Mail);
                    treeRankings.Nodes[i].Nodes[j].Nodes.Add("Tag: " + r[j].Player.Tag);
                    treeRankings.Nodes[i].Nodes[j].Nodes.Add("Points: " + r[j].Points);
                    treeRankings.Nodes[i].Nodes[j].Nodes.Add("Ranking: " + r[j].Ranking);
                }
            }
            treeRankings.EndUpdate();

            // games tree
            treeGames.BeginUpdate();
            treeGames.Nodes.Clear();
            for (int i = 0; i < games.Count; i++)
            {
                treeGames.Nodes.Add(games[i].Name);
                treeGames.Nodes[i].Nodes.Add("Participant type: " + games[i].ParticipantType.ToString());
            }
            treeGames.EndUpdate();

            // teams tree
            treeTeams.BeginUpdate();
            treeTeams.Nodes.Clear();
            for (int i = 0; i < teams.Count; i++)
            {
                treeTeams.Nodes.Add(teams[i].Name);
                for (int j = 0; j < teams[i].Members.Count; j++)
                {
                    treeTeams.Nodes[i].Nodes.Add($"Player: {teams[i].Members[j].Name} - {teams[i].Members[j].Tag} - {teams[i].Members[j].Mail}");
                }
            }
            treeTeams.EndUpdate();

            // players tree
            treePlayers.BeginUpdate();
            treePlayers.Nodes.Clear();
            for (int i = 0; i < players.Count; i++)
            {
                treePlayers.Nodes.Add(players[i].Name);
                treePlayers.Nodes[i].Nodes.Add("Tag: " + players[i].Tag);
                treePlayers.Nodes[i].Nodes.Add("Mail: " + players[i].Mail);
            }
            treePlayers.EndUpdate();

            // matches tree
            treeMatches.BeginUpdate();
            treeMatches.Nodes.Clear();
            for (int i = 0; i < games.Count; i++)
            {
                List<MatchType> matches = matchLogic.GetMatchesAll(games[i]);
                treeMatches.Nodes.Add($"Matches for: {games[i].Name}");
                for (int j = 0; j < matches.Count; j++)
                {
                    if (matches[j] is SoloMatch)
                    {
                        SoloMatch s = (SoloMatch)matches[j];
                        treeMatches.Nodes[i].Nodes.Add(s.dateTime.ToString());
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Name: {s.GameID.Name}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Type: {s.GameID.ParticipantType.ToString()}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Category: {s.Category.ToString()}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add("Players & scores");
                        for (int k = 0; k < s.Players.Count; k++)
                        {
                            treeMatches.Nodes[i].Nodes[j].Nodes[3].Nodes.Add($"Player: {s.Players[k].Name} : {s.Scores[k]}");
                        }
                    }
                    else if (matches[j] is TeamMatch)
                    {
                        TeamMatch t = (TeamMatch)matches[j];
                        treeMatches.Nodes[i].Nodes.Add(t.dateTime.ToString());
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Name: {t.GameID.Name}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Type: {t.GameID.ParticipantType.ToString()}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add($"Category: {t.Category.ToString()}");
                        treeMatches.Nodes[i].Nodes[j].Nodes.Add("Teams & scores");
                        for (int k = 0; k < t.Teams.Count; k++)
                        {
                            treeMatches.Nodes[i].Nodes[j].Nodes[3].Nodes.Add($"Team: {t.Teams[k].Name} : {t.Scores[k]}");
                        }
                    }
                }
            }
            treeMatches.EndUpdate();
        }
Exemplo n.º 6
0
 private void btnAddSoloMatch_Click(object sender, EventArgs e)
 {
     IMatchManipulations matchLogic = new MatchLogic();
     IPlayerManipulations playerLogic = new PlayerLogic();
     IGameManipulations gameLogic = new GameLogic();
     try
     {
         List<PlayerType> players = new List<PlayerType>();
         MatchCategories cat = (MatchCategories)Enum.Parse(typeof(MatchCategories), downUpSoloCat.SelectedItem.ToString());
         GameType game = gameLogic.GetGames()[downUpSoloGame.SelectedIndex];
         List<int> scores = new List<int>();
         string[] parts = tbSoloScores.Text.Split(',');
         foreach (string s in parts)
         {
             scores.Add(int.Parse(s));
         }
         for (int i = 0; i < clSoloMembers.CheckedItems.Count; i++)
         {
             players.Add(playerLogic.GetPlayers()[clSoloMembers.Items.IndexOf(clSoloMembers.CheckedItems[i])]);
         }
         if ((players.Count > 0) && (players.Count == scores.Count))
         {
             matchLogic.AddOrUpdateSoloMatch(new SoloMatch(players, scores, cat, game));
             tbSoloScores.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();
 }
Exemplo n.º 7
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();
 }