Exemple #1
0
        public async Task ShowList()
        {
            if (!IsUserRaidLeader((SocketGuildUser)Context.User))
            {
                return;
            }

            var sb       = new StringBuilder();
            var accounts = UserAccounts.GetListAccounts();
            int i        = 1;

            foreach (var account in accounts)
            {
                var      curUsername = String.Format("{0}{1}{2}", Context.Guild.GetUser(account.UserID).Username, "#", Context.Guild.GetUser(account.UserID).DiscriminatorValue);
                TimeSpan time        = TimeSpan.FromSeconds(account.Time);
                sb.Append(String.Format("{0}.{1}  -  DKP:[{2}]  -  Time:[{3}]" + Environment.NewLine, i, curUsername, account.PointsDKP, time.ToString(@"hh\:mm\:ss")));
                i++;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(new Color(10, 255, 10));
            embed.WithTitle("DATA-MEMBER LIST:");

            embed.WithDescription(sb.ToString());
            await Context.Channel.SendMessageAsync("", false, embed.Build(), null);
        }
Exemple #2
0
        public async Task RewardDKP(uint dkp)
        {
            if (!IsUserRaidLeader((SocketGuildUser)Context.User))
            {
                return;
            }

            var onlineUsers = Context.Guild.Users.Where(x => x.Status.ToString() == "Online");

            var accounts = UserAccounts.GetListAccounts();

            foreach (var account in accounts)
            {
                foreach (var onlineUser in onlineUsers)
                {
                    // if user dont have "In Raid" role, continue
                    if (!IsUserCurrentlyInRaid((SocketGuildUser)onlineUser))
                    {
                        continue;
                    }

                    if (account.UserID == onlineUser.Id)
                    {
                        account.PointsDKP += dkp;
                        continue;
                    }
                }
            }

            UserAccounts.SaveAccounts();
            await Context.Channel.SendMessageAsync($"**All raid members got {dkp} dkp.**");
        }
Exemple #3
0
        public async Task StopRaid()
        {
            if (_raidStartSignal == false)
            {
                await Context.Channel.SendMessageAsync($"Raid is not activated!");

                return;
            }

            if (!IsUserRaidLeader((SocketGuildUser)Context.User))
            {
                return;
            }

            stopwatchRaidingTime.Stop();
            _raidStartSignal = false;

            TimeSpan time = TimeSpan.FromSeconds(GetPassedTime());


            var onlineUsers = Context.Guild.Users;
            var accounts    = UserAccounts.GetListAccounts();

            foreach (var account in accounts)
            {
                foreach (var onlineUser in onlineUsers)
                {
                    // if user have "In Raid" role add time
                    if (!IsUserCurrentlyInRaid((SocketGuildUser)onlineUser))
                    {
                        continue;
                    }

                    if (account.UserID == onlineUser.Id)
                    {
                        account.Time += GetPassedTime();
                        break;
                    }
                }
            }

            UserAccounts.SaveAccounts();
            await Context.Channel.SendMessageAsync($"** RAID STOPPED ** -- Time elapsed: **[{time.ToString(@"hh\:mm\:ss")}]** ");
        }
Exemple #4
0
        public async Task InRaid()
        {
            if (!IsUserRaidLeader((SocketGuildUser)Context.User))
            {
                return;
            }

            var sb          = new StringBuilder();
            var onlineUsers = Context.Guild.Users;
            int i           = 1;

            foreach (var onlineUser in onlineUsers)
            {
                // if user dont have "In Raid" role, continue
                if (!IsUserCurrentlyInRaid((SocketGuildUser)onlineUser))
                {
                    continue;
                }

                var    accounts = UserAccounts.GetListAccounts();
                string dkp      = "";
                foreach (var account in accounts)
                {
                    if (onlineUser.Id == account.UserID)
                    {
                        dkp = account.PointsDKP.ToString();
                        break;
                    }
                }

                var curUsername = String.Format("{0}{1}{2}", Context.Guild.GetUser(onlineUser.Id).Username, "#", onlineUser.DiscriminatorValue);
                sb.Append(String.Format("{0}.{1} - [dkp:{2}]" + Environment.NewLine, i, curUsername, dkp));
                i++;
            }

            var embed = new EmbedBuilder();

            embed.WithColor(new Color(10, 255, 10));
            embed.WithTitle($"IN RAID MEMBERS: [{i - 1}] ");

            embed.WithDescription(sb.ToString());
            await Context.Channel.SendMessageAsync("", false, embed.Build(), null);
        }
Exemple #5
0
        private async void AuctionFunction()
        {
            int  tempSec     = 0;
            int  auctionTime = Config.bot.auctionTime;
            bool signalTen   = true;
            bool signalFive  = true;

            try
            {
                stopwatchAuctionTime.Reset();
                stopwatchAuctionTime.Start();
                _auctionSignal = true;

                while (tempSec <= auctionTime)
                {
                    Thread.Sleep(100);
                    TimeSpan ts = stopwatchAuctionTime.Elapsed;
                    tempSec = ts.Seconds;

                    //display last 10 sec of auction time
                    if (auctionTime - tempSec == 10 && signalTen)
                    {
                        signalTen = false;
                        await Context.Channel.SendMessageAsync($"Auction ends in 10 sec...");
                    }

                    //display last 5 sec of auction time
                    if (auctionTime - tempSec == 5 && signalFive)
                    {
                        signalFive = false;
                        await Context.Channel.SendMessageAsync($"Auction ends in 5 sec...");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in Auction Thread:\n" + ex.Message);
            }

            tempSec        = 0;
            signalTen      = true;
            signalFive     = true;
            _auctionSignal = false;

            stopwatchAuctionTime.Stop();
            stopwatchAuctionTime.Reset();

            var account = UserAccounts.GetListAccounts().Where(x => x.UserID == _lastUserIdBid).SingleOrDefault();

            if (account != null)
            {
                account.PointsDKP -= _lastBid;
                UserAccounts.SaveAccounts();

                await Context.Channel.SendMessageAsync($"**Auction has ended!** (total bids:{_bidCounter}) - **{account.Username}, has won the {_auctionItemName}.** {account.Username}, your current dkp: [{account.PointsDKP}]");
            }
            else
            {
                await Context.Channel.SendMessageAsync($"**Auction has ended!** - For item:**{_auctionItemName}** - NO BIDS PLACED!");
            }

            _lastBid         = 0;
            _lastUserIdBid   = 0;
            _auctionItemName = String.Empty;
        }
Exemple #6
0
        public async Task Bid(uint dkp)
        {
            if (!IsUserCurrentlyInRaid((SocketGuildUser)Context.User))
            {
                return;
            }

            if (!_auctionSignal)
            {
                await Context.Channel.SendMessageAsync($"** Auction not started yet! **");

                return;
            }

            if (dkp % Config.bot.minBid != 0)
            {
                await Context.Channel.SendMessageAsync($"~~ Bid must be divisible with number: {Config.bot.minBid}");

                return;
            }

            if (dkp == 0)
            {
                await Context.Channel.SendMessageAsync($"~~ Bid must be greater then: ZERO");

                return;
            }


            if (Context.User.Id == _lastUserIdBid)
            {
                await Context.Channel.SendMessageAsync($"~~ You already place your bid!");

                return;
            }

            if (dkp <= _lastBid)
            {
                await Context.Channel.SendMessageAsync($"~~ Bid must be greater then last bid: {_lastBid}");

                return;
            }

            var account = UserAccounts.GetListAccounts().Where(x => x.UserID == Context.User.Id).SingleOrDefault();

            if (account != null)
            {
                if (account.PointsDKP >= dkp) // OK
                {
                    _lastBid       = dkp;
                    _lastUserIdBid = Context.User.Id;
                    _bidCounter++;
                    var embed = new EmbedBuilder();
                    embed.WithTitle($"**{_bidCounter}. BID ACCEPTED FOR:**");
                    embed.WithDescription($"**{Context.User.Username} - dkp:[{dkp}]**");
                    embed.WithColor(new Color(0, 255, 0));
                    await Context.Channel.SendMessageAsync("", false, embed.Build(), null);

                    //await Context.Channel.SendMessageAsync($"**Bid accepted for {Context.User.Username} - dkp:[{dkp}]**");
                }
                else
                {
                    await Context.Channel.SendMessageAsync($"~~ Not enough dkp:[{account.PointsDKP}] - you bid with:[{dkp}]");
                }
            }
        }