Exemplo n.º 1
0
        public async Task OldParty()
        {
            ContextIds idList = new ContextIds(Context);
            var        user   = UserHandler.GetUser(idList.UserId);

            //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location)
            try
            {
                await UserHandler.CharacterExists(idList);

                await UserHandler.ValidCharacterLocation(idList);
            }
            catch (InvalidCharacterStateException)
            {
                return;
            }

            var count = 6;

            foreach (BasicMon mon in user.Char.Party)
            {
                await MessageHandler.SendEmbedMessage(idList, "", MonEmbedBuilder.FieldMon(mon));

                count--;
            }

            await MessageHandler.SendEmbedMessage(idList, "", MonEmbedBuilder.EmptyPartySpot(count));
        }
Exemplo n.º 2
0
        public static async Task FightScreenNew(ulong userId)
        {
            var user = UserHandler.GetUser(userId);

            var message = await _client.GetUser(userId).SendMessageAsync("", false, MonEmbedBuilder.FightScreen(user.Char.ActiveMons[0]));

            await FightScreenEmojis(message);

            user.ReactionMessages.Add(message.Id, 2);
        }
Exemplo n.º 3
0
        public static async Task TargetingScreen(ulong userId)
        {
            var user = UserHandler.GetUser(userId);

            var message = await _client.GetUser(userId).SendMessageAsync("", false, MonEmbedBuilder.TargetingScreen(user, user.Char.ActiveMons[user.Char.MoveScreenNum]));

            await TargetingScreenEmojis(message);

            user.ReactionMessages.Add(message.Id, 4);
        }
Exemplo n.º 4
0
        public static async Task TeamInviteMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "check":
                if (user.GetTeam() == null)
                {
                    if (user.InviteMessages.ContainsKey(message.Id))
                    {
                        var otherUser = UserHandler.GetUser(user.InviteMessages[message.Id]);
                        if (otherUser.GetTeam() != null)
                        {
                            user.InviteMessages.Remove(message.Id);
                            user.RemoveAllReactionMessages(10);
                            otherUser.GetTeam().AddMember(user);
                            await message.RemoveAllReactionsAsync();

                            //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 message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.TeamMenu(user); m.Content = ""; });

                            await MessageHandler.TeamMenuEmojis(message, user);

                            //Update the menu of the person who sent the invite
                            foreach (KeyValuePair <ulong, int> kvp in otherUser.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(otherUser); m.Content = ""; });
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case "redx":
                user.InviteMessages.Remove(message.Id);
                user.RemoveAllReactionMessages(10);
                await message.ModifyAsync(m => { m.Content = "Invite Declined."; });

                break;

            default:
                break;
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        public static async Task PvPMainMenu(ContextIds context)
        {
            var user = UserHandler.GetUser(context.UserId);

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

            await PvPMainMenuEmojis(message);

            user.RemoveAllReactionMessages(11);
        }
Exemplo n.º 7
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;
            }
        }
Exemplo n.º 8
0
        public static async Task ModifyAsyncTest(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name)
            {
            case "1\u20E3":
                await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.ModifyAsyncTestPageOne(); });

                break;

            case "2\u20E3":
                await message.ModifyAsync(m => { m.Embed = MonEmbedBuilder.ModifyAsyncTestPageTwo(); });

                break;
            }
        }
Exemplo n.º 9
0
        public static async Task ModifyAsyncTest(ContextIds context, ulong userId)
        {
            var user = UserHandler.GetUser(userId);

            var message = await _client.GetGuild(context.GuildId).GetTextChannel(context.ChannelId).SendMessageAsync(
                "Modify Async Tester",
                embed: MonEmbedBuilder.ModifyAsyncTestPageOne())
                          .ConfigureAwait(false);

            await message.AddReactionAsync(new Emoji("1\u20E3"));

            await message.AddReactionAsync(new Emoji("2\u20E3"));

            user.RemoveAllReactionMessages(1);

            user.ReactionMessages.Add(message.Id, 13);
        }
Exemplo n.º 10
0
        public static async Task TeamSettingsMenu(ContextIds context)
        {
            var user = UserHandler.GetUser(context.UserId);

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

            await TeamSettingsEmojis(message, user);

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

            user.ReactionMessages.Add(message.Id, 8);
        }
Exemplo n.º 11
0
        public static async Task PartyMenu(ContextIds context)
        {
            var user = UserHandler.GetUser(context.UserId);

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

            string url     = MessageHandler.GetImageURL(ImageGenerator.PartyMenu(user.Char.Party)).Result;
            var    message = await _client.GetGuild(context.GuildId).GetTextChannel(context.ChannelId).SendMessageAsync(
                "",
                embed: MonEmbedBuilder.PartyMenu(url, user))
                             .ConfigureAwait(false);

            await PartyMenuEmojis(message, user);

            user.RemoveAllReactionMessages(5);

            user.ReactionMessages.Add(message.Id, 5);
        }
Exemplo n.º 12
0
        public async Task MonStat([Remainder] int num)
        {
            ContextIds  idList = new ContextIds(Context);
            UserAccount user   = UserHandler.GetUser(idList.UserId);

            //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location)
            try
            {
                await UserHandler.CharacterExists(idList);

                await UserHandler.ValidCharacterLocation(idList);
            }
            catch (InvalidCharacterStateException)
            {
                return;
            }

            await Context.Channel.SendMessageAsync(
                "",
                embed : MonEmbedBuilder.MonStats((BasicMon)user.Char.Party[num - 1]))
            .ConfigureAwait(false);
        }
Exemplo n.º 13
0
        public static async Task MainMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "location":
                await MessageHandler.NotImplemented(idList, "location");

                break;

            case "snoril":
                user.RemoveAllReactionMessages(1);
                user.RemoveAllReactionMessages(5);

                await message.RemoveAllReactionsAsync();

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

                await MessageHandler.PartyMenuEmojis(message, user);

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

            case "bag":
                await MessageHandler.NotImplemented(idList, "bag");

                break;

            case "dex":
                await MessageHandler.NotImplemented(idList, "dex");

                break;

            case "team":
                user.RemoveAllReactionMessages(7);
                user.RemoveAllReactionMessages(8);
                user.RemoveAllReactionMessages(9);
                user.RemoveAllReactionMessages(1);

                await message.RemoveAllReactionsAsync();

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

                await MessageHandler.TeamMenuEmojis(message, user);

                //Reactionmessage added within TeamMenuEmojis() method
                break;

            case "pvp":
                user.RemoveAllReactionMessages(11);
                user.RemoveAllReactionMessages(1);

                if (user.HasLobby())
                {
                    CombatCreationTool lobby = user.GetOrCreatePvPLobby("single", user.UserId);

                    await message.RemoveAllReactionsAsync();

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

                    await MessageHandler.PvPLobbyEmojis(message, user);

                    user.ReactionMessages.Add(message.Id, 12);
                }
                else
                {
                    await message.RemoveAllReactionsAsync();

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

                    await MessageHandler.PvPMainMenuEmojis(message);

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

            case "settings":
                await MessageHandler.NotImplemented(idList, "settings");

                break;

            default:
                break;
            }
        }
Exemplo n.º 14
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;
            }
        }
Exemplo n.º 15
0
 public static async Task TakesDamage(ContextIds context, BasicMon mon, string addon)
 {
     await MessageHandler.SendEmbedMessage(context, $"{mon.Nickname} takes damage!" + addon, MonEmbedBuilder.FieldMon(mon));
 }
Exemplo n.º 16
0
 public static async Task UseMoveNew(ContextIds context, BasicMon target, string addon)
 {
     await MessageHandler.SendEmbedMessage(context, addon, MonEmbedBuilder.FieldMon(target));
 }
Exemplo n.º 17
0
        public static async Task TeamSettingsMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            Team team = user.GetTeam();

            if (team != null)
            {
                switch (emote.Name.ToLower())
                {
                case "back1":
                    user.RemoveAllReactionMessages(8);
                    user.RemoveAllReactionMessages(7);

                    await message.RemoveAllReactionsAsync();

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

                    await MessageHandler.TeamMenuEmojis(message, user);

                    break;

                case "edit":
                    if (team.CanAccessSettings(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Type your team's name. It must be less than 64 charcters.**"; });

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

                case "addpicturegreen":
                    if (team.CanAccessSettings(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Enter your team's picture as an image URL**"; });

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

                case "rgb":
                    if (team.CanAccessSettings(user))
                    {
                        await message.ModifyAsync(m => { m.Content = "**Enter RGB values separated with spaces. Ex: 91 255 10**"; });

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

                case "permissions":
                    if (team.CanAccessSettings(user))
                    {
                        if (team.Permissions == "OwnerOnly")
                        {
                            team.Permissions = "AllMembers";
                        }
                        else if (team.Permissions == "AllMembers")
                        {
                            team.Permissions = "NoPerms";
                        }
                        else if (team.Permissions == "NoPerms")
                        {
                            team.Permissions = "OwnerOnly";
                        }
                        await MessageHandler.UpdateMenu(user, (ISocketMessageChannel)message.Channel, 8, "");
                    }
                    break;

                case "locked":
                case "unlocked":
                    if (team.CanAccessSettings(user))
                    {
                        if (team.OpenInvite)
                        {
                            team.OpenInvite = false;
                        }
                        else
                        {
                            team.OpenInvite = true;
                        }
                        await MessageHandler.UpdateMenu(user, (ISocketMessageChannel)message.Channel, 8, "");
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 18
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;
            }
        }
Exemplo n.º 19
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;
            }
        }
Exemplo n.º 20
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;
                }
            }
        }
Exemplo n.º 21
0
        public static async Task LobbyInviteMenu(UserAccount user, IUserMessage message, IEmote emote, ContextIds idList)
        {
            switch (emote.Name.ToLower())
            {
            case "check":
                if (!user.Char.InCombat)
                {
                    if (user.InviteMessages.ContainsKey(message.Id))
                    {
                        var otherUser = UserHandler.GetUser(user.InviteMessages[message.Id]);
                        if (otherUser.HasLobby())
                        {
                            var lobby = otherUser.CombatLobby;

                            user.InviteMessages.Remove(message.Id);
                            user.RemoveAllReactionMessages(14);
                            await message.RemoveAllReactionsAsync();

                            //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);
                            if (lobby.IsLobbyFull())
                            {
                                await message.ModifyAsync(m => { m.Content = "Joining failed. Lobby is full."; });
                            }
                            else
                            {
                                lobby.AddPlayer(user);
                                user.CombatLobby = lobby;
                                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);

                                //Update the menu of the person who sent the invite
                                await MessageHandler.UpdateMenu(otherUser, idList.ChannelId, 12, "");

                                /*foreach(KeyValuePair<ulong, int> kvp in otherUser.ReactionMessages)
                                 * {
                                 *  if(kvp.Value == 12)
                                 *  {
                                 *      IMessage teamMess = await message.Channel.GetMessageAsync(kvp.Key);
                                 *      if(teamMess is IUserMessage)
                                 *      {
                                 *          IUserMessage userTeamMess = (IUserMessage)teamMess;
                                 *          await userTeamMess.ModifyAsync(m => {m.Embed = MonEmbedBuilder.TeamMenu(otherUser); m.Content = "";});
                                 *      }
                                 *  }
                                 * }*/
                            }
                        }
                    }
                }
                break;

            case "redx":
                user.InviteMessages.Remove(message.Id);
                user.ReactionMessages.Remove(message.Id);
                await message.ModifyAsync(m => { m.Content = "Invite Declined."; });

                break;

            default:
                break;
            }
        }
Exemplo n.º 22
0
        public async Task Enter([Remainder] string text)
        {
            ContextIds ids          = new ContextIds(Context);
            var        user         = UserHandler.GetUser(ids.UserId);
            var        originalText = text;

            text = text.ToLower();

            /* PROMPT STATE MEANINGS-
             * -1- Has no character
             * 0- Awaiting confirmation or cancellation of character creation
             * 1- Character creation confirmed. Awaiting name.
             * 2- Name confirmed. Awaiting partner.
             */
            switch (user.PromptState)
            {
            case 0:
                if (text.Equals("confirm"))
                {
                    user.Char = new Character(true);
                    user.Char.CurrentGuildId   = ids.GuildId;
                    user.Char.CurrentGuildName = Context.Guild.Name;
                    user.PromptState           = 1;
                    await MessageHandler.SendMessage(ids, $"Beginning character creation for {user.Mention}.\nWhat is your name? (use the \"enter\" command to enter your name)");
                }
                else if (text.Equals("cancel"))
                {
                    user.PromptState = -1;
                    await MessageHandler.SendMessage(ids, $"Character creation cancelled for {user.Mention}.");
                }
                else
                {
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, I'm sorry, but I don't recognize that. Please enter \"confirm\" or \"cancel\"");
                }
                break;

            case 1:
                if (text.Length <= 32 && text.Length > 0)
                {
                    user.Char.Name   = originalText;
                    user.PromptState = 2;
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, your character's name is now {originalText}. Now you must choose your partner.");

                    await Context.Channel.SendMessageAsync(
                        "", embed : MonEmbedBuilder.MonDex(new Snoril(true)))
                    .ConfigureAwait(false);

                    await Context.Channel.SendMessageAsync(
                        "", embed : MonEmbedBuilder.MonDex(new Suki(true)))
                    .ConfigureAwait(false);
                }
                else
                {
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, your name must be 32 characters or less.");
                }
                break;

            case 2:
                if (text.Equals("snoril") || text.Equals("1"))
                {
                    user.Char.Party.Add(new Snoril(true)
                    {
                        CatcherID = user.UserId,
                        OwnerID   = user.UserId
                    });
                    user.HasCharacter = true;
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, you have chosen Snoril as your partner! Good luck on your adventure.");
                }
                else if (text.Equals("suki") || text.Equals("2"))
                {
                    user.Char.Party.Add(new Suki(true)
                    {
                        CatcherID = user.UserId,
                        OwnerID   = user.UserId
                    });
                    user.HasCharacter = true;
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, you have chosen Suki as your partner! Good luck on your adventure.");
                }
                else
                {
                    await MessageHandler.SendMessage(ids, $"{user.Mention}, please enter either Snoril or Suki.");
                }
                break;
            }
        }
Exemplo n.º 23
0
 public static async Task UseMove(ContextIds context, BasicMon mon, BasicMon target, string move, string addon)
 {
     await MessageHandler.SendEmbedMessage(context, $"**{mon.Nickname}** used **{move}**!" + addon, MonEmbedBuilder.FieldMon(target));
 }
Exemplo n.º 24
0
        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);
            }
        }
Exemplo n.º 25
0
 public async Task TeamTest()
 {
     await Context.Channel.SendMessageAsync("", false, MonEmbedBuilder.TeamSettingsMenu(UserHandler.GetUser(Context.User.Id)));
 }