Example #1
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (!cmd.Sender.IsBroadcaster || !cmd.Sender.DisplayName.ToLower().Equals("zerratar"))
            {
                return;
            }

            if (string.IsNullOrEmpty(cmd.Arguments))
            {
                return;
            }

            var values = cmd.Arguments.Split(' ');

            if (values.Length <= 1)
            {
                return;
            }

            var player = playerProvider.Get(values[0], values[1]);
            await game.JoinAsync(player);
        }
Example #2
0
 public ChatService(IChatEntryRepository iChatEntryRepository, IMessageBroadcaster iMessageBroadcaster, IChatRoomManager iChatRoomManager, IMapper iMapper)
 {
     this.iChatEntryRepository = iChatEntryRepository;
     this.iMessageBroadcaster  = iMessageBroadcaster;
     this.iChatRoomManager     = iChatRoomManager;
     this.iMapper = iMapper;
 }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }


            if (string.IsNullOrEmpty(cmd.Arguments) || !cmd.Arguments.Trim().Contains(" "))
            {
                broadcaster.Send(cmd.Sender.Username, cmd.Command + " <item> (optional: <amount>, default 1) <price per item>");
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (cmd.Command.Equals("sell", StringComparison.OrdinalIgnoreCase))
            {
                await this.game.SellItemAsync(player, cmd.Arguments);
            }
            else if (cmd.Command.Equals("buy", StringComparison.OrdinalIgnoreCase))
            {
                await this.game.BuyItemAsync(player, cmd.Arguments);
            }
        }
Example #4
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 //broadcaster.Broadcast(
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (!cmd.Sender.IsBroadcaster)
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 "You do not have permission to kick a player from the game.");
                return;
            }

            var item = cmd.Arguments?.Trim();

            if (string.IsNullOrEmpty(item))
            {
                return;
            }

            var player = playerProvider.Get(cmd.Sender);
            await game.ItemDropEventAsync(player, item);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (cmd.Command.StartsWith("disembark"))
            {
                await game.DisembarkFerryAsync(player);

                return;
            }

            var destination = cmd.Arguments?.ToLower();

            if (string.IsNullOrEmpty(destination))
            {
                await game.EmbarkFerryAsync(player);

                return;
            }

            if (destination.StartsWith("stop"))
            {
                await game.DisembarkFerryAsync(player);

                return;
            }

            await game.TravelAsync(player, destination);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (string.IsNullOrEmpty(cmd.Arguments))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 "You need to specify what to toggle, like: helm or pet");
                return;
            }

            if (cmd.Arguments.Contains("helm", StringComparison.OrdinalIgnoreCase))
            {
                var player = playerProvider.Get(cmd.Sender);
                await game.ToggleHelmetAsync(player);
            }
            else if (cmd.Arguments.Contains("pet", StringComparison.OrdinalIgnoreCase))
            {
                var player = playerProvider.Get(cmd.Sender);
                await game.TogglePetAsync(player);
            }
            else
            {
                broadcaster.Send(cmd.Sender.Username, cmd.Arguments + " cannot be toggled.");
            }
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 //broadcaster.Broadcast(
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 "You do not have permission to kick a player from the game.");
                return;
            }

            var targetPlayerName = cmd.Arguments?.Trim();

            if (string.IsNullOrEmpty(targetPlayerName))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 "You are kicking who? Provide a username");
                return;
            }

            var targetPlayer = playerProvider.Get(targetPlayerName);
            await game.KickAsync(targetPlayer);
        }
 public async Task HandleAsync(IMessageBroadcaster listener, ICommand cmd)
 {
     if (commands.TryGetValue(cmd.Command, out var processor))
     {
         Console.WriteLine($"Command received: {cmd.Command} from {cmd.Sender} with args: {cmd.Arguments}");
         await processor.ProcessAsync(listener, cmd);
     }
 }
Example #9
0
        public ModuleMain(ILoggerProvider loggerProvider, IMessageBroadcaster messageBroadcaster, IWorld world)
        {
            _logger             = loggerProvider.GetLogger("CoreModule");
            _messageBroadcaster = messageBroadcaster;
            _world = world;

            _logger.LogInformation("CoreModule was loaded!");
        }
Example #10
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(ServerPort))
            {
                //broadcaster.Broadcast(
                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);


            if (GetCombatTypeFromString(cmd.Command) != -1)
            {
                await game.SendPlayerTaskAsync(player, PlayerTask.Fighting, cmd.Command);

                return;
            }

            var commandSkillTarget = GetSkillTypeFromString(cmd.Command);

            if (commandSkillTarget != -1)
            {
                await game.SendPlayerTaskAsync(player, (PlayerTask)commandSkillTarget, cmd.Command);

                return;
            }

            var arg   = cmd.Arguments?.ToLower();
            var skill = arg?.Split(' ').LastOrDefault();

            if (string.IsNullOrEmpty(skill))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 $"You need to specify a skill to train, currently supported skills: " + string.Join(", ", trainableSkills));
                return;
            }

            if (GetCombatTypeFromString(skill) != -1)
            {
                await game.SendPlayerTaskAsync(player, PlayerTask.Fighting, skill);
            }
            else
            {
                var value = GetSkillTypeFromString(skill);
                if (value == -1)
                {
                    //broadcaster.Broadcast(
                    broadcaster.Send(cmd.Sender.Username,
                                     $"You cannot train '{skill}'.");
                }
                else
                {
                    await game.SendPlayerTaskAsync(player, (PlayerTask)value, skill);
                }
            }
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var arg = cmd.Arguments?.ToLower();

            if (string.IsNullOrEmpty(arg))
            {
                return;
            }

            if (arg.StartsWith("help"))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 "The commands are available in the panels below the stream :-) Too many commands.");
                return;
            }

            if (arg.StartsWith("join"))
            {
                var player = playerProvider.Get(cmd.Sender);
                await game.JoinAsync(player);
            }

            if (arg.StartsWith("task"))
            {
                var player = playerProvider.Get(cmd.Sender);
                var task   = arg.Split(' ').LastOrDefault();

                var availableTasks = Enum.GetValues(typeof(PlayerTask))
                                     .Cast <PlayerTask>()
                                     .ToList();

                if (string.IsNullOrEmpty(task))
                {
                    //broadcaster.Broadcast(

                    broadcaster.Send(cmd.Sender.Username,
                                     $"You need to specify a task, currently supported tasks: {string.Join(", ", availableTasks.Select(x => x.ToString()))}");
                    return;
                }

                var targetTask = availableTasks.FirstOrDefault(x =>
                                                               x.ToString().Equals(task, StringComparison.InvariantCultureIgnoreCase));

                await game.SendPlayerTaskAsync(player, targetTask);
            }
        }
Example #12
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);
            await game.PlayerCountAsync(player);
        }
Example #13
0
        public override Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (cmd.Arguments == null || cmd.Arguments.Length == 0)
            {
                broadcaster.Broadcast("Ravenfall is a Twitch idle game where you can train, craft, fight together against huge raid bosses or fight against eachother.");
            }
            else if (cmd.Arguments.Contains("help", System.StringComparison.OrdinalIgnoreCase))
            {
                broadcaster.Broadcast("Please see https://www.ravenfall.stream/how-to-play on how to play Ravenfall. This guide is still being updated so make sure to check it out frequently.");
            }

            return(Task.CompletedTask);
        }
Example #14
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }
            var player = playerProvider.Get(cmd.Sender);
            var skill  = cmd.Arguments;

            await this.game.RequestHighestSkillAsync(player, skill);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 //broadcaster.Broadcast(
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator && !cmd.Sender.IsSubscriber)
            {
                //broadcaster.Broadcast(
                broadcaster.Send(cmd.Sender.Username,
                                 "You do not have permission to set the currently observed player.");
                return;
            }
            var isSubscriber = cmd.Sender.IsSubscriber && !cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator;

            if (isSubscriber)
            {
                var user    = userStore.Get(cmd.Sender.Username);
                var command = nameof(ObserveCommandProcessor);
                if (!user.CanUseCommand(command))
                {
                    var timeLeft = user.GetCooldown(command);
                    broadcaster.Broadcast($"{cmd.Sender.Username}, You must wait another {Math.Floor(timeLeft.TotalSeconds)} secs to use that command.");
                    return;
                }

                user.UseCommand(command, TimeSpan.FromSeconds(120));
            }

            var targetPlayerName = cmd.Arguments?.Trim();

            Models.Player player = null;
            if (!string.IsNullOrEmpty(targetPlayerName))
            {
                player = playerProvider.Get(targetPlayerName);
            }
            else
            {
                player = playerProvider.Get(cmd.Sender);
            }

            await game.ObservePlayerAsync(player);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (string.IsNullOrEmpty(cmd.Arguments))
            {
                await this.game.JoinDungeonAsync(player);

                return;
            }

            if (!string.IsNullOrEmpty(cmd.Arguments))
            {
                if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator && !cmd.Sender.IsSubscriber)
                {
                    broadcaster.Send(cmd.Sender.Username, Localization.PERMISSION_DENIED);
                    return;
                }

                //if (cmd.Arguments.Contains("start", StringComparison.OrdinalIgnoreCase))
                //{
                //    var isSubscriber = cmd.Sender.IsSubscriber && !cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator;
                //    if (isSubscriber)
                //    {
                //        var user = userStore.Get(cmd.Sender.Username);
                //        var command = nameof(RaidCommandProcessor);
                //        if (!user.CanUseCommand(command))
                //        {
                //            var timeLeft = user.GetCooldown(command);
                //            broadcaster.Broadcast($"{cmd.Sender.Username}, You must wait another {Math.Floor(timeLeft.TotalSeconds)} secs to use that command.");
                //            return;
                //        }
                //        user.UseCommand(command, TimeSpan.FromHours(1));
                //    }

                //    await this.game.RaidStartAsync(player);
                //    return;
                //}
            }
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (player == null)
            {
                broadcaster.Send(cmd.Sender.Username, "Uh oh, bug when trying to leave :(");
            }

            await game.LeaveAsync(player);
        }
Example #18
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username, Localization.GAME_NOT_STARTED);
                return;
            }

            var player      = playerProvider.Get(cmd.Sender);
            var destination = cmd.Arguments?.ToLower();

            if (string.IsNullOrEmpty(destination))
            {
                broadcaster.Send(cmd.Sender.Username, "You must specify a destination, !travel <destination>");
                return;
            }

            await game.TravelAsync(player, destination);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (string.IsNullOrEmpty(cmd.Arguments) || !cmd.Arguments.Trim().Contains(" "))
            {
                broadcaster.Send(cmd.Sender.Username, cmd.Command + " <playername> <item> (optional: <amount>, default 1)");
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            await this.game.GiftItemAsync(player, cmd.Arguments);
        }
Example #20
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            if (string.IsNullOrEmpty(cmd.Arguments))
            {
                broadcaster.Send(cmd.Sender.Username, cmd.Command + "<item>");
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            await this.game.ValueItemAsync(player, cmd.Arguments);
        }
Example #21
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var numOfSubs = 1;

            if (!string.IsNullOrEmpty(cmd.Arguments))
            {
                int.TryParse(cmd.Arguments, out numOfSubs);
            }

            var player = playerProvider.Get(cmd.Sender);
            await game.SetExpMultiplierAsync(player, numOfSubs);
        }
Example #22
0
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (string.IsNullOrEmpty(cmd.Arguments))
            {
                broadcaster.Broadcast("You can customize your character here https://www.ravenfall.stream/customization");
                return;
            }

            await this.game.PlayerAppearanceUpdateAsync(player, cmd.Arguments);
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                //broadcaster.Broadcast(

                broadcaster.Send(cmd.Sender.Username,
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var sub = cmd.Arguments?.Trim();

            if (string.IsNullOrEmpty(sub))
            {
                //broadcaster.Broadcast(
                broadcaster.Send(cmd.Sender.Username,
                                 "To duel a player you need to specify their name. ex: '!duel JohnDoe', to accept or decline a duel request use '!duel accept' or '!duel decline'. You may also cancel an ongoing request by using '!duel cancel'");
                return;
            }

            var player = playerProvider.Get(cmd.Sender);

            if (sub.Equals("cancel", StringComparison.InvariantCultureIgnoreCase))
            {
                await this.game.CancelDuelRequestAsync(player);
            }
            else if (sub.Equals("accept", StringComparison.InvariantCultureIgnoreCase))
            {
                await this.game.AcceptDuelRequestAsync(player);
            }
            else if (sub.Equals("decline", StringComparison.InvariantCultureIgnoreCase))
            {
                await this.game.DeclineDuelRequestAsync(player);
            }
            else
            {
                await this.game.DuelRequestAsync(player, playerProvider.Get(sub));
            }
        }
        public Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            //if (string.IsNullOrEmpty(cmd.Arguments))
            //{
            //    return Task.CompletedTask;
            //}

            var command = cmd.Arguments.Trim().ToLower();
            if (command.StartsWith("add"))
            {
                if (!cmd.Sender.IsModerator && !cmd.Sender.IsBroadcaster)
                {
                    broadcaster.Send(cmd.Sender.Username,
                    //broadcaster.Broadcast(
                        "Sorry, this command is restricted to mods and broadcaster.");
                    return Task.CompletedTask;
                }

                var data = command.Split(' ');
                if (data.Length <= 1)
                {
                    broadcaster.Broadcast("Insufficient parameters, use: !credits add <user> <amount>");
                    return Task.CompletedTask;
                }

                var name = data[1];
                var amountStr = data[2];
                if (int.TryParse(amountStr, out var val))
                {
                    var user = this.userStore.Get(name);
                    user.AddCredits(val);
                    broadcaster.Broadcast($"{val} credits was added to {name}'s stash.");
                }
            }
            else if (command.StartsWith("remove"))
            {
                if (!cmd.Sender.IsModerator && !cmd.Sender.IsBroadcaster)
                {
                    //broadcaster.Broadcast(
                    broadcaster.Send(cmd.Sender.Username,
                        "Sorry, this command is restricted to mods and broadcaster.");
                    return Task.CompletedTask;
                }

                var data = command.Split(' ');
                if (data.Length <= 1)
                {
                    broadcaster.Broadcast("Insufficient parameters, use: !credits remove <user> <amount>");
                    return Task.CompletedTask;
                }
                var name = data[1];
                var amountStr = data[2];
                if (int.TryParse(amountStr, out var val))
                {
                    var user = this.userStore.Get(name);
                    user.RemoveCredits(val);
                    broadcaster.Broadcast($"{val} credits was removed from {name}'s stash.");
                }
            }
            else
            {
                var user = this.userStore.Get(cmd.Sender.Username);
                broadcaster.Send(cmd.Sender.Username,
                //broadcaster.Broadcast(
                    $"{cmd.Sender.Username}, you have {user.Credits} credits left.");
            }
            return Task.CompletedTask;
        }
Example #25
0
 public abstract Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd);
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Send(cmd.Sender.Username,
                                 //broadcaster.Broadcast(
                                 Localization.GAME_NOT_STARTED);
                return;
            }

            var query = cmd.Arguments?.Trim();
            //var categories = Enum.GetNames(typeof(CraftableCategory));
            ////var types = Enum.GetNames(typeof(ItemType));
            //if (string.IsNullOrEmpty(query))
            //{
            //    //broadcaster.Broadcast(
            //    broadcaster.Send(cmd.Sender.Username,
            //        $"You must specify an item or category to craft. Currently supported item categories: {string.Join(", ", categories)}");
            //    return;
            //}

            var player = playerProvider.Get(cmd.Sender);
            await game.CraftAsync(player, query);

            // !craft weapon
            // !craft amulet
            // !craft helm
            // !craft chest

            //var types = categoryAndType.Split(" ");

            //if (categories.Any(x => x.Equals(categoryAndType, StringComparison.InvariantCultureIgnoreCase))
            //    /*types.Any(x => x.Equals(categoryAndType, StringComparison.InvariantCultureIgnoreCase))*/)
            //{
            //    var player = playerProvider.Get(cmd.Sender);
            //    if (Enum.TryParse(typeof(CraftableCategory), categoryAndType, true, out var item))
            //    {
            //        var category = ItemCategory.Weapon;
            //        switch ((CraftableCategory)item)
            //        {
            //            case CraftableCategory.Weapon:
            //                category = ItemCategory.Weapon;
            //                break;

            //            case CraftableCategory.Armor:
            //            case CraftableCategory.Helm:
            //            case CraftableCategory.Chest:
            //            case CraftableCategory.Gloves:
            //            case CraftableCategory.Leggings:
            //            case CraftableCategory.Boots:
            //                category = ItemCategory.Armor;
            //                break;

            //            case CraftableCategory.Ring:
            //                category = ItemCategory.Ring;
            //                break;

            //            case CraftableCategory.Amulet:
            //                category = ItemCategory.Amulet;
            //                break;
            //        }

            //        await game.CraftAsync(player, category.ToString(), categoryAndType);
            //        return;
            //    }
            //    else if (Enum.TryParse(typeof(ItemCategory), categoryAndType, true, out var weapon))
            //    {
            //        await game.CraftAsync(player, categoryAndType, "");
            //        return;
            //    }
            //}
        }
        public override async Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            if (!await this.game.ProcessAsync(Settings.UNITY_SERVER_PORT))
            {
                broadcaster.Broadcast(Localization.GAME_NOT_STARTED);
                return;
            }

            // --- PLayers only ---
            //!arena leave
            //!arena, !arena join

            // --- Broadcaster Only ---
            //!arena start,begin
            //!arena cancel,cancel
            //!arena kick <player>
            //!arena add <player>

            var command = cmd.Arguments?.Trim().ToLower();
            var player  = playerProvider.Get(cmd.Sender);

            if (string.IsNullOrEmpty(command) || command.Equals("join"))
            {
                await game.JoinArenaAsync(player);
            }
            else if (command.Equals("leave"))
            {
                await game.LeaveArenaAsync(player);
            }
            else if (command.Equals("start") || command.Equals("begin"))
            {
                if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
                {
                    broadcaster.Send(cmd.Sender.Username, "You do not have permission to force start the arena.");
                    //broadcaster.Broadcast("You do not have permission to force start the arena.");
                    return;
                }

                await game.StartArenaAsync(player);
            }
            else if (command.Equals("cancel") || command.Equals("end"))
            {
                if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
                {
                    //broadcaster.Broadcast(
                    broadcaster.Send(cmd.Sender.Username,
                                     "You do not have permission to cancel the arena.");
                    return;
                }

                await game.CancelArenaAsync(player);
            }
            else
            {
                var targetPlayerName = command.Split(' ').LastOrDefault();
                if (command.StartsWith("kick "))
                {
                    if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
                    {
                        //broadcaster.Broadcast(
                        broadcaster.Send(cmd.Sender.Username,
                                         "You do not have permission to kick a player from the arena.");
                        return;
                    }

                    var targetPlayer = playerProvider.Get(cmd.Sender);
                    await game.KickPlayerFromArenaAsync(player, targetPlayer);
                }
                else if (command.StartsWith("add "))
                {
                    if (!cmd.Sender.IsBroadcaster && !cmd.Sender.IsModerator)
                    {
                        //broadcaster.Broadcast(
                        broadcaster.Send(cmd.Sender.Username,
                                         "You do not have permission to add a player to the arena.");
                        return;
                    }

                    var targetPlayer = playerProvider.Get(cmd.Sender);
                    await game.AddPlayerToArenaAsync(player, targetPlayer);
                }
            }
        }
        public Task ProcessAsync(IMessageBroadcaster broadcaster, ICommand cmd)
        {
            var command = cmd.Arguments;

            if (string.IsNullOrEmpty(command))
            {
                return(Task.CompletedTask);
            }

            if (command.Trim().StartsWith("help "))
            {
                var cmdTarget = command.Trim().Split(new string[] { "help " }, StringSplitOptions.RemoveEmptyEntries)
                                .FirstOrDefault();

                if (Witcher3Commands.TryGet(cmdTarget, out var cmdTargetInfo))
                {
                    broadcaster.Broadcast(cmdTargetInfo.Syntax + $", costs: {cmdTargetInfo.InvokeCost} credits, " + cmdTargetInfo.Description);
                }
                else
                {
                    broadcaster.Broadcast(cmd.Sender.Username + ", no such command exists!");
                }

                return(Task.CompletedTask);
            }

            if (command.Trim().Equals("commands", StringComparison.InvariantCultureIgnoreCase) ||
                command.Trim().Equals("help", StringComparison.InvariantCultureIgnoreCase))
            {
                broadcaster.Broadcast("For a list of commands, go to https://commands.gg/witcher3");
                return(Task.CompletedTask);
            }

            if (!witcher3.IsRunning)
            {
                broadcaster.Broadcast($"{cmd.Sender.Username}, Witcher 3 is not running right now.");
                return(Task.CompletedTask);
            }

            if (witcher3.IsRunning)
            {
                var gameCommand = commandFactory.Create(cmd.Sender.Username, command);
                if (gameCommand == null)
                {
                    broadcaster.Broadcast($"{cmd.Sender.Username}, no such Witcher 3 command exists!");
                    return(Task.CompletedTask);
                }

                var user = this.userStore.Get(cmd.Sender.Username);
                if (!user.CanAfford(gameCommand.InvokeCost))
                {
                    broadcaster.Broadcast($"{cmd.Sender.Username}, You have insufficient amount of credits to use this command. This costs {gameCommand.InvokeCost}, and you only have {(int)user.Credits} left.");
                    return(Task.CompletedTask);
                }

                if (witcher3.Invoke(gameCommand))
                {
                    messageBus.Send("witcher3", gameCommand);
                    user.RemoveCredits(gameCommand.InvokeCost);
                    broadcaster.Broadcast($"{cmd.Sender.Username}, command executed! You now have {(int)user.Credits} credits left.");
                    witcher3.Notify($"{cmd.Sender.Username} used {gameCommand.Name}");
                }
                else
                {
                    broadcaster.Broadcast($"{cmd.Sender.Username}, the command failed :(");
                }
            }
            return(Task.CompletedTask);
        }