public async Task QuickDuel(string mon, string mon2, SocketGuildUser target) { var fromUser = UserHandler.GetUser(Context.User.Id); var toUser = UserHandler.GetUser(target.Id); ContextIds ids = new ContextIds(Context); fromUser.Char = new Character(true); fromUser.Char.CurrentGuildId = ids.GuildId; fromUser.Char.CurrentGuildName = Context.Guild.Name; fromUser.Char.Name = fromUser.Name; mon = mon.ToLower(); BasicMon m = MonRegister.StringToMonRegister(mon); m.CatcherID = fromUser.UserId; m.OwnerID = fromUser.UserId; fromUser.Char.Party.Add(m); fromUser.HasCharacter = true; await MessageHandler.SendMessage(ids, $"{fromUser.Mention}, you have chosen {m.Nickname} as your partner! Good luck on your adventure."); fromUser.PromptState = -1; toUser.Char = new Character(true); toUser.Char.CurrentGuildId = ids.GuildId; toUser.Char.CurrentGuildName = target.Guild.Name; toUser.Char.Name = toUser.Name; mon2 = mon2.ToLower(); BasicMon m2 = MonRegister.StringToMonRegister(mon2); m2.CatcherID = toUser.UserId; m2.OwnerID = toUser.UserId; toUser.Char.Party.Add(m2); toUser.HasCharacter = true; await MessageHandler.SendMessage(ids, $"{toUser.Mention}, you have chosen {m2.Nickname} as your partner! Good luck on your adventure."); toUser.PromptState = -1; CombatInstance2 combat = new CombatInstance2(ids, fromUser, toUser); CombatHandler2.StoreInstance(CombatHandler2.NumberOfInstances(), combat); await combat.StartCombat(); }
public async Task Duel(SocketGuildUser target) { var fromUser = UserHandler.GetUser(Context.User.Id); var toUser = UserHandler.GetUser(target.Id); ContextIds idList = new ContextIds(Context); //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.OtherCharacterExists(idList, toUser); await UserHandler.ValidCharacterLocation(idList); await UserHandler.OtherCharacterLocation(idList, toUser); } catch (InvalidCharacterStateException) { return; } //Check that the user did not target themself with the command if (fromUser.UserId != toUser.UserId) { //Set the current user's combat request ID to the user specified fromUser.Char.CombatRequest = toUser.UserId; //Check if the specified user has a combat request ID that is the current user's ID if (toUser.Char.CombatRequest == fromUser.UserId) { //Make sure neither users are in combat while sending response request if (fromUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot start a duel while in combat!"); } else if (toUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot start a duel with a player who is in combat!"); } else { //Start duel /* * CombatInstance combat = new CombatInstance(idList, Context.User.Id, target.Id); * * await Context.Channel.SendMessageAsync($"The duel between {target.Mention} and {Context.User.Mention} will now begin!"); * fromUser.Char.InCombat = true; * fromUser.Char.InPvpCombat = true; * fromUser.Char.CombatRequest = 0; * fromUser.Char.InCombatWith = toUser.UserId; * fromUser.Char.Combat = new CombatInstance(idList, fromUser.UserId, toUser.UserId); * * toUser.Char.InCombat = true; * toUser.Char.InPvpCombat = true; * toUser.Char.CombatRequest = 0; * toUser.Char.InCombatWith = fromUser.UserId; * toUser.Char.Combat = new CombatInstance(idList, toUser.UserId, fromUser.UserId); * * await CombatHandler.StartCombat(fromUser.Char.Combat); */ CombatInstance2 combat = new CombatInstance2(idList, fromUser, toUser); CombatHandler2.StoreInstance(CombatHandler2.NumberOfInstances(), combat); await combat.StartCombat(); } } else { //Make sure neither users are in combat while sending initial request if (fromUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot request a duel when you are in combat!"); } else if (toUser.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot duel a player who is in combat!"); } else { //Challenge the specified user await Context.Channel.SendMessageAsync($"{target.Mention}, you have been challenged to a duel by {Context.User.Mention}\nUse the \"duel [mention target]\" command to accept."); } } } else { //Tell the current user they have are a dum dum await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot duel yourself."); } }
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; } }