public async Task Give(int ID, IUser user) { var dbUser = DBFuncs.FindDBUser(Context.User); bool hasBall = false; int index = -1; for (int i = 0; i < dbUser.BallCount(); i++) { if (dbUser.heldBalls[i].ID == ID) { hasBall = true; index = i; break; } } if (hasBall) { DragonBall transferBall = dbUser.heldBalls[index]; dbUser.heldBalls.RemoveAt(index); DBFuncs.FindDBUser(user).heldBalls.Add(transferBall); transferBall.Holder = user; await Context.Channel.SendMessageAsync($"{Context.User.Mention} has given {user.Mention} the {transferBall.ID} Star Ball"); } else { await Context.Channel.SendMessageAsync("You do not have that ball."); } }
public async Task Train(string npcChoice, int choice) { foreach (DBNPC npc in NPCList.NPCs) { if (Context.Channel.Id == npc.Location) { if (npc.Name.ToLower().Contains(npcChoice.ToLower())) { if (choice == 1) { await Context.Channel.SendMessageAsync("", embed : DBFuncs.Dialogue(npc, npc.Response1)); Bot.sess.Players.Add(new DBUser(npc)); //AI?? npc.Fight(DBFuncs.FindDBUser(Context.User)); } else if (choice == 2) { await Context.Channel.SendMessageAsync("", embed : DBFuncs.Dialogue(npc, npc.Response2)); } } } } }
public async Task Skill(string skillName, IUser user) { DBUser dbUser = DBFuncs.FindDBUser(Context.User); DBUser target = DBFuncs.FindDBUser(user); DBSkill skill = DBFuncs.GetSkill(skillName); if (target.Location == Context.Channel.Id) { if (DBFuncs.HasSkill(skill, Context.User)) { if (dbUser.Energy >= skill.EnergyCost && !dbUser.Charging) { int power = skill.Power * Convert.ToInt32(DBFuncs.GetAttribute("POWER_LVL", Context.User)); await Context.Channel.SendMessageAsync($"{Context.User.Username} uses {skill.Name} on {user.Username} with a power of {power}"); dbUser.Charging = true; Timer timer = new Timer(await target.Hurt(Context.Channel, power), null, skill.Charge * 1000, Timeout.Infinite); } } else { await Context.Channel.SendMessageAsync("You do not have this skill!"); } } else { await Context.Channel.SendMessageAsync("That person is not here."); } }
public async Task Status(IUser user) { JEmbed JEmb = new JEmbed(); DBUser dbUser = DBFuncs.FindDBUser(user); JEmb.Author.Name = $"{user.Username}'s Status"; JEmb.ColorStripe = Funcs.GetColour(user, Context.Guild); JEmb.Description = "Health: " + dbUser.Health + "/" + dbUser.MaxHealth; await Context.Channel.SendMessageAsync("", embed : JEmb.Build()); }
public async Task Attack(IUser user) { DBUser attacker = DBFuncs.FindDBUser(Context.User); DBUser target = DBFuncs.FindDBUser(user); if (target.Location == Context.Channel.Id) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} attacks {user.Mention} with a power of {DBFuncs.GetPowerLVL(Context.User)}."); await target.Hurt(Context.Channel, DBFuncs.GetPowerLVL(Context.User)); } else { await Context.Channel.SendMessageAsync("That person is not here."); } }
public async Task HandleReady() { try { foreach (IUser user in client.GetGuild(Constants.Guilds.DBZ_EARTH).Users) { if (DBFuncs.PlayerRegistered(user)) { if (DBFuncs.GetAttribute("LOCATION", user) != "null") { DBFuncs.FindDBUser(user).Location = Convert.ToUInt64(DBFuncs.GetAttribute("LOCATION", user)); } } } } catch (Exception e) { Console.WriteLine(e.Message); } }
public async Task HandleCommand(SocketMessage messageParam) { var message = messageParam as SocketUserMessage; if (message == null) { return; } int argPos = 0; if (!Constants.Channels.BLOCKED_CHANNELS.Contains(message.Channel.Id)) { DBUser user = DBFuncs.FindDBUser(message.Author); user.Location = message.Channel.Id; DBFuncs.SetAttribute("LOCATION", message.Author, Convert.ToString(message.Channel.Id)); } //changed prefix to db! because even though bot is called shenron, its more DB in general. if (message.HasStringPrefix("db!", ref argPos)) { if (DBFuncs.PlayerRegistered(message.Author) || message.Content.StartsWith("db!register") || message.Content.StartsWith("db!help")) { var context = new CommandContext(client, message); var result = await commands.ExecuteAsync(context, argPos); if (!result.IsSuccess) { Console.WriteLine(result.ErrorReason); } } else { await message.Channel.SendMessageAsync($"{message.Author.Mention}, you must register with `db!register` before using commands."); } } else { return; } }
public async Task PickUp() { var user = DBFuncs.FindDBUser(Context.User); if (!user.IsDead) { for (int i = 0; i < 7; i++) { if (Bot.sess.Balls[i].Location == Context.Channel && Bot.sess.Balls[i].Held == false) { await Context.Channel.SendMessageAsync($"{Context.User.Username} collects the {Bot.sess.Balls[i].ID} star Dragon Ball."); var dbUser = DBFuncs.FindDBUser(Context.User); dbUser.heldBalls.Add(Bot.sess.Balls[i]); Console.WriteLine($"{Context.User.Username} has picked up the { Bot.sess.Balls[i].ID} star Dragon Ball in {Context.Channel.Name} of {Context.Guild.Name}."); Bot.sess.Balls[i].Holder = Context.User; Bot.sess.Balls[i].Held = true; await Bot.sess.Balls[i].Msg1.DeleteAsync(); await Bot.sess.Balls[i].Msg2.DeleteAsync(); } } } }
public async Task Wish(string wish, IUser user) { if (DBFuncs.FindDBUser(user).BallCount() == 7) { if (wish == "list") { JEmbed jemb = new JEmbed(); jemb.Author.Name = "Wish List"; jemb.Author.IconUrl = Bot.client.CurrentUser.GetAvatarUrl(); jemb.ColorStripe = Constants.Colours.SHENRON_GREEN; int counter = 1; foreach (string item in File.ReadAllLines(@"Files\wishes.txt")) { jemb.Fields.Add(new JEmbedField(x => { x.Header = $"[{counter}]"; x.Text = item; })); counter++; } await Context.Channel.SendMessageAsync("", embed : jemb.Build()); } else if (wish == "1") { int currentLVL = Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", user)); int newLVL = currentLVL + 10; DBFuncs.SetAttribute("LEVEL", user, Convert.ToString(newLVL)); await Context.Channel.SendMessageAsync($"Your wish has been granted... {user.Username}! You are now level {newLVL}."); } else if (wish == "2") { } //increase currency else if (wish == "3") { } //give skill else if (wish == "4") { } //custom else { await Context.Channel.SendMessageAsync($"Wish '{wish}' does not exist. Refer to the wish by it's ID number."); return; } for (int i = 0; i < 7; i++) { if (Bot.sess.Balls[i].Location == null && Bot.sess.Balls[i].Held == false) { var dbUser = DBFuncs.FindDBUser(Context.User); dbUser.heldBalls.Clear(); Bot.sess.Balls[i].Holder = null; Bot.sess.Balls[i].Held = false; Bot.sess.End(); } } } else { await Context.Channel.SendMessageAsync("Shenron cannot be summoned without all seven **Dragon Balls**!"); } }