Beispiel #1
0
        private static async void QuizEnded(object sender, ElapsedEventArgs e)
        {
            var guild                = GlobalVar.QuizGuild;
            var users                = guild.Users;
            int highscores           = 0;
            List <SocketUser> winner = new List <SocketUser>();
            var role = from r in guild.Roles
                       where r.Name.Equals("Survivor")
                       select r;
            var des = role.FirstOrDefault();
            List <UserAccount> pacito = UserAccounts.UserAccounts.GetAllAliveUsers();
            await Task.Delay(3000);

            await channel.SendMessageAsync($"The right answer is {GlobalVar.Selected.RightAnswer}");

            await Task.Delay(1000);

            foreach (var p in pacito)
            {
                await UserAccounts.UserAccounts.StatusAilment(p);

                var realuser = GlobalVar.QuizGuild.GetUser(p.ID);
                await SurvivorInventory.Inventories.PassiveItem(realuser);

                await SurvivorInventory.Inventories.CountDownItem(realuser);
            }
            string text = "";

            foreach (var u in users)
            {
                var temp = (SocketGuildUser)u;
                if (temp.Roles.Contains(des))
                {
                    var user = UserAccounts.UserAccounts.GetUserAccount(temp);
                    UserAccounts.UserAccounts.AddAllPoints(user);
                    text += $"{temp.Mention}\nHP : {user.HP}\n" +
                            $"POINT : {user.Points}\nKILL : {user.Kills}\n";
                    //item
                    text += "Inventory : \n";
                    int num = 0;
                    for (int i = 0; i < user.Inventory.Items.Count; i++)
                    {
                        text += $"Item-{i + 1}: {user.Inventory.Items[i].Name}";
                        if (user.Inventory.Items[i].Countdown != -1)
                        {
                            text += $" ({user.Inventory.Items[i].Countdown})";
                        }
                        text += "\n";
                        num++;
                    }
                    for (int i = num; i < 3; i++)
                    {
                        text += $"Item-{i + 1}: ---\n";
                    }

                    //buff
                    text += "Buffs : \n";
                    num   = 0;
                    for (int i = 0; i < user.Buffs.Count; i++)
                    {
                        text += $"Buff-{i + 1}: {user.Buffs[i].Name} ({user.Buffs[i].Countdown})\n";
                        num++;
                    }
                    for (int i = num; i < 3; i++)
                    {
                        text += $"Buff-{i + 1}: ---\n";
                    }

                    //debuff
                    text += "Debuffs : \n";
                    num   = 0;
                    for (int i = 0; i < user.Debuffs.Count; i++)
                    {
                        text += $"Debuff-{i + 1}: {user.Debuffs[i].Name} ({user.Debuffs[i].Countdown})\n";
                        num++;
                    }
                    for (int i = num; i < 3; i++)
                    {
                        text += $"Debuff-{i + 1}: ---\n";
                    }
                    text += "\n\n";
                    if (user.TempPoint != 0)
                    {
                        if (winner.Count == 0)
                        {
                            highscores = user.TempPoint;
                            winner.Add(temp);
                        }
                        else
                        {
                            var despacito = UserAccounts.UserAccounts.GetUserAccount(winner[winner.Count - 1]);
                            if (user.TempPoint > highscores)
                            {
                                highscores = user.TempPoint;
                                winner.Remove(winner[winner.Count - 1]);
                                winner.Add(temp);
                            }
                            else if (user.TempPoint == highscores)
                            {
                                highscores = user.TempPoint;
                                winner.Add(temp);
                            }
                        }
                    }
                    UserAccounts.UserAccounts.ResetTempPoint(user);
                    if ((text.Length + 300) > 2048)
                    {
                        await channel.SendMessageAsync(text);

                        text = "";
                    }
                }
            }
            timers.Clear();
            await Task.Delay(1000);

            await channel.SendMessageAsync(text);

            await Task.Delay(1000);

            await Quizzes.GiveDrops(winner, channel);

            GlobalVar.QuizHasBeenStarted = false;
            GlobalVar.CanUseItem         = false;
            GlobalVar.Selected           = null;
            GlobalVar.QuizGuild          = null;
        }