Beispiel #1
0
        public static async Task PvPMainMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "back1":
                user.RemoveAllReactionMessages(11);
                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 "singlebattle":
                user.RemoveAllReactionMessages(12);
                user.RemoveAllReactionMessages(11);
                user.RemoveAllReactionMessages(1);
                CombatCreationTool lobby = user.GetOrCreatePvPLobby("single", user.UserId);

                await message.RemoveAllReactionsAsync();

                string url = MessageHandler.GetImageURL(ImageGenerator.PvPSoloLobby(lobby)).Result;
                await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.PvPLobby(lobby, url, user); m.Content = ""; });

                await MessageHandler.PvPLobbyEmojis(message, user);

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

            case "doublebattle":
                await MessageHandler.NotImplemented(idList, "double battle");

                break;

            case "ffa":
                await MessageHandler.NotImplemented(idList, "free for all");

                break;

            case "custombattle":
                await MessageHandler.NotImplemented(idList, "custom battle");

                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public static async Task CreateTeamMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "back1":
                user.RemoveAllReactionMessages(9);
                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 "team":
                Team t = new Team(true);
                t.AddMember(user);
                TownHandler.GetTown(user.Char.CurrentGuildId).Teams.Add(t);

                if (user.ExpectedInput == 5)
                {
                    user.ExpectedInput         = -1;
                    user.ExpectedInputLocation = 0;
                }

                user.RemoveAllReactionMessages(9);
                user.RemoveAllReactionMessages(7);

                await message.RemoveAllReactionsAsync();

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

                await MessageHandler.TeamMenuEmojis(message, user);

                break;

            case "invite":
                await message.ModifyAsync(m => { m.Content = "**Tag someone in the team you want to join. The team must be open.**"; });

                user.ExpectedInput         = 5;
                user.ExpectedInputLocation = message.Channel.Id;
                break;

            default:
                break;
            }
        }
        public static async Task Menu(ContextIds context)
        {
            var user = UserHandler.GetUser(context.UserId);

            var message = await _client.GetGuild(context.GuildId).GetTextChannel(context.ChannelId).SendMessageAsync(
                "",
                embed: MonEmbedBuilder.MainMenu(user))
                          .ConfigureAwait(false);

            await MenuEmojis(message);

            user.RemoveAllReactionMessages(1);

            user.ReactionMessages.Add(message.Id, 1);
        }
        public static async Task UpdateMenu(UserAccount user, ISocketMessageChannel channel, int num, string content)
        {
            bool  mainMenu = false;
            ulong messId   = 0;

            //Update the user's currently active menu
            foreach (KeyValuePair <ulong, int> kvp in user.ReactionMessages)
            {
                //Team menu
                if (kvp.Value == 7 && num == 7)
                {
                    IMessage teamMess = await channel.GetMessageAsync(kvp.Key);

                    if (teamMess is IUserMessage)
                    {
                        IUserMessage userTeamMess = (IUserMessage)teamMess;
                        await userTeamMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = content; });
                    }
                }
                //Team settings
                if (kvp.Value == 8 && num == 8)
                {
                    IMessage teamMess = await channel.GetMessageAsync(kvp.Key);

                    if (teamMess is IUserMessage)
                    {
                        IUserMessage userTeamMess = (IUserMessage)teamMess;
                        await userTeamMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamSettingsMenu(user); m.Content = content; });
                    }
                }
                //Team creation (for updating it into becoming a Team Menu)
                if (kvp.Value == 9 && num == 9)
                {
                    IMessage teamMess = await channel.GetMessageAsync(kvp.Key);

                    if (teamMess is IUserMessage)
                    {
                        IUserMessage userTeamMess = (IUserMessage)teamMess;
                        await userTeamMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = content; });

                        if (user.GetTeam() != null)
                        {
                            user.RemoveAllReactionMessages(7);
                            user.RemoveAllReactionMessages(9);
                            //FOR FUTURE USE- When bot has no permissions, this can be used to remove bot-only reactions
                            //await message.RemoveReactionAsync(await MessageHandler.GetEmoji(736480922152730665), message.Author);
                            await userTeamMess.RemoveAllReactionsAsync();

                            await MessageHandler.TeamMenuEmojis(userTeamMess, user);
                        }
                    }
                }
                //PvP Lobby Invite Menu
                if (kvp.Value == 12 && num == 12)
                {
                    IMessage mess = await channel.GetMessageAsync(kvp.Key);

                    if (mess is IUserMessage)
                    {
                        IUserMessage userMess = (IUserMessage)mess;
                        if (user.HasLobby())
                        {
                            var    lobby = user.CombatLobby;
                            string url   = MessageHandler.GetImageURL(ImageGenerator.PvPSoloLobby(lobby)).Result;
                            await userMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.PvPLobby(user.CombatLobby, url, user); m.Content = content; });

                            return;
                        }
                        else
                        {
                            await userMess.ModifyAsync(m => { m.Embed = MonEmbedBuilder.MainMenu(user); m.Content = content; });

                            user.RemoveAllReactionMessages(12);
                            user.RemoveAllReactionMessages(1);
                            mainMenu = true;
                            messId   = userMess.Id;
                            //FOR FUTURE USE- When bot has no permissions, this can be used to remove bot-only reactions
                            //await message.RemoveReactionAsync(await MessageHandler.GetEmoji(736480922152730665), message.Author);
                            await userMess.RemoveAllReactionsAsync();

                            await MessageHandler.MenuEmojis(userMess);

                            return;
                        }
                    }
                }
            }
            if (mainMenu)
            {
                user.ReactionMessages.Add(messId, 1);
            }
        }
Beispiel #5
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;
            }
        }
Beispiel #6
0
        public static async Task TeamMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            Team team = user.GetTeam();

            if (team != null)
            {
                switch (emote.Name.ToLower())
                {
                case "back1":
                    user.RemoveAllReactionMessages(7);
                    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 "invite":
                    if (team.CanInvite(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Please tag the player(s) you wish to invite.**"; });

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

                case "kick_player":
                    if (team.CanKick(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Please tag the player(s) you wish to kick.**"; });

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

                case "exit":
                    bool leader = false;
                    if (team.Members.IndexOf(user) == 0)
                    {
                        leader = true;
                    }

                    team.KickMember(user);

                    if (team.Members.Count > 0)
                    {
                        if (leader)
                        {
                            await MessageHandler.SendMessage(user.Char.CurrentGuildId, message.Channel.Id, $"{team.Members[0].Mention}, you are now the team leader.");
                        }
                    }
                    else
                    {
                        TownHandler.GetTown(user.Char.CurrentGuildId).Teams.Remove(team);
                    }

                    user.RemoveAllReactionMessages(9);
                    user.RemoveAllReactionMessages(7);

                    await message.RemoveAllReactionsAsync();

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

                    await MessageHandler.TeamMenuEmojis(message, user);

                    break;

                case "settings":
                    if (team.CanAccessSettings(user))
                    {
                        user.RemoveAllReactionMessages(7);
                        user.RemoveAllReactionMessages(8);

                        await message.RemoveAllReactionsAsync();

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

                        await MessageHandler.TeamSettingsEmojis(message, user);

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

                case "disband":
                    if (team.CanDisband(user))
                    {
                        TownHandler.GetTown(user.Char.CurrentGuildId).Teams.Remove(team);

                        user.RemoveAllReactionMessages(9);
                        user.RemoveAllReactionMessages(7);

                        await message.RemoveAllReactionsAsync();

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

                        await MessageHandler.TeamMenuEmojis(message, user);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #7
0
        public static async Task PartyMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "back1":
                user.RemoveAllReactionMessages(5);
                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);
                user.Char.SwapMode   = false;
                user.Char.SwapMonNum = -1;
                break;

            case "1\u20E3":
            case "2\u20E3":
            case "3\u20E3":
            case "4\u20E3":
            case "5\u20E3":
            case "6\u20E3":
                int num = int.Parse(emote.Name.ToLower().Substring(0, 1));
                if (user.Char.Party.Count >= num)
                {
                    if (!user.Char.SwapMode)
                    {
                        await MessageHandler.NotImplemented(idList, "monstats");
                    }
                    else
                    {
                        if (user.Char.SwapMonNum == -1)
                        {
                            user.Char.SwapMonNum = num - 1;
                            await message.ModifyAsync(m => { m.Content = $"**Who should {user.Char.Party[num-1].Nickname} be swapped with?**"; });
                        }
                        else
                        {
                            if (num - 1 != user.Char.SwapMonNum)
                            {
                                BasicMon temp = user.Char.Party[num - 1];
                                user.Char.Party[num - 1] = user.Char.Party[user.Char.SwapMonNum];
                                user.Char.Party[user.Char.SwapMonNum] = temp;
                                string url = MessageHandler.GetImageURL(ImageGenerator.PartyMenu(user.Char.Party)).Result;
                                await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.PartyMenu(url, user); m.Content = ""; });

                                user.Char.SwapMode   = false;
                                user.Char.SwapMonNum = -1;
                            }
                        }
                    }
                }

                break;

            case "swap":
                if (!user.Char.SwapMode)
                {
                    await message.ModifyAsync(m => { m.Content = "**Swapping Mode Enabled**"; });

                    user.Char.SwapMode   = true;
                    user.Char.SwapMonNum = -1;
                }
                else
                {
                    //Careful- m.Content string has an invisible EMPTY CHARACTER in it. Looks like this -->‎
                    await message.ModifyAsync(m => { m.Content = "‎"; });

                    user.Char.SwapMode   = false;
                    user.Char.SwapMonNum = -1;
                }
                break;

            default:
                break;
            }
        }