public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            _logger.LogDebug(e.PlayerControl.PlayerInfo.PlayerName + " said " + e.Message);

            if (e.Message == "test")
            {
                e.Game.Options.KillCooldown   = 0;
                e.Game.Options.NumImpostors   = 2;
                e.Game.Options.PlayerSpeedMod = 5;

                await e.Game.SyncSettingsAsync();
            }

            if (e.Message == "look")
            {
                await e.PlayerControl.SetColorAsync(ColorType.Pink);

                await e.PlayerControl.SetHatAsync(HatType.Cheese);

                await e.PlayerControl.SetSkinAsync(SkinType.Police);

                await e.PlayerControl.SetPetAsync(PetType.Ufo);
            }

            if (e.Message == "snap")
            {
                await e.PlayerControl.NetworkTransform.SnapToAsync(new Vector2(1, 1));
            }

            await e.PlayerControl.SetNameAsync(e.Message);

            await e.PlayerControl.SendChatAsync(e.Message);
        }
示例#2
0
        public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            Console.WriteLine(e.PlayerControl.PlayerInfo.PlayerName + " said " + e.Message);

            if (e.Message == "test")
            {
                e.Game.Options.KillCooldown   = 0;
                e.Game.Options.NumImpostors   = 2;
                e.Game.Options.PlayerSpeedMod = 5;

                await e.Game.SyncSettingsAsync();
            }

            if (e.Message == "look")
            {
                await e.PlayerControl.SetColorAsync(ColorType.Pink);

                await e.PlayerControl.SetHatAsync(HatType.Cheese);

                await e.PlayerControl.SetSkinAsync(SkinType.Police);

                await e.PlayerControl.SetPetAsync(PetType.Ufo);
            }

            await e.PlayerControl.SetNameAsync(e.Message);

            await e.PlayerControl.SendChatAsync(e.Message);
        }
 private static void PlayerChat(IPlayerChatEvent obj)
 {
     if (obj.Message[0] == '/')
     {
         CommandProcessor.ProcessGameChat(obj.ClientPlayer, obj.Message);
     }
 }
        public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            _logger.LogInformation(e.PlayerControl.PlayerInfo.PlayerName + " said " + e.Message);

            /*
             * if (e.Message == "test")
             * {
             *  e.Game.Options.KillCooldown = 0;
             *  e.Game.Options.NumImpostors = 2;
             *  e.Game.Options.PlayerSpeedMod = 5;
             *
             *  await e.Game.SyncSettingsAsync();
             * }
             *
             * if (e.Message == "look")
             * {
             *  await e.PlayerControl.SetColorAsync(ColorType.Pink);
             *  await e.PlayerControl.SetHatAsync(HatType.Cheese);
             *  await e.PlayerControl.SetSkinAsync(SkinType.Police);
             *  await e.PlayerControl.SetPetAsync(PetType.Ufo);
             * }
             *
             * await e.PlayerControl.SetNameAsync(e.Message);
             * await e.PlayerControl.SendChatAsync(e.Message);
             */
        }
        public void OnPlayerChat(IPlayerChatEvent e)
        {
            new Task(async() =>
            {
                if (e.Game.GameState != GameStates.NotStarted || !e.ClientPlayer.IsHost)
                {
                    return;
                }
                var command = e.Message.Split(' ');
                switch (command[0])
                {
                case "/gamemode":
                    switch (command.Length)
                    {
                    case 1:
                        if (_susSuiteManager.PluginManager.TryGetGame(e.Game.Code, out var susSuiteGame))
                        {
                            var msg1 = new string[4];
                            msg1[0]  = $"Current Game Mode: {susSuiteGame.SusSuitePlugin.Name}";
                            msg1[1]  = $"{susSuiteGame.SusSuitePlugin.Description}";
                            msg1[2]  = $"Made by: {susSuiteGame.SusSuitePlugin.Author}";
                            msg1[3]  = $"Version: {susSuiteGame.SusSuitePlugin.Version}";
                            await _susSuiteCore.PluginService.SendMessageAsync(e.Game, msg1);
                        }
                        break;

                    case 2:
                        var plugin = command[1];
                        if (_susSuiteManager.PluginManager.TryGetPlugin(plugin, out var susSuitePlugin))
                        {
                            _susSuiteManager.PluginManager.EnablePlugin(susSuitePlugin, e.Game.Code);
                            var msg2 = new string[4];
                            msg2[0]  = $"Game Mode Changed to: {susSuitePlugin.FormattedPluginName}";
                            msg2[1]  = $"{susSuitePlugin.Description}";
                            msg2[2]  = $"Made by: {susSuitePlugin.Author}";
                            msg2[3]  = $"Version: {susSuitePlugin.Version}";
                            await _susSuiteCore.PluginService.SendMessageAsync(e.Game, msg2);
                        }
                        else
                        {
                            await _susSuiteCore.PluginService.SendPrivateMessageAsync(e.ClientPlayer, "Invalid Game Mode.", "Valid Game Modes: " + _susSuiteManager.PluginManager.GetGameModeList());
                        }
                        break;

                    default:

                        await _susSuiteCore.PluginService.SendPrivateMessageAsync(e.ClientPlayer, "Too Many Arguments.");
                        break;
                    }
                    break;

                case "/gamemodes":
                    var msg = new string[1];
                    msg[0]  = $"Game Modes: {_susSuiteManager.PluginManager.GetGameModeList()}";
                    await _susSuiteCore.PluginService.SendMessageAsync(e.Game, msg);
                    break;
                }
            }).Start();
        }
 public void OnPlayerChat(IPlayerChatEvent e)
 {
     _logger.LogInformation($"{e.PlayerControl.PlayerInfo.PlayerName} said {e.Message}");
     if (e.Game.GameState == GameStates.NotStarted && e.Message.StartsWith("/"))
     {
         Task.Run(async() => await RunCommands(e).ConfigureAwait(false));
     }
 }
        public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            if (e.Game.GameState != GameStates.NotStarted || !e.Message.StartsWith(commandPrefix))
            {
                return;
            }

            switch (e.Message.ToLowerInvariant()[($"{commandPrefix} ".Length)..])
        // ReSharper disable once UnusedMember.Global
        public async ValueTask OnPlayerChat(IPlayerChatEvent chatEvent)
        {
            var message = chatEvent.Message;

            if (message.ElementAtOrDefault(0) == '/')
            {
                await HandleCommand(chatEvent);
            }
        }
示例#9
0
        public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            var msg = e.Message;

            if (!e.ClientPlayer.IsHost || msg.Length < 3 || !msg.StartsWith(CommandPrefix))
            {
                return;
            }

            msg = msg[CommandPrefix.Length..];
示例#10
0
        private async Task RunCommands(IPlayerChatEvent e)
        {
            switch (e.Message.ToLowerInvariant())
            {
            case "/j on":
            case "/jester on":
                if (e.ClientPlayer.IsHost)
                {
                    JesterGame jgame = JesterGames[e.Game.Code];
                    jgame.JesterOn           = true;
                    JesterGames[e.Game.Code] = jgame;

                    await ServerSendChatAsync("The Jester role is now on!", e.PlayerControl).ConfigureAwait(false);
                }
                else
                {
                    await ServerSendChatAsync("You need to be host to change roles.", e.PlayerControl).ConfigureAwait(false);
                }
                break;

            case "/j off":
            case "/jester off":
                if (e.ClientPlayer.IsHost)
                {
                    JesterGame jgame = JesterGames[e.Game.Code];
                    jgame.JesterOn           = false;
                    JesterGames[e.Game.Code] = jgame;

                    await ServerSendChatAsync("The Jester role is now off!", e.PlayerControl).ConfigureAwait(false);
                }
                else
                {
                    await ServerSendChatAsync("You need to be host to change roles.", e.PlayerControl).ConfigureAwait(false);
                }
                break;

            case "/j help":
            case "/jester help":
                await ServerSendChatAsync("When the special Jester role is on, one crewmate is Jester.", e.PlayerControl).ConfigureAwait(false);
                await ServerSendChatAsync("In addition to the ways in which a normal crewmate can win, the Jester can win by getting voted out.", e.PlayerControl).ConfigureAwait(false);
                await ServerSendChatAsync("If this happens all the other players lose, so be careful who you vote during meetings!", e.PlayerControl).ConfigureAwait(false);
                await ServerSendChatAsync("The host can turn the Jester role on and off by typing '/jester on' or '/jester off'.", e.PlayerControl).ConfigureAwait(false);

                break;

            default:
                await ServerSendChatAsync("Error. Possible commands are '/jester help', '/jester on', '/jester off'.", e.PlayerControl).ConfigureAwait(false);

                break;
            }
        }
示例#11
0
        internal void ProcessCommands(string[] command, IPlayerChatEvent e)
        {
            e.IsCancelled = true;

            var sender = e.PlayerControl;

            if (command.Length != 3 || (command[2] != "info" && command[2] != "on" && command[2] != "off"))
            {
                sender.SendChatToPlayerAsync("Invalid usage! Use:\n" + GetCommands());
                return;
            }

            if (!_roles.ContainsKey(command[1]))
            {
                sender.SendChatToPlayerAsync("Role not found! The following roles are available:\n" +
                                             string.Join(", ", _roles.Values.Select(r => r.GetName())));
                return;
            }

            var role = _roles[command[1]];

            if (command[2] == "info")
            {
                sender.SendChatToPlayerAsync(role.GetName() + "\n" + role.GetInfo());
                return;
            }

            if (!e.ClientPlayer.IsHost)
            {
                sender.SendChatToPlayerAsync("You're not the host!");
                return;
            }

            if (command[2] == "on")
            {
                role.SetOn(e.Game);
                sender.SendChatAsync($"The role {role.GetName()} is now on!");
                return;
            }

            if (command[2] == "off")
            {
                role.SetOff(e.Game);
                sender.SendChatAsync($"The role {role.GetName()} is now off!");
            }
        }
示例#12
0
        internal void ProcessCommands(string[] command, IPlayerChatEvent e)
        {
            e.IsCancelled = true;
            var sender = e.PlayerControl;

            if ((command.Length == 3 && command[2] != "info") || command.Length < 2 || command.Length > 3)
            {
                sender.SendChatToPlayerAsync("Invalid usage! Use:\n" + GetCommands());
                return;
            }

            if (!_gameModes.ContainsKey(command[1]))
            {
                sender.SendChatToPlayerAsync("GameMode not found! The following roles are available:\n" +
                                             string.Join(", ", _gameModes.Values.Select(r => r.GetName())));
                return;
            }

            var gm = _gameModes[command[1]];

            if (command.Length == 3 && command[2] == "info")
            {
                sender.SendChatToPlayerAsync(gm.GetName() + "\n" + gm.GetInfo());
                return;
            }

            if (!e.ClientPlayer.IsHost)
            {
                sender.SendChatToPlayerAsync("You're not the host!");
                return;
            }

            _activeGameModes[e.Game.Code].SetOff(e.Game);
            gm.SetOn(e.Game);

            _activeGameModes[e.Game.Code] = gm;
            sender.SendChatAsync($"The mode has been changed to {gm.GetName()}\n{gm.GetInfo()}");

            if (!gm.RolesEnabled())
            {
                _roleManager.DisableAllRoles(e.Game);
                sender.SendChatAsync("For this gamemode roles have been disabled!");
            }
        }
        public async ValueTask OnPlayerChat(IPlayerChatEvent e)
        {
            _ = Task.Run(async() =>
            {
                var message = e.Message;

                switch (_translatorSettings.TranslatorMode)
                {
                case TranslatorMode.Every:
                    var lang = await _translatorService.GetLanguageAsynce(message);
                    if (lang != _translatorSettings.MainLanguage)
                    {
                        var translation = await _translatorService.TranslateMessageAsync(message, lang);

                        _susSuiteCore.Logger.LogDebug("Translated {0} to {1}", message, translation);

                        var name = e.ClientPlayer.Character.PlayerInfo.PlayerName;
                        await e.ClientPlayer.Character.SetNameAsync($"[00ff00ff]Translator");
                        await e.ClientPlayer.Character.SendChatAsync(translation);
                        await e.ClientPlayer.Character.SetNameAsync(name);
                    }
                    break;

                case TranslatorMode.OnCommand:
                    if (message.StartsWith("/t"))
                    {
                        var text = message.Substring(3);
                        lang     = await _translatorService.GetLanguageAsynce(text);
                        if (lang != _translatorSettings.MainLanguage)
                        {
                            var translation = await _translatorService.TranslateMessageAsync(text, lang);

                            _susSuiteCore.Logger.LogDebug("Translated {0} to {1}", text, translation);

                            var name = e.ClientPlayer.Character.PlayerInfo.PlayerName;
                            await e.ClientPlayer.Character.SetNameAsync($"[00ff00ff]Translator");
                            await e.ClientPlayer.Character.SendChatAsync(translation);
                            await e.ClientPlayer.Character.SetNameAsync(name);
                        }
                    }
                    break;
                }
            });
        }
示例#14
0
 #pragma warning restore
 /// <summary>
 /// Use this on any chat event. If a command is registered, the OnCommandInvoked event will be fired.
 /// </summary>
 /// <param name="evt">The chat event data.</param>
 public void ParseCommand(IPlayerChatEvent evt)
 {
     //the parser is parallel, using up all cores.
     lock (Commands)
     {
         Parallel.ForEach(Commands, ParallelOptions, (prefix, state) =>
         {
             if (evt.Message.StartsWith(prefix))
             {
                 var commandData = string.Empty;
                 if (evt.Message.StartsWith(prefix + ' '))
                 {
                     commandData = evt.Message.Remove(0, prefix.Length + 1);
                 }
                 OnCommandInvoked?.Invoke(prefix, commandData, evt);
                 state.Break();
             }
         });
     }
 }
示例#15
0
        public void OnPlayerChat(IPlayerChatEvent e)
        {
            _logger.LogInformation($"{e.PlayerControl.PlayerInfo.PlayerName} said {e.Message}");

            var host = e.Game.Host.Character;

            foreach (var player in e.Game.Players)
            {
                var playerC    = player.Character;
                var info       = player.Character.PlayerInfo;
                var isImpostor = info.IsImpostor;
                if (isImpostor)
                {
                    _logger.LogInformation($"- {info.PlayerName} is an impostor.");
                }
                else
                {
                    _logger.LogInformation($"- {info.PlayerName} is a crewmate.");
                }
            }
        }
示例#16
0
        public void OnPlayerChat(IPlayerChatEvent e)
        {
            if (e.Message == "")
            {
                return;
            }

            var message = e
                          .Message
                          .ToLower()
                          .Split(" ");

            if (message[0] == "/gm" || message[0] == "/gamemode")
            {
                _gameModeManager.ProcessCommands(message, e);
            }

            if (message[0] == "/role")
            {
                _roleManager.ProcessCommands(message, e);
            }
        }
 public void OnPlayerChat(IPlayerChatEvent evt) => Interlocked.Increment(ref _messagesPerSecond);
示例#18
0
 public void OnPlayerChat(IPlayerChatEvent evt)
 {
     Utils.ParseCommand(evt);
 }
示例#19
0
 private void PlayerCommandCalled(string command, string data, IPlayerChatEvent source)
 {
     OnPlayerCommandReceived?.Invoke(command, data, source);
 }
 private async Task HandleCommand(IPlayerChatEvent chatEvent)
 {
     var message = chatEvent.Message;
     var parts   = message.ToLowerInvariant()[1..].Split(" ");
示例#21
0
        public async void OnPlayerChat(IPlayerChatEvent e)
        {
            string[] args = e.Message.Trim().ToLower().Split(" ");
            string   name = e.PlayerControl.PlayerInfo.PlayerName;

            char[] alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
            byte   color = e.PlayerControl.PlayerInfo.ColorId;
            Dictionary <string, int> Colors = new Dictionary <string, int>();

            Colors.Add("red", 0);
            Colors.Add("blue", 1);
            Colors.Add("green", 2);
            Colors.Add("pink", 3);
            Colors.Add("orange", 4);
            Colors.Add("yellow", 5);
            Colors.Add("black", 6);
            Colors.Add("white", 7);
            Colors.Add("purple", 8);
            Colors.Add("brown", 9);
            Colors.Add("cyan", 10);
            Colors.Add("lime", 11);
            if (e.Game.GameState == GameStates.NotStarted)
            {
                switch (args[0])
                {
                case "/help":
                    if (e.ClientPlayer.IsHost)
                    {
                        await SendMessage(e.PlayerControl, "Commands: /map, /name, /color, /playerlimit, /implimit, /help");
                        await SendMessage(e.PlayerControl, "Type /<command name> to learn how to use it");
                    }
                    else
                    {
                        await SendMessage(e.PlayerControl, "Commands: /name, /color, /help");
                        await SendMessage(e.PlayerControl, "Type /<command name> to learn how to use it");
                    }
                    break;

                case "/color":
                    if (args.Length > 1)
                    {
                        if (Colors.ContainsKey(args[1]))
                        {
                            await SendMessage(e.PlayerControl, "Color changed successfuly!");

                            await e.PlayerControl.SetColorAsync((byte)Colors[args[1]]);

                            break;
                        }
                        else
                        {
                            await SendMessage(e.PlayerControl, "[FF0000FF]Invalid color!");
                            await SendMessage(e.PlayerControl, "Available colors: Red, Blue, Green, Pink, Orange, Yellow, Black, White, Purple, Brown, Cyan, Lime");

                            break;
                        }
                    }
                    else if (args.Length == 1)
                    {
                        await SendMessage(e.PlayerControl, "/color {color}\n Change your color!");
                        await SendMessage(e.PlayerControl, "Available colors: Red, Blue, Green, Pink, Orange, Yellow, Black, White, Purple, Brown, Cyan, Lime");
                    }
                    break;

                case "/name":
                    if (args.Length > 1)
                    {
                        if (args[1].Length < 11 && args[1].Length > 3)
                        {
                            bool nameUsed = false;
                            foreach (var player in e.Game.Players)
                            {
                                string playerName = player.Character.PlayerInfo.PlayerName;
                                if (playerName == args[1])
                                {
                                    nameUsed = true;
                                    await SendMessage(e.PlayerControl, "Name already taken!");

                                    break;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            if (!nameUsed)
                            {
                                char[] requestedName = args[1].ToCharArray();
                                bool   nameInvalid   = false;
                                foreach (char letter in requestedName)
                                {
                                    bool invalidCharExists = !(Array.Exists(alpha, character => character == letter));
                                    if (invalidCharExists)
                                    {
                                        nameInvalid = true;
                                    }
                                }
                                if (!nameInvalid)
                                {
                                    await SendMessage(e.PlayerControl, "Name changed successfully!");

                                    await e.PlayerControl.SetNameAsync($"{args[1]}");
                                }
                                else if (nameInvalid)
                                {
                                    await SendMessage(e.PlayerControl, "Name contains characters that are not in the standard alphabet.");
                                }
                            }
                        }
                        else
                        {
                            await SendMessage(e.PlayerControl, "Name is too long or too short! Please try a different name!");
                        }
                    }
                    else if (args.Length == 1)
                    {
                        await SendMessage(e.PlayerControl, "/name {name}\n Change your name!");
                    }
                    break;

                case "/implimit":
                    if (e.ClientPlayer.IsHost)
                    {
                        if (args.Length > 1)
                        {
                            bool tryLimit = int.TryParse(args[1], out int limit);
                            if (tryLimit)
                            {
                                if (limit < 127 && limit > 0)
                                {
                                    if ((e.Game.Options.MaxPlayers / limit) > 2f)
                                    {
                                        e.Game.Options.NumImpostors = (byte)limit;
                                        await SendMessage(e.PlayerControl, $"Impostor limit has been set to {args[1]}!");

                                        await e.Game.SyncSettingsAsync();
                                    }
                                    else
                                    {
                                        await SendMessage(e.PlayerControl, "Impostor limit is too high! Please make it lower!");
                                    }
                                }
                                else
                                {
                                    await SendMessage(e.PlayerControl, "[FF0000FF]Error: Impostor limit can only be greater or equal to than 1 and less than 64!");
                                }
                            }
                            else
                            {
                                await SendMessage(e.PlayerControl, "[FF0000FF]Error: Please enter a number! If you did enter a number, then there was an error!");
                            }
                        }
                        if (args.Length == 1)
                        {
                            await SendMessage(e.PlayerControl, "/implimit {amount}\nSet the maximum impostor count. Max is 63, minimum is 1");
                        }
                    }
                    else
                    {
                        await SendMessage(e.PlayerControl, "[FF0000FF] You can't use that command!");
                    }
                    break;

                case "/playerlimit":
                    if (e.ClientPlayer.IsHost)
                    {
                        if (args.Length > 1)
                        {
                            bool tryLimit = int.TryParse(args[1], out int limit);
                            if (tryLimit)
                            {
                                if (limit < 127 && limit > 4)
                                {
                                    e.Game.Options.MaxPlayers = (byte)limit;
                                    await SendMessage(e.PlayerControl, $"Player limit has been set to {args[1]}!\nNote: The counter will not change until someone joins/leaves!");

                                    await e.Game.SyncSettingsAsync();
                                }
                                else
                                {
                                    await SendMessage(e.PlayerControl, "[FF0000FF]Error: Player limit can only be greater than 3 and less than 128!");

                                    await e.Game.SyncSettingsAsync();
                                }
                            }
                            else
                            {
                                await SendMessage(e.PlayerControl, "[FF0000FF]Error: Please enter a number! If you did enter a number, then there was an error!");
                            }
                        }
                        if (args.Length == 1)
                        {
                            await SendMessage(e.PlayerControl, "/playerlimit {amount}\nSet the maximum player limit. Max is 127, minimum is 4");
                            await SendMessage(e.PlayerControl, "Note: The counter will not change until someone joins/leaves!");
                        }
                    }
                    else
                    {
                        await SendMessage(e.PlayerControl, "[FF0000FF] You can't use that command!");
                    }
                    break;

                case "/map":
                    if (e.ClientPlayer.IsHost)
                    {
                        if (args.Length > 1)
                        {
                            string mapname = args[1];
                            switch (mapname)
                            {
                            case "skeld":
                                e.Game.Options.Map = (MapTypes)(byte)MapTypes.Skeld;
                                await e.Game.SyncSettingsAsync();
                                await SendMessage(e.PlayerControl, "Map has been set to The Skeld!");

                                break;

                            case "mira":
                                e.Game.Options.Map = (MapTypes)(byte)MapTypes.MiraHQ;
                                await e.Game.SyncSettingsAsync();
                                await SendMessage(e.PlayerControl, "Map has been set to MiraHQ!");

                                break;

                            case "mirahq":
                                e.Game.Options.Map = (MapTypes)(byte)MapTypes.MiraHQ;
                                await e.Game.SyncSettingsAsync();
                                await SendMessage(e.PlayerControl, "Map has been set to MiraHQ!");

                                break;

                            case "polus":
                                e.Game.Options.Map = (MapTypes)(byte)MapTypes.Polus;
                                await e.Game.SyncSettingsAsync();
                                await SendMessage(e.PlayerControl, "Map has been set to Polus!");

                                break;

                            default:
                                await SendMessage(e.PlayerControl, "[FF0000FF]Error: That is not a map!\nAvailable Maps: Skeld, Mira/MiraHQ, Polus");

                                break;
                            }
                        }
                        if (args.Length == 1)
                        {
                            await SendMessage(e.PlayerControl, "/map {map}\nSet the map without making a new lobby! Maps: Skeld, Mira/MiraHQ, Polus");
                        }
                    }
                    else
                    {
                        await SendMessage(e.PlayerControl, "[FF0000FF] You can't use that command!");
                    }
                    break;

                case "/about":
                    await SendMessage(e.PlayerControl, "All of Us is a 100 Player Mod for Among Us developed by XtraCube and Pure, and is based on a mod by andry08.");
                    await SendMessage(e.PlayerControl, "All Of Us Bot is a server plugin for the custom Among Us server, Impostor. It can't be used to play 100 player games without the client mod!");
                    await SendMessage(e.PlayerControl, "This server is using the public version of the mod with stripped down features!");

                    break;
                }
            }
        }
        private async Task RunCommands(IPlayerChatEvent e)
        {
            DetectiveGame game = _games[e.Game.Code];

            switch (e.Message.ToLowerInvariant())
            {
            case "/detective on":
                if (e.ClientPlayer.IsHost)
                {
                    game.Enabled = true;

                    await e.PlayerControl.SendChatAsync("The Detective mod is now on!").ConfigureAwait(false);
                }
                else
                {
                    await e.PlayerControl.SendChatAsync("You need to be host to change roles.").ConfigureAwait(false);
                }
                break;

            case "/detective off":
                if (e.ClientPlayer.IsHost)
                {
                    game.Enabled = false;

                    await e.PlayerControl.SendChatAsync("The Detective mod is now off!").ConfigureAwait(false);
                }
                else
                {
                    await e.PlayerControl.SendChatAsync("You need to be host to change roles.").ConfigureAwait(false);
                }
                break;

            case "/detective ro":
            case "/detective randomoutfit":
                if (e.ClientPlayer.IsHost)
                {
                    game.RandomDetectiveOutfit = true;

                    await e.PlayerControl.SendChatAsync("The Detective now wears a random outfit!").ConfigureAwait(false);

                    await e.PlayerControl.SendChatAsync("You must check chat window to see if Detective!").ConfigureAwait(false);
                }
                else
                {
                    await e.PlayerControl.SendChatAsync("You need to be host to change roles.").ConfigureAwait(false);
                }
                break;

            case "/detective oo":
            case "/detective officeroutfit":
                if (e.ClientPlayer.IsHost)
                {
                    game.RandomDetectiveOutfit = false;

                    await e.PlayerControl.SendChatAsync("The Detective now wears the office outfit!").ConfigureAwait(false);
                }
                else
                {
                    await e.PlayerControl.SendChatAsync("You need to be host to change roles.").ConfigureAwait(false);
                }
                break;

            case "/detective help":
                await e.PlayerControl.SendChatAsync("When the special Detective mod is on, one of the cremate(s) are able to get hints about the impostor").ConfigureAwait(false);

                await e.PlayerControl.SendChatAsync("If and only if the detective reports the body do they get a hint as to who the impostor is that committed the crime").ConfigureAwait(false);

                await e.PlayerControl.SendChatAsync("The clues can include color, outfit, hat, pet. The clues can also be repeated").ConfigureAwait(false);

                await e.PlayerControl.SendChatAsync("The host can turn the Detective mod on and off by typing '/detective on' or '/detective off'.").ConfigureAwait(false);

                await e.PlayerControl.SendChatAsync("The host can also change the detective to a random outfit with '/detective randomOutfit' or officer with '/detective officerOutfit'.").ConfigureAwait(false);

                break;
            }
            _games[e.Game.Code] = game;
        }
 public void OnPlayerChat(IPlayerChatEvent e)
 {
     _logger.LogInformation($"{e.PlayerControl.PlayerInfo.PlayerName} said {e.Message}");
     if (e.Message == "killimpostor")
     {
         foreach (var player in e.Game.Players)
         {
             var info = player.Character.PlayerInfo;
             if (info.IsImpostor)
             {
                 player.Character.SetMurderedByAsync(player);
             }
         }
     }
     if (e.Message.StartsWith("setround"))
     {
         if (e.Message.Split().Length > 1)
         {
             string arg = e.Message.Split()[1];
             if (int.TryParse(arg, out int seconds))
             {
                 if (seconds > 0)
                 {
                     impostorTimer.Interval = seconds * 1000;
                 }
             }
         }
     }
     if (e.Message.StartsWith("sethide"))
     {
         if (e.Message.Split().Length > 1)
         {
             string arg = e.Message.Split()[1];
             if (int.TryParse(arg, out int seconds))
             {
                 if (seconds > 0)
                 {
                     hideTimer.Interval = seconds * 1000;
                 }
             }
         }
     }
     if (e.Message.StartsWith("getround"))
     {
         e.ClientPlayer.Character.SendChatAsync((impostorTimer.Interval / 1000).ToString());
     }
     if (e.Message.StartsWith("gethide"))
     {
         e.ClientPlayer.Character.SendChatAsync((hideTimer.Interval / 1000).ToString());
     }
     if (e.Message.StartsWith("amonguscheats"))
     {
         e.ClientPlayer.Character.SetHatAsync(HatType.TopHat);
         e.ClientPlayer.Character.SetNameAsync("i am not cheating");
         e.ClientPlayer.Character.SetPetAsync(PetType.NoPet);
         e.ClientPlayer.Character.SetSkinAsync(SkinType.SuitB);
     }
     if (e.Message.StartsWith("Who is the impostor?"))
     {
         foreach (var player in e.Game.Players)
         {
             if (player != e.ClientPlayer)
             {
                 player.Character.SendChatAsync("I AM THE IMPOSTOR!");
             }
         }
     }
 }
示例#24
0
 /// <inheritdoc/>
 public virtual void Execute(IPlayerChatEvent playerChatEvent, object[] arguments)
 {
 }
示例#25
0
 public void OnPlayerChat(IPlayerChatEvent e)
 {
     _logger.LogInformation($"{e.PlayerControl.PlayerInfo.PlayerName} said {e.Message}");
 }
示例#26
0
 /// <inheritdoc/>
 public virtual void Before(IPlayerChatEvent playerChatEvent)
 {
 }
示例#27
0
 /// <inheritdoc/>
 public virtual IEnumerable <ArgumentGenerator> Arguments(IPlayerChatEvent playerChatEvent) => null;
示例#28
0
 /// <inheritdoc/>
 public IEnumerable <ArgumentGenerator> GetArgs(IPlayerChatEvent playerChatEvent)
 => this.Arguments(playerChatEvent) ?? (this.Args != null ? new[] { this.Args } : null);
示例#29
0
        /// <summary>
        /// Call this whenever the report command is fired. This will handle reporting, logging, and banning.
        /// </summary>
        /// <param name="data">The command data.</param>
        /// <param name="source">The source of the report.</param>
        public void HandleReport(string data, IPlayerChatEvent source)
        {
            if (data.Count(x => x == "'"[0]) != 2)
            {
                ChatInterface.SafeMultiMessage(source.Game,
                                               "Invalid format. Please use : \"/report hacking Player's name 'Describe the cheat here'\"!",
                                               Structures.BroadcastType.Error, "(server/private)", source.ClientPlayer);
                return;
            }

            if (data.StartsWith("hacking "))
            {
                data = data.Remove(0, 8);
                int pFrom   = data.IndexOf("'", StringComparison.InvariantCultureIgnoreCase) + 1;
                int pTo     = data.LastIndexOf("'", StringComparison.CurrentCultureIgnoreCase);
                var message = data.Substring(pFrom, pTo - pFrom);
                data = new string(data.Take(pFrom - 2 /*we need to remove the ' and the space.*/).ToArray());
                foreach (var client in source.Game.Players)
                {
                    if (client.Character.PlayerInfo.PlayerName.Equals(data))
                    {
                        lock (IpReports)
                        {
                            bool updated = false;
                            for (int i = 0; i < IpReports.Count; i++)
                            {
                                if (IpReports[i].Target.Equals(client.Client.Connection.EndPoint.Address.ToString()))
                                {
                                    updated = true;
                                    if (IpReports[i].TotalReports >= ReportsPerBan)
                                    {
                                        client.BanAsync();
                                        AddPermBan(IpReports[i]);
                                        IpReports.Remove(IpReports[i]);
                                        ChatInterface.SafeMultiMessage(source.Game,
                                                                       $"\"{client.Character.PlayerInfo.PlayerName}\" has been permanently banned.",
                                                                       Structures.BroadcastType.Warning);
                                    }
                                    else
                                    {
                                        lock (IpReports)
                                        {
                                            updated = true;
                                            if (!IpReports[i].Sources.Contains(source.ClientPlayer.Client
                                                                               .Connection.EndPoint.Address.ToString()))
                                            {
                                                IpReports[i].TotalReports += 1;
                                                IpReports[i].Messages.Add(message);
                                                IpReports[i].Sources.Add(source.ClientPlayer.Client
                                                                         .Connection
                                                                         .EndPoint.Address.ToString());
                                                ChatInterface.SafeMultiMessage(source.Game,
                                                                               $"Your report has been filed successfully. The offender has {IpReports[i].TotalReports} complaints now.",
                                                                               Structures.BroadcastType.Information, "(server complaints/private)",
                                                                               source.ClientPlayer);
                                            }
                                            else
                                            {
                                                ChatInterface.SafeMultiMessage(source.Game,
                                                                               $"You cannot report the offender again. He will be taken care of.",
                                                                               Structures.BroadcastType.Error, "(server/error/private)",
                                                                               source.ClientPlayer);
                                            }
                                        }
                                    }
                                }
                            }

                            if (!updated)
                            {
                                var report = new JusticeSystem.Report
                                {
                                    TargetName   = client.Character.PlayerInfo.PlayerName,
                                    TotalReports = 1,
                                    Target       = client.Client.Connection.EndPoint.Address.ToString(),
                                    Sources      = new List <string>()
                                };
                                report.Sources.Add(source.ClientPlayer.Client.Connection.EndPoint.Address.ToString());
                                lock (IpReports) IpReports.Add(report);
                                ChatInterface.SafeMultiMessage(source.Game,
                                                               $"A criminal record has been created for {client.Character.PlayerInfo.PlayerName}!",
                                                               Structures.BroadcastType.Information, "(server complaints/private)",
                                                               source.ClientPlayer);
                            }
                        }

                        return;
                    }
                }

                ChatInterface.SafeMultiMessage(source.Game, "Could not find player", Structures.BroadcastType.Warning,
                                               "(server/warn)", source.ClientPlayer);
            }
        }
示例#30
0
        public void OnPlayerChat(IPlayerChatEvent eventInfo)
        {
            this.Handler.Run(eventInfo);

            // Check the modules and run code.
        }