public static void Do(ClientInfo clientInfo, string data)
        {
            C2S_ExitMatchGameMode2 c2s = JsonConvert.DeserializeObject <C2S_ExitMatchGameMode2>(data);

            MatchLogic.removeUser(clientInfo);
            CommonUtil.Log("玩家退出匹配:" + c2s.UserId, true);
        }
Пример #2
0
        public void UpdateMatchesLose(int id)
        {
            TeamDataLogic teamDataLogic = new TeamDataLogic();
            MatchLogic    matchLogic    = new MatchLogic();

            teamDataLogic.UpdateMatchesLose(matchLogic.GetMatchById(id).FirstTeamId);
            teamDataLogic.UpdateMatchesWin(matchLogic.GetMatchById(id).SecondTeamId);
        }
        public IEnumerable <Match> GetTeamMatches()
        {
            MatchLogic matchLogic = new MatchLogic();
            UserLogic  userLogic  = new UserLogic();
            int        id         = userLogic.GetIdByNameUser(User.Identity.Name);

            return(matchLogic.GetMatchesByUser(id));
        }
Пример #4
0
        public HttpResponseMessage MatchList()
        {
            MatchLogic matchLogic = new MatchLogic();

            jsonResult = matchLogic.MatchList();

            returnResult.Content = new StringContent(jsonResult, Encoding.UTF8, "application/json");
            return(returnResult);
        }
Пример #5
0
        public HttpResponseMessage BoBoCount([FromBody] MatchParameterModel match)
        {
            MatchLogic matchLogic = new MatchLogic();

            jsonResult = matchLogic.BoBoCount(match);

            returnResult.Content = new StringContent(jsonResult, Encoding.UTF8, "application/json");
            return(returnResult);
        }
Пример #6
0
        public static void Do(ClientInfo clientInfo, string data)
        {
            S2C_EnterGameMode2 s2c = new S2C_EnterGameMode2();

            s2c.Tag  = CSParam.NetTag.EnterGameMode2.ToString();
            s2c.Code = (int)CSParam.CodeType.Ok;
            Socket_S.getInstance().Send(clientInfo, s2c);

            C2S_EnterGameMode2 c2s = JsonConvert.DeserializeObject <C2S_EnterGameMode2>(data);

            MatchLogic.addUser(clientInfo, c2s);
        }
 public int AddMacth([FromBody] Match match)
 {
     try
     {
         MatchLogic matchLogic = new MatchLogic();
         matchLogic.AddMatch(match);
     }
     catch (Exception)
     {
         return(match.FirstTeamId);
     }
     return(match.Id);
 }
        public int CalculateFirstTeamScore(int id)
        {
            object     locker       = new object();
            MatchLogic matchLogic   = new MatchLogic();
            int        firstTeamId  = matchLogic.GetMatchById(id).FirstTeamId;
            int        secondTeamId = matchLogic.GetMatchById(id).SecondTeamId;
            int        minute       = matchLogic.GetCurrentMinute(id);

            lock (locker)
            {
                matchLogic.CalculateMinute(firstTeamId, secondTeamId, id, minute);
                matchLogic.UpdateTimer(id);
            }
            return(matchLogic.GetMatchById(id).FirstTeamGoals);
        }
Пример #9
0
        private void TransitionToMatch()
        {
            if (transitionFinished)
            {
                return;
            }

            Scene matchScene = new Scene();

            matchScene.RegisterMatchSoundManager(scene.MatchSoundManager);

            Logic matchLogic = new MatchLogic(director, matchScene, selectedPlayers);

            matchLogic.Initialize();
            Screen matchScreen = new MatchScreen(director, matchScene, matchLogic.BaseScreenSize, selectedPlayers);

            director.TransitionToLogic(matchLogic);
            director.TransitionToScreen(matchScreen, 3, -1);

            transitionFinished = true;
        }
Пример #10
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();
        }
Пример #11
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();
        }
Пример #12
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();
        }
Пример #13
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();
        }
Пример #14
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();
        }
Пример #15
0
        public void TestMatch()
        {
            MatchLogic matchLogic = new MatchLogic();
            var dataManager = new DataManager();
            MatchRequest req = new MatchRequest();

            var userDataPuddy = new UserProfileRequest
            {
                //UserID = 69,
                UserName = "******",
                ProfileAttributeType = ProfileAttributeTypeEnum.All
            };

            UserProfileData match = dataManager.FetchProfile(userDataPuddy);

            // This is elaine.
            req.UserID = 6969;

            MatchResponse response = matchLogic.GetMatchByLocation(req);

            if (response != null)
            {

                if (response.MatchProfiles != null && response.MatchProfiles.Count() > 0)
                {
                    foreach (ChoiceProfile cp in response.MatchProfiles)
                    {
                        cp.ChoiceType =  ChoiceTypeEnum.Like;

                    }

                    // Add the match profiles
                    var userProfileData = new UserProfileData
                    {
                        UserData = match.UserData,
                        UserChoices = response.MatchProfiles
                    };

                    dataManager.ModifyProfile(userProfileData);
                }

            }
        }
Пример #16
0
 public static void deleteClientInfo(ClientInfo clientInfo)
 {
     MatchLogic.removeUser(clientInfo);
     RoomManager.deleteUser(clientInfo);
     s_clientList.Remove(clientInfo);
 }
        public int GetFirstTeamId(int id)
        {
            MatchLogic matchLogic = new MatchLogic();

            return(matchLogic.GetMatchById(id).FirstTeamId);
        }
        public int GetCurrentMinute(int id)
        {
            MatchLogic matchLogic = new MatchLogic();

            return(matchLogic.GetCurrentMinute(id));
        }
        public int GetFirstSecondScore(int id)
        {
            MatchLogic matchLogic = new MatchLogic();

            return(matchLogic.GetMatchById(id).SecondTeamGoals);
        }
        public int CalculateSecondTeamScore(int id)
        {
            MatchLogic matchLogic = new MatchLogic();

            return(matchLogic.GetMatchById(id).SecondTeamGoals);
        }
        public int GetSecondTeamId(int id)
        {
            MatchLogic matchLogic = new MatchLogic();

            return(matchLogic.GetMatchById(id).SecondTeamId);
        }