Пример #1
0
        public async void LaunchBalls()
        {
            IGuild[] guilds = { Bot.client.GetGuild(Constants.Guilds.DBZ_EARTH), Bot.client.GetGuild(Constants.Guilds.DBZ_NAMEK), Bot.client.GetGuild(Constants.Guilds.DBZ_VEGETA) };
            Random   rdm    = new Random();

            Balls = new DragonBall[7];

            for (int i = 0; i < 7; i++)
            {
                var guild = guilds[rdm.Next(guilds.Length)];
                var chans = await guild.GetTextChannelsAsync();

                ITextChannel chan;
                while (true)
                {
                    int chanNum = rdm.Next(chans.Count);
                    chan = chans.ElementAt(chanNum);
                    bool no = false;
                    for (int a = 0; a < Constants.Channels.BLOCKED_CHANNELS.Count(); a++)
                    {
                        if (Constants.Channels.BLOCKED_CHANNELS[a] == (chan.Id))
                        {
                            no = true;
                        }
                    }


                    if (!no)
                    {
                        break;
                    }
                }
                Balls[i] = new DragonBall(chan, i + 1);
            }
        }
Пример #2
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.");
            }
        }