/// <summary> /// Checks if the opponent is blocking. /// Returns: Success, Blocked Damage, Taken Damage /// </summary> /// <param name="attacker"></param> /// <param name="defender"></param> /// <param name="dmg"></param> /// <returns> Success, Blocked Damage, Taken Damage</returns> public static Tuple <bool, int, int> CheckForBlock(SocketUser attacker, SocketUser defender, int dmg) { var config = GlobalUserAccounts.GetUserAccount(defender); var choms = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id); var chom1 = choms.Item1; var chom2 = choms.Item2; int finaldmg2 = 0, finaldmg1 = 0; if (chom1.PotionEffects.ContainsKey("Speed")) { chom2.Effects.Remove(Effect.Blocking); ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2); return(new Tuple <bool, int, int>(true, 0, 0)); } if (chom2.Effects.Contains(Effect.Blocking)) { finaldmg1 = dmg * (3 / 4); //blocked dmg finaldmg2 = dmg * (1 / 4); //taken dmg chom2.Effects.Remove(Effect.Blocking); return(new Tuple <bool, int, int>(true, finaldmg1, finaldmg2)); } GlobalUserAccounts.SaveAccounts(config.Id); return(new Tuple <bool, int, int>(false, 0, 0)); // use for values }
public async Task EndFight() { var config = GlobalUserAccounts.GetUserAccount(Context.User); var configg = GlobalUserAccounts.GetUserAccount(config.OpponentId); await ReplyAsync(":flag_white: **|** " + Context.User.Mention + " ended the fight."); var choms = ActiveChomusuke.GetActiveChomusuke(Context.User.Id, config.OpponentId); var chom1 = choms.Item1; var chom2 = choms.Item2; config.Fighting = false; configg.Fighting = false; chom1.Health = chom1.HealthCapacity; chom2.Health = chom2.HealthCapacity; config.OpponentId = 0; configg.OpponentId = 0; config.OpponentName = null; configg.OpponentName = null; config.WhosTurn = null; config.WhoWaits = null; config.PlaceHolder = null; configg.WhosTurn = null; configg.WhoWaits = null; chom1.Effects?.Clear(); chom2.Effects?.Clear(); chom1.PotionEffects?.Clear(); chom2.PotionEffects?.Clear(); GlobalUserAccounts.SaveAccounts(config.Id, configg.Id); }
public static Tuple <bool, int> CheckForDeflect(SocketUser attacker, SocketUser defender, int dmg) { var config = GlobalUserAccounts.GetUserAccount(defender); var choms = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id); var chom1 = choms.Item1; var chom2 = choms.Item2; int finaldmg = 0; if (chom1.PotionEffects.ContainsKey("Speed")) { chom2.Effects.Remove(Effect.Deflecting); ActiveChomusuke.ConvertActiveVariable(attacker.Id, config.OpponentId, chom1, chom2); return(new Tuple <bool, int>(true, 0)); } if (chom2.Effects.Contains(Effect.Deflecting)) { finaldmg = dmg / 2; //damage taken and deflected chom2.Effects.Remove(Effect.Deflecting); return(new Tuple <bool, int>(true, finaldmg)); } GlobalUserAccounts.SaveAccounts(config.Id); return(new Tuple <bool, int>(false, 0)); }
public static Tuple <int, int> GetDMGModifiers(SocketUser attacker, SocketUser defender, int dmg) { var config = GlobalUserAccounts.GetUserAccount(attacker); var choms = ActiveChomusuke.GetActiveChomusuke(attacker.Id, defender.Id); var chom1 = choms.Item1; var chom2 = choms.Item2; int modifier = 0; if (chom1.PotionEffects.Keys.Contains("Strength")) { modifier += chom1.PotionEffects["Strength"]; } if (chom2.PotionEffects.Keys.Contains("Debuff")) { modifier += chom2.PotionEffects["Debuff"]; } if (chom1.Effects.Contains(Effect.Meditating)) { modifier += 30; chom1.Effects.Remove(Effect.Meditating); GlobalUserAccounts.SaveAccounts(config.Id); } if (Helpers.GetCritical()) { modifier += 20; } if (config.Blessing == "Blessing Of Strength") { modifier += 10; } int newdmg = (modifier / 100 + 1) * dmg; return(new Tuple <int, int>(newdmg, modifier)); }
public static async Task Reset(ShardedCommandContext context, Core.Entities.Chomusuke chom1, Core.Entities.Chomusuke chom2) { var config = GlobalUserAccounts.GetUserAccount(context.User); var player2 = context.Guild.GetUser(config.OpponentId); var configg = GlobalUserAccounts.GetUserAccount(player2); config.Fighting = false; configg.Fighting = false; chom1.Health = chom1.HealthCapacity; chom2.Health = chom2.HealthCapacity; config.OpponentId = 0; configg.OpponentId = 0; config.OpponentName = null; configg.OpponentName = null; config.WhosTurn = null; config.WhoWaits = null; config.PlaceHolder = null; configg.WhosTurn = null; configg.WhoWaits = null; chom1.Effects?.Clear(); chom2.Effects?.Clear(); chom1.PotionEffects?.Clear(); chom2.PotionEffects?.Clear(); await ActiveChomusuke.ConvertActiveVariable(context.User.Id, config.OpponentId, chom1, chom2); GlobalUserAccounts.SaveAccounts(config.Id, configg.Id); }
public static PotionResult ExecutePotion(ShardedCommandContext context, string potion, ulong user, ulong target) { var config = GlobalUserAccounts.GetUserAccount(user); var choms = ActiveChomusuke.GetActiveChomusuke(user, config.OpponentId); var chom1 = choms.Item1; var chom2 = choms.Item2; var result = new PotionResult(); switch (potion) { case "Strength Potion": result = Potions.StrengthPotion(context, chom1, chom2, target); break; case "Debuff Potion": result = Potions.DebuffPotion(context, chom1, chom2, target); break; case "Speed Potion": result = Potions.SpeedPotion(context, chom1, chom2, target); break; case "Equalizer Potion": result = Potions.EqualizerPotion(context, chom1, chom2, target); break; } return(result); }
public static async Task StartDuel(ISocketMessageChannel channel, SocketGuildUser user, SocketUser req) { var config = GlobalUserAccounts.GetUserAccount(req); var player2 = user.Guild.GetUser(user.Id); var configg = GlobalUserAccounts.GetUserAccount(player2); configg.OpponentId = req.Id; config.OpponentId = user.Id; configg.OpponentName = req.Username; config.OpponentName = user.Username; config.Fighting = true; configg.Fighting = true; string[] whoStarts = { req.Mention, user.Mention }; Random rand = new Random(); int randomIndex = rand.Next(whoStarts.Length); string text = whoStarts[randomIndex]; config.WhosTurn = text; configg.WhosTurn = text; if (text == req.Mention) { config.WhoWaits = user.Mention; configg.WhoWaits = user.Mention; } else { config.WhoWaits = req.Mention; configg.WhoWaits = req.Mention; } GlobalUserAccounts.SaveAccounts(config.Id, configg.Id); var choms = ActiveChomusuke.GetActiveChomusuke(user.Id, req.Id); var chom1 = choms.Item1; var chom2 = choms.Item2; await channel.SendMessageAsync( $":crossed_swords: **|** {req.Mention} challenged {user.Mention} to a duel!\n\n**{chom1.Name}** has **{chom1.Health}** health!\n**{chom2.Name}** has **{chom2.Health}** health!\n\n{text}, you go first!"); }
public static async Task ApplyEffects(ShardedCommandContext context, ulong user1, ulong user2) { var choms = ActiveChomusuke.GetActiveChomusuke(user1, user2); var chom1 = choms.Item1; var chom2 = choms.Item2; foreach (var effect in chom1.Effects) { switch (effect) { //TODO: Add effects and their results case Effect.Binded: break; case Effect.Blocking: break; case Effect.Burned: await Burning.Burned(context); break; case Effect.Confused: break; case Effect.Decay: break; case Effect.Deflecting: break; case Effect.Frozen: break; case Effect.Meditating: break; case Effect.Restricted: break; case Effect.Stunned: break; } } }
public async Task EngageCommand() { var user = Context.User as SocketGuildUser; var config = GlobalUserAccounts.GetUserAccount((SocketGuildUser)Context.User); var choms = ActiveChomusuke.GetActiveChomusuke(Context.User.Id, config.OpponentId); var activeChomusuke = choms.Item1; var activeChomusukee = choms.Item2; if (config.Fighting != true) { await ReplyAndDeleteAsync($"**{Context.User.Username}** there is no fight going on!", false, null, TimeSpan.FromSeconds(5), null); return; } var player2 = user.Guild.GetUser(config.OpponentId); var configg = GlobalUserAccounts.GetUserAccount(player2); if (config.WhosTurn != user.Mention) { await ReplyAndDeleteAsync($"**{Context.User.Username}** it is not your turn!", false, null, TimeSpan.FromSeconds(5), null); return; } var embed = new EmbedBuilder() .WithColor(Global.NayuColor) .WithFooter("Type [cancel] anytime to cancel the engagement."); embed.WithTitle("What do you want to do?"); embed.AddField("[1]", "**ATTACK**"); embed.AddField("[2]", "**ITEM**"); embed.AddField("[3]", "**GIVE UP**"); var gui = await Context.Channel.SendMessageAsync("", embed : embed.Build()); var response = await NextMessageAsync(); if (response == null) { await gui.DeleteAsync(); await SendMessage(Context, null, $"{Context.User.Mention},The interface has closed due to inactivity"); return; } if (response.Content.Equals("1", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var embeddd = new EmbedBuilder() .WithColor(Global.NayuColor) .WithFooter("Type [cancel] anytime to cancel the engagement."); embeddd.AddField("[1]", activeChomusuke.Attack1); embeddd.AddField("[2]", activeChomusuke.Attack2); embeddd.AddField("[3]", activeChomusuke.Attack3); embeddd.AddField("[4]", activeChomusuke.Attack4); var newGui = await Context.Channel.SendMessageAsync("", embed : embeddd.Build()); var newresponse = await NextMessageAsync(); if (newresponse == null) { await gui.DeleteAsync(); await newGui.DeleteAsync(); await SendMessage(Context, null, $"{Context.User.Mention},The interface has closed due to inactivity"); } else if (newresponse.Content.Equals("1", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var result = Helpers.ExecuteAttack(Context, activeChomusuke, activeChomusuke.Attack1); if (!result.Success) { await SendMessage(Context, null, result.Response); return; } await SendMessage(Context, null, result.Response); Tuple <bool, string> death = await CheckDeath(Context, activeChomusuke, activeChomusukee); if (death.Item1) { await SendMessage(Context, null, death.Item2); return; } var turnmsg = await NextTurn(Context); await SendMessage(Context, null, turnmsg); } else if (newresponse.Content.Equals("2", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var result = Helpers.ExecuteAttack(Context, activeChomusuke, activeChomusuke.Attack2); if (!result.Success) { await SendMessage(Context, null, result.Response); return; } await SendMessage(Context, null, result.Response); Tuple <bool, string> death = await CheckDeath(Context, activeChomusuke, activeChomusukee); if (death.Item1) { await SendMessage(Context, null, death.Item2); return; } var turnmsg = await NextTurn(Context); await SendMessage(Context, null, turnmsg); } else if (newresponse.Content.Equals("3", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var result = Helpers.ExecuteAttack(Context, activeChomusuke, activeChomusuke.Attack3); if (!result.Success) { await SendMessage(Context, null, result.Response); return; } await SendMessage(Context, null, result.Response); Tuple <bool, string> death = await CheckDeath(Context, activeChomusuke, activeChomusukee); if (death.Item1) { await SendMessage(Context, null, death.Item2); return; } var turnmsg = await NextTurn(Context); await SendMessage(Context, null, turnmsg); } else if (newresponse.Content.Equals("4", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var result = Helpers.ExecuteAttack(Context, activeChomusuke, activeChomusuke.Attack4); if (!result.Success) { await SendMessage(Context, null, result.Response); return; } await SendMessage(Context, null, result.Response); Tuple <bool, string> death = await CheckDeath(Context, activeChomusuke, activeChomusukee); if (death.Item1) { await SendMessage(Context, null, death.Item2); return; } var turnmsg = await NextTurn(Context); await SendMessage(Context, null, turnmsg); } if (newresponse.Content.Equals("cancel", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { await gui.ModifyAsync(m => { m.Content = $":shield: **|** **{Context.User.Username}**, engagement cancelled."; }); return; } await gui.ModifyAsync(m => { m.Content = $"{Global.ENo} **|** That is an invalid response. Please try again."; }); return; } if (response.Content.Equals("2", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { var values = 0; var embedd = new EmbedBuilder() .WithColor(Global.NayuColor) .WithFooter("Type [cancel] anytime to cancel the engagement."); embedd.WithTitle("Which item would you like to use?"); embedd.WithDescription("These are all of the items you currently have"); int numkeys = 0; int numkeys2 = 0; int[] num = Enumerable.Range(0, config.Items.Keys.Count + 2).ToArray(); foreach (var keys in config.Items.Keys) { var entry = config.Items[keys]; if (entry == 0) { continue; } values = Helpers.GetValueFromKey(keys, user); int newnum = Helpers.GetNextElement(num, numkeys); numkeys++; embedd.AddField($"[{newnum}]", $"{keys} x {values}"); } var newGui = await Context.Channel.SendMessageAsync("", embed : embedd.Build()); var newresponsee = await NextMessageAsync(); string target = null; if (newresponsee == null) { await gui.DeleteAsync(); await newGui.DeleteAsync(); await SendMessage(Context, null, $"{Context.User.Mention},The interface has closed due to inactivity"); return; } if (newresponsee.Content.Equals("cancel", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { await gui.DeleteAsync(); await newGui.DeleteAsync(); await SendMessage(Context, null, $":shield: **|** **{Context.User.Username}**, engagement cancelled."); return; } await SendMessage(Context, null, "Who do you want to use this item on? (@mention them)"); var newresponseee = await NextMessageAsync(); if (!newresponseee.Content.Equals(Context.User.Username, StringComparison.CurrentCultureIgnoreCase) || !newresponseee.Content.Equals(config.OpponentName, StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { await gui.ModifyAsync(m => { m.Content = $"{Global.ENo} **|** That is an invalid response. Please try again."; }); return; } if (newresponseee.Content.Equals(Context.User.Username, StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { target = Context.User.Username; } if (newresponseee.Content.Equals(config.OpponentName, StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { target = config.OpponentName; } if (newresponseee.Content.Equals("cancel", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { await gui.ModifyAsync(m => { m.Content = $":shield: **|** **{Context.User.Username}**, engagement cancelled."; }); return; } if (newresponseee == null) { await gui.ModifyAsync(m => { m.Content = $"{Context.User.Mention}, The interface has closed due to inactivity"; }); return; } var itemChoosen = config.Items.ElementAt(int.Parse(newresponsee.ToString())).Key; var result = Helpers.ExecutePotion(Context, itemChoosen, config.Id, configg.Id); if (result.Success) { await SendMessage(Context, null, result.Response); var turnmsg = await NextTurn(Context); await SendMessage(Context, null, turnmsg); return; } else { await SendMessage(Context, null, result.Response); return; } } if (response.Content.Equals("3", StringComparison.CurrentCultureIgnoreCase) && (response.Author.Equals(Context.User))) { if (config.Fighting || configg.Fighting) { await ReplyAsync(":flag_white: **|** " + Context.User.Mention + " gave up. The fight stopped."); config.Wins += 1; configg.Losses += 1; await Reset(Context, activeChomusuke, activeChomusukee); GlobalUserAccounts.SaveAccounts(config.Id, configg.Id); } } if (response == null) { await gui.ModifyAsync(m => { m.Content = $"{Context.User.Mention}, The interface has closed due to inactivity"; }); return; } }