Beispiel #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();
        }
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();
        }
Beispiel #3
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();
        }