Esempio n. 1
0
        public static async Task ParseExpectedInput(SocketUserMessage message, UserAccount user, SocketCommandContext Context)
        {
            ContextIds idList = new ContextIds(Context);

            if ((user.ExpectedInputLocation == idList.ChannelId || user.ExpectedInputLocation == 0) && user.GetTeam() != null)
            {
                if (user.ExpectedInput == 0 || user.ExpectedInput == 1)
                {
                    //Update the menu(s) of the person who sent the invite
                    await UpdateMenu(user, message.Channel, 7, "");

                    /*foreach(KeyValuePair<ulong, int> kvp in user.ReactionMessages)
                     * {
                     *  if(kvp.Value == 7)
                     *  {
                     *      IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key);
                     *      if(teamMess is IUserMessage)
                     *      {
                     *          IUserMessage userTeamMess = (IUserMessage)teamMess;
                     *          await userTeamMess.ModifyAsync(m => {m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = "";});
                     *      }
                     *  }
                     * }*/
                }
                //Team Invite Sending
                if (user.ExpectedInput == 0)
                {
                    foreach (SocketUser u in message.MentionedUsers)
                    {
                        var ua = UserHandler.GetUser(u.Id);
                        if (ua.GetTeam() == null && ua.Char != null)
                        {
                            var m = await _client.GetGuild(idList.GuildId).GetTextChannel(idList.ChannelId).SendMessageAsync("", embed: MonEmbedBuilder.TeamInviteMenu(user, ua)).ConfigureAwait(false);
                            await TeamInviteEmojis(m);

                            ua.ReactionMessages.Add(m.Id, 10);
                            ua.InviteMessages.Add(m.Id, user.UserId);
                        }
                    }
                }
                //Kick players from team
                else if (user.ExpectedInput == 1)
                {
                    //Kick all players who are on the team as long as the user kicking has kick permissions
                    foreach (SocketUser u in message.MentionedUsers)
                    {
                        var ua = UserHandler.GetUser(u.Id);
                        if (ua.GetTeam() == user.GetTeam() && user.GetTeam().CanKick(user) && user != ua)
                        {
                            ua.GetTeam().KickMember(ua);
                        }
                    }

                    //Update the user's currently active team menu
                    await UpdateMenu(user, message.Channel, 7, "");

                    /*foreach(KeyValuePair<ulong, int> kvp in user.ReactionMessages)
                     * {
                     *  if(kvp.Value == 7)
                     *  {
                     *      IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key);
                     *      if(teamMess is IUserMessage)
                     *      {
                     *          IUserMessage userTeamMess = (IUserMessage)teamMess;
                     *          await userTeamMess.ModifyAsync(m => {m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = "";});
                     *      }
                     *  }
                     * }*/
                }
                //Edit team name
                else if (user.ExpectedInput == 2)
                {
                    var team = user.GetTeam();
                    if (team.CanAccessSettings(user) && message.Content.Length < 64)
                    {
                        team.TeamName = message.Content;
                    }
                    await UpdateMenu(user, message.Channel, 8, "");
                }
                //Add image url
                else if (user.ExpectedInput == 3)
                {
                    var team = user.GetTeam();
                    if (team.CanAccessSettings(user))
                    {
                        team.Picture = message.Content;
                    }
                    await UpdateMenu(user, message.Channel, 8, "");
                }
                //Edit RGB
                else if (user.ExpectedInput == 4)
                {
                    var    team          = user.GetTeam();
                    string updateContent = "";
                    if (team.CanAccessSettings(user))
                    {
                        string str = message.Content;
                        str = str.Replace(",", "");
                        string[] rgb = str.Split(' ');
                        if (rgb.Count() == 3)
                        {
                            try
                            {
                                team.TeamR = Int32.Parse(rgb[0]);
                                team.TeamG = Int32.Parse(rgb[1]);
                                team.TeamB = Int32.Parse(rgb[2]);
                            }
                            catch (FormatException e)
                            {
                                Console.WriteLine(e.Message);
                                updateContent = "**You didn't enter the RGB values correctly!**";
                            }
                        }
                    }
                    await UpdateMenu(user, message.Channel, 8, updateContent);
                }

                user.ExpectedInput         = -1;
                user.ExpectedInputLocation = 0;
            }
            //Expected inputs that do not require a team
            if (user.ExpectedInputLocation == idList.ChannelId || user.ExpectedInputLocation == 0)
            {
                //Join open team
                if (user.ExpectedInput == 5)
                {
                    string      updateContent = "";
                    var         team          = user.GetTeam();
                    UserAccount otherUser     = null;
                    if (message.MentionedUsers.Count != 0)
                    {
                        otherUser = UserHandler.GetUser(message.MentionedUsers.First().Id);
                    }
                    Team otherTeam = null;
                    if (otherUser != null)
                    {
                        otherTeam = otherUser.GetTeam();
                    }

                    if (otherTeam != null)
                    {
                        if (otherTeam.OpenInvite)
                        {
                            if (team == null)
                            {
                                otherTeam.AddMember(user);
                            }
                            else
                            {
                                updateContent = "**You already have a team!**";
                            }
                        }
                        else
                        {
                            updateContent = "**That team is not open invite!**";
                        }
                    }
                    else
                    {
                        updateContent = "**That person does not have a team!**";
                    }

                    await UpdateMenu(user, message.Channel, 9, updateContent);
                }
                //Invite player(s) to a pvp lobby
                else if (user.ExpectedInput == 6)
                {
                    foreach (SocketUser u in message.MentionedUsers)
                    {
                        var ua = UserHandler.GetUser(u.Id);
                        if (ua.Char != null)
                        {
                            var m = await _client.GetGuild(idList.GuildId).GetTextChannel(idList.ChannelId).SendMessageAsync("", embed: MonEmbedBuilder.LobbyInviteMenu(user, ua)).ConfigureAwait(false);
                            await TeamInviteEmojis(m);

                            ua.ReactionMessages.Add(m.Id, 14);
                            ua.InviteMessages.Add(m.Id, user.UserId);
                        }
                    }
                    if (user.HasLobby())
                    {
                        CombatCreationTool lobby = user.CombatLobby;
                        await lobby.UpdateAllMenus(new List <ulong>(), idList, "");
                    }
                }
                else if (user.ExpectedInput == 7)
                {
                    List <ulong> excludeUpdate = new List <ulong>();
                    foreach (SocketUser u in message.MentionedUsers)
                    {
                        var ua = UserHandler.GetUser(u.Id);
                        if (ua.Char != null)
                        {
                            if (user.HasLobby())
                            {
                                CombatCreationTool lobby = user.CombatLobby;
                                lobby.RemovePlayer(ua);
                                await UpdateMenu(ua, message.Channel, 12, "You have been kicked from the lobby.");

                                excludeUpdate.Add(ua.UserId);
                            }
                        }
                    }
                    if (user.HasLobby())
                    {
                        CombatCreationTool lobby = user.CombatLobby;
                        await lobby.UpdateAllMenus(excludeUpdate, idList, "");
                    }
                }

                user.ExpectedInput         = -1;
                user.ExpectedInputLocation = 0;
            }
        }
Esempio n. 2
0
        public static async Task SoloPvPLobbyMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "back1":
                user.RemoveAllReactionMessages(12);
                user.RemoveAllReactionMessages(1);

                await message.RemoveAllReactionsAsync();

                await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = ""; });

                await MessageHandler.MenuEmojis(message);

                user.ReactionMessages.Add(message.Id, 1);
                break;

            case "check":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;
                    user.Char.ReadyToggle();

                    if (user.Char.ReadyUp)
                    {
                        if (lobby.CheckCombatStart())
                        {
                            CombatInstance2 combat = new CombatInstance2(idList, lobby.Teams);

                            CombatHandler2.StoreInstance(CombatHandler2.NumberOfInstances(), combat);
                            await combat.StartCombat();
                        }
                    }
                }
                break;

            case "invite":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    if (lobby.IsLeader(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Please tag the player(s) you wish to invite.**"; });

                        user.ExpectedInput         = 6;
                        user.ExpectedInputLocation = message.Channel.Id;
                    }
                }
                break;

            case "kick_player":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    if (lobby.IsLeader(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Please tag the player(s) you wish to kick.**"; });

                        user.ExpectedInput         = 7;
                        user.ExpectedInputLocation = message.Channel.Id;
                    }
                }
                break;

            case "lvl":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    if (lobby.IsLeader(user))
                    {
                        lobby.LevelToggle();

                        await lobby.UpdateAllMenus(new List <ulong>(), idList, "");
                    }
                }
                break;

            case "bag":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    if (lobby.IsLeader(user))
                    {
                        lobby.ItemsToggle();

                        await lobby.UpdateAllMenus(new List <ulong>(), idList, "");
                    }
                }
                break;

            case "mon":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    if (lobby.IsLeader(user))
                    {
                        lobby.MonsToggle();

                        await lobby.UpdateAllMenus(new List <ulong>(), idList, "");
                    }
                }
                break;

            case "exit":
                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.CombatLobby;

                    lobby.RemovePlayer(user);
                    await lobby.UpdateAllMenus(user.UserId, idList, $"{user.Name} left lobby");

                    user.RemoveAllReactionMessages(12);
                    user.RemoveAllReactionMessages(1);

                    await message.RemoveAllReactionsAsync();

                    await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = ""; });

                    await MessageHandler.MenuEmojis(message);

                    user.ReactionMessages.Add(message.Id, 1);
                }
                break;

            default:
                break;
            }
        }