コード例 #1
0
        private NetworkData ParseMessage(string txt)
        {
            try
            {
                if (txt[0] == '/')
                {
                    txt = txt.Substring(1);
                    string cmd = txt.Split(' ')[0].ToString().ToUpper();
                    switch (cmd)
                    {
                    case "ANIM":
                        return(new NetworkData(PacketType.ChatMessage, _cmdParser.AnimationMessage(txt.Substring(cmd.Length + 1))));

                    case "INFO":
                        return(new NetworkData(PacketType.ChatMessage, _cmdParser.InformationMessage(txt.Substring(cmd.Length + 1))));

                    case "SETMOTD":
                        return(new NetworkData(PacketType.ChatMessage, _cmdParser.SetMessageOfTheDay(txt.Substring(cmd.Length + 1))));

                    case "SETGREET":
                        return(new NetworkData(PacketType.ChatMessage, _cmdParser.SetGreet(txt.Substring(cmd.Length + 1))));

                    case "KICK":
                        return(new NetworkData(PacketType.Kick, _cmdParser.Kick(txt.Substring(cmd.Length + 1))));

                    case "BAN":
                        return(new NetworkData(PacketType.Ban, _cmdParser.Ban(txt.Substring(cmd.Length + 1))));

                    case "UNBAN":
                        return(new NetworkData(PacketType.Unban, _cmdParser.Unban(txt.Substring(cmd.Length + 1))));

                    case "MUTE":
                        return(new NetworkData(PacketType.Mute, _cmdParser.Mute(txt.Substring(cmd.Length + 1))));

                    case "UNMUTE":
                        return(new NetworkData(PacketType.Unmute, _cmdParser.Unmute(txt.Substring(cmd.Length + 1))));

                    case "CLEAR":
                        return(new NetworkData(PacketType.Clear, _cmdParser.ClearChat(txt.Length > cmd.Length ? txt.Substring(cmd.Length + 1) : ".")));

                    case "MUTECHAT":
                        return(new NetworkData(PacketType.Mutechat, _cmdParser.MuteChat(txt.Length > cmd.Length ? txt.Substring(cmd.Length + 1) : ".")));

                    case "MPALL":
                        return(new NetworkData(PacketType.MPAll, _cmdParser.MPAll(txt.Substring(cmd.Length + 1))));

                    case "PANEL":
                        Panel panel = new Panel(Client.PanelAdmin);
                        panel.Show();
                        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => panel.Activate()));
                        return(null);

                    case "BANLIST":
                        return(new NetworkData(PacketType.Banlist, new StandardClientBanlist {
                        }));

                    case "MUTELIST":
                        return(new NetworkData(PacketType.Mutelist, new StandardClientMutelist {
                        }));

                    case "HELP":
                        return(new NetworkData(PacketType.Help, new StandardClientAskHelp {
                        }));

                    case "GIVEBATTLEPOINTS":
                        return(new NetworkData(PacketType.GivePoints, _cmdParser.GiveBattlePoints(txt.Substring(cmd.Length + 1))));

                    case "GIVEPRESTIGEPOINTS":
                        return(new NetworkData(PacketType.GivePoints, _cmdParser.GivePrestigePoints(txt.Substring(cmd.Length + 1))));

                    case "GIVECARD":
                        return(new NetworkData(PacketType.GiveCard, _cmdParser.GiveCard(txt.Substring(cmd.Length + 1))));

                    case "GIVEAVATAR":
                        return(new NetworkData(PacketType.GiveAvatar, _cmdParser.GiveAvatar(txt.Substring(cmd.Length + 1))));

                    case "GIVEBORDER":
                        return(new NetworkData(PacketType.GiveBorder, _cmdParser.GiveBorder(txt.Substring(cmd.Length + 1))));

                    case "GIVESLEEVE":
                        return(new NetworkData(PacketType.GiveSleeve, _cmdParser.GiveSleeve(txt.Substring(cmd.Length + 1))));

                    case "GIVEPARTNER":
                        return(new NetworkData(PacketType.GivePartner, _cmdParser.GivePartner(txt.Substring(cmd.Length + 1))));

                    case "GIVETITLE":
                        return(new NetworkData(PacketType.GiveTitle, _cmdParser.GiveTitle(txt.Substring(cmd.Length + 1))));

                    case "ENABLED":
                        return(new NetworkData(PacketType.EnabledAccount, _cmdParser.EnabledAccount(txt.Substring(cmd.Length + 1))));

                    case "DISABLED":
                        return(new NetworkData(PacketType.DisabledAccount, _cmdParser.DisabledAccount(txt.Substring(cmd.Length + 1))));

                    case "PROMOTE":
                        return(new NetworkData(PacketType.Ranker, _cmdParser.Ranker(txt.Substring(cmd.Length + 1))));

                    case "MAINTENANCE":
                        return(new NetworkData(PacketType.Maintenance, _cmdParser.AskMaintenance(txt.Substring(cmd.Length + 1))));

                    case "MAINTENANCESTOP":
                        return(new NetworkData(PacketType.StopMaintenance, _cmdParser.StopMaintenance()));

                    case "DUELSERVERSTOP":
                        return(new NetworkData(PacketType.DuelServerStop, _cmdParser.DuelServerStop(txt.Substring(cmd.Length + 1))));

                    case "DUELSERVERRESTART":
                        return(new NetworkData(PacketType.DuelServerRestart, _cmdParser.DuelServerRestart()));

                    case "NEXTRANKINGSEASON":
                        return(new NetworkData(PacketType.NextRankingSeason, _cmdParser.AskNextRankingSeason()));

                    case "BLACKLIST":
                        Blacklist blacklist = new Blacklist(Client.BlacklistManager);
                        blacklist.Show();
                        Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(() => blacklist.Activate()));
                        return(null);

                    case "STATS":
                        SpecialChatMessage?.Invoke(FormExecution.AppDesignConfig.GetGameColor("LauncherMessageColor"), "••• Il y a " + FormExecution.GetChatWindow().Players.Count + " utilisateurs connectés.", false, false);
                        return(null);

                    case "SMILEYS":
                        ShowSmileys?.Invoke();
                        return(null);

                    case "LOGS":
                        _cmdParser.OpenLogFolder();
                        return(null);

                    case "ROOMSLIST":
                        return(new NetworkData(PacketType.RoomList, new StandardClientAskRoomList {
                        }));

                    case "KILLROOM":
                        return(new NetworkData(PacketType.KillRoom, _cmdParser.KillRoom(txt.Substring(cmd.Length + 1))));

                    case "TEAMADD":
                        return(new NetworkData(PacketType.AddTeamPlayer, _cmdParser.AddTeamMember(txt.Substring(cmd.Length + 1))));

                    case "TEAMREMOVE":
                        return(new NetworkData(PacketType.RemoveTeamPlayer, _cmdParser.RemoveTeamMember(txt.Substring(cmd.Length + 1))));

                    case "TEAMCHANGELEADER":
                        return(new NetworkData(PacketType.UpdateTeamLeader, _cmdParser.ChangeTeamLeader(txt.Substring(cmd.Length + 1))));

                    case "TEAMCHANGECOLEADER":
                        return(new NetworkData(PacketType.UpdateTeamColeader, _cmdParser.ChangeTeamCoLeader(txt.Substring(cmd.Length + 1))));

                    case "TEAMLEAVE":
                        return(new NetworkData(PacketType.LeaveTeam, _cmdParser.LeaveTeam()));

                    case "RESTARTASTRAL":
                        return(new NetworkData(PacketType.RestartAstral, new StandardClientRestartAstral {
                        }));

                    case "STORY":
                        StoryModeConsole console = new StoryModeConsole();
                        console.Show();
                        return(null);

                    default:
                        SpecialChatMessage?.Invoke(FormExecution.AppDesignConfig.GetGameColor("LauncherMessageColor"), "••• Cette commande n'existe pas.", false, false);
                        return(null);
                    }
                }
                return(new NetworkData(PacketType.ChatMessage, _cmdParser.StandardMessage(txt)));
            }
            catch (Exception ex)
            {
                SpecialChatMessage?.Invoke(FormExecution.AppDesignConfig.GetGameColor("LauncherMessageColor"), "••• Une erreur s'est produite.", false, false);
                logger.Error("Chat input error : {0}", ex.ToString());
                return(null);
            }
        }