Example #1
0
        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.");
            }
        }
Example #2
0
        public async Task HandleJoin(SocketGuildUser user)
        {
            ulong ID = user.Guild.Id;

            IChannel chan = user.Guild.GetChannel(Constants.Channels.EARTH_GEN);

            if (ID == Constants.Guilds.DBZ_EARTH)
            {
                chan = user.Guild.GetChannel(Constants.Channels.EARTH_GEN);
            }
            else if (ID == Constants.Guilds.DBZ_NAMEK)
            {
                chan = user.Guild.GetChannel(Constants.Channels.NAMEK_GEN);
            }
            else if (ID == Constants.Guilds.DBZ_VEGETA)
            {
                chan = user.Guild.GetChannel(Constants.Channels.VEGETA_GEN);
            }
            var    mChan = chan as IMessageChannel;
            string reg   = "";

            if (DBFuncs.PlayerRegistered(user))
            {
                DBFuncs.LoadRoles(user);
            }
            else
            {
                reg = " Use `db!register [race]` to register as either a Human, Namekian, or Saiyan.";
            }
            await mChan.SendMessageAsync($"{user.Mention} has entered {user.Guild.Name.Replace("DBZ ", "")}.{reg}");
        }
Example #3
0
        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.");
            }
        }
Example #4
0
        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));
                        }
                    }
                }
            }
        }
Example #5
0
 public DBUser(IUser user)
 {
     User      = user;
     heldBalls = new List <DragonBall>();
     Energy    = Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", User)) * 100;
     Health    = Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", User)) * 100;
     MaxHealth = Health;
 }
Example #6
0
        public async Task Scouter(IUser user)
        {
            var JEmb = new JEmbed();

            JEmb.Author.Name = $"{user.Username}'s Power Level";
            JEmb.ColorStripe = Funcs.GetColour(user, Context.Guild);
            JEmb.Description = Convert.ToString(DBFuncs.GetPowerLVL(user));

            await Context.Channel.SendMessageAsync("", embed : JEmb.Build());
        }
Example #7
0
        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());
        }
Example #8
0
        public async Task Register(string race)
        {
            race = race.ToLower();
            if (DBFuncs.PlayerRegistered(Context.User))
            {
                await Context.Channel.SendMessageAsync($"{Context.User.Mention} has already registered.");
            }
            else if (race == "human" || race == "saiyan" || race == "namekian")
            {
                Player.Race wRace  = Player.Race.Human;
                string      planet = "";

                if (race == "human")
                {
                    wRace = Player.Race.Human; planet = "Earth: https://discord.gg/UwDKgAF";
                }
                else if (race == "saiyan")
                {
                    wRace = Player.Race.Saiyan; planet = "Vegeta: https://discord.gg/vFaS8u2";
                }
                else if (race == "namekian")
                {
                    wRace = Player.Race.Namekian; planet = "Namek: https://discord.gg/tJVfgms";
                }


                string[] toWrite = new string[9];
                toWrite[0] = Context.User.Username;
                toWrite[1] = $"RACE: {wRace}";
                toWrite[2] = "POWER_LVL: 10";
                toWrite[3] = "MULTIPLIER: 1";
                toWrite[4] = "ENERGY: 100";
                toWrite[5] = "LEVEL: 1";
                toWrite[6] = "EXP: 0";
                toWrite[7] = "LOCATION: null";
                toWrite[8] = "SKILLS:";

                File.WriteAllLines($@"Players\{Context.User.Id}.txt", toWrite);

                DBFuncs.LoadRoles(Context.User);


                await Context.Channel.SendMessageAsync($"{Context.User.Mention} has successfully registered as a {wRace}. Go forth to Planet {planet}.");
            }
            else
            {
                await Context.Channel.SendMessageAsync("Please choose either Human, Saiyan, or Namekian as your race. `db!register [race]`");
            }
        }
Example #9
0
        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.");
            }
        }
Example #10
0
        public TimerCallback Timer(DBUser target)
        {
            Random rdm = new Random();

            if (rdm.Next(100) > 30)
            {
                var emb = DBFuncs.Dialogue(this, $"{Name} attacks {target.User.Username}, doing {Power_Level} damage.");
                Place.SendMessageAsync("", embed: emb);
            }
            else
            {
                if (Skill != null)
                {
                    UseSkill(Skill, target);
                }
            }


            return(null);
        }
Example #11
0
 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);
     }
 }
Example #12
0
        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;
            }
        }
Example #13
0
        public async Task Profile(IUser user)
        {
            if (DBFuncs.PlayerRegistered(user))
            {
                var emb = new JEmbed()
                {
                    ThumbnailUrl = user.GetAvatarUrl(),
                    ColorStripe  = Funcs.GetColour(user, Context.Guild)
                };
                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Race";
                    x.Text   = DBFuncs.GetAttribute("RACE", user);
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "Level";
                    x.Text   = DBFuncs.GetAttribute("LEVEL", user);
                    x.Inline = true;
                }));

                emb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "EXP";
                    x.Text   = DBFuncs.GetAttribute("EXP", user) + "/" + Convert.ToString(Math.Pow(Convert.ToInt32(DBFuncs.GetAttribute("LEVEL", user)), 2) + 10);
                    x.Inline = true;
                }));

                emb.Author.Name = user.Username + "'s Profile";

                var embed = emb.Build();
                await Context.Channel.SendMessageAsync("", embed : embed);
            }
            else
            {
                await Context.Channel.SendMessageAsync("Player in not registered");
            }
        }
Example #14
0
        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();
                    }
                }
            }
        }
Example #15
0
 public async Task GiveEXP(int amount, IUser user)
 {
     DBFuncs.AddEXP(user, amount);
     await Context.Channel.SendMessageAsync($"{user.Mention} has been given {amount} EXP.");
 }
Example #16
0
 public void Die()
 {
     Place.SendMessageAsync("", embed: DBFuncs.Dialogue(this, DefeatResponse));
 }
Example #17
0
        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**!");
            }
        }
Example #18
0
        public async Task Train()
        {
            List <DBNPC>  inLocation = new List <DBNPC>();
            List <DBUser> here       = new List <DBUser>();

            foreach (DBNPC npc in NPCList.NPCs)
            {
                if (Context.Channel.Id == npc.Location)
                {
                    inLocation.Add(npc);
                }
            }

            foreach (DBUser user in Bot.sess.Players)
            {
                string location = DBFuncs.GetAttribute("LOCATION", user.User);
                if (location != "null")
                {
                    if (Context.Channel.Id == Convert.ToUInt64(location) && user.User.Id != Context.User.Id)
                    {
                        here.Add(user);
                    }
                }
            }

            var JEmb = new JEmbed();

            JEmb.Description = "People in area:";

            if (inLocation.Count > 0 || here.Count > 0)
            {
                foreach (DBNPC npc in inLocation)
                {
                    JEmb.Fields.Add(new JEmbedField(x =>
                    {
                        x.Header = npc.Name + " [NPC]";
                        x.Text   = $"Power Level: ~{npc.Power_Level}";
                    }));
                }

                foreach (DBUser user in here)
                {
                    JEmb.Fields.Add(new JEmbedField(x =>
                    {
                        x.Header = user.User.Username + " [PLAYER]";
                        x.Text   = $"Power Level: ~{DBFuncs.GetPowerLVL(user.User)}";
                    }));
                }

                JEmb.ColorStripe = Funcs.GetColour(Context.User, Context.Guild);
                JEmb.Footer.Text = "Type 'db!train [name]' to request to train with them!";
            }
            else
            {
                JEmb.Fields.Add(new JEmbedField(x =>
                {
                    x.Header = "None";
                    x.Text   = "There seems to be no one here.. Check another area.";
                }));
            }

            await Context.Channel.SendMessageAsync("", embed : JEmb.Build());
        }
Example #19
0
        public async Task Power(string direction, int amount)
        {
            if (direction == "up")
            {
                string race  = DBFuncs.GetAttribute("RACE", Context.User);
                IGuild guild = Bot.client.GetGuild(Constants.Guilds.DBZ_EARTH);
                var    user  = await guild.GetUserAsync(Context.User.Id);

                ulong[] role = new ulong[3];

                for (int i = 0; i < amount; i++)
                {
                    if ((user.RoleIds.Contains(Constants.Roles.KAIOKEN[0]) || role == Constants.Roles.KAIOKEN) && DBFuncs.HasSkill("Super Saiyan", Context.User))
                    {
                        await Power("down");

                        role = Constants.Roles.SUPER;
                    }
                    else if ((user.RoleIds.Contains(Constants.Roles.SUPER[0]) || role == Constants.Roles.SUPER) && DBFuncs.HasSkill("SSGSS", Context.User))
                    {
                        await Power("down");

                        role = Constants.Roles.SSGSS;
                    }
                    else if (DBFuncs.HasSkill("Kaioken", Context.User) && !user.RoleIds.Contains(Constants.Roles.SSGSS[0]))
                    {
                        role = Constants.Roles.KAIOKEN;
                    }
                }

                if (role[0] != 0)
                {
                    Funcs.GiveRole(role, Context.User);
                    DBSkill skill = DBFuncs.GetSkill(guild.GetRole(role[0]).Name);
                    DBFuncs.SetAttribute("MULTIPLIER", Context.User, Convert.ToString(skill.Power));
                }
                else
                {
                    await Context.Channel.SendMessageAsync("You attempt to power up further, but fail.");
                }
            }
            else if (direction == "down")
            {
                var guilds = Constants.Guilds.PLANETS;
                for (int i = 0; i < 3; i++)
                {
                    var guildID = guilds.ElementAt(i);
                    var guild   = Bot.client.GetGuild(guildID);
                    if (await Funcs.InGuild(guild, Context.User))
                    {
                        var user = guild.GetUser(Context.User.Id);
                        if (user.Roles.Contains(guild.GetRole(Constants.Roles.KAIOKEN[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.KAIOKEN[i]));
                        }
                        else if (user.Roles.Contains(guild.GetRole(Constants.Roles.SUPER[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.SUPER[i]));
                        }
                        else if (user.Roles.Contains(guild.GetRole(Constants.Roles.SSGSS[i])))
                        {
                            await user.RemoveRoleAsync(guild.GetRole(Constants.Roles.SSGSS[i]));
                        }
                    }
                    DBFuncs.SetAttribute("FORM", Context.User, "1");
                }
                DBFuncs.SetAttribute("MULTIPLIER", Context.User, "1");
            }
        }
Example #20
0
        public async Task MovePlanet(string planet)
        {
            string msg = await DBFuncs.MoveToPlanet(Context.User, planet);

            await Context.Channel.SendMessageAsync(msg);
        }