Exemplo n.º 1
0
        // Generate two (roughly even) teams from the existing players in Allplayers
        public void GenerateTeam()
        {
            Random rand       = new Random();
            int    counter    = 0;
            int    counterLim = AllPlayers.Count / 2;
            int    randomIndex;

            Console.WriteLine($"Assigning {AllPlayers.Keys.Count} Players...");

            // Reset team states
            Console.WriteLine("Resetting current team...");
            DiscordMember[] keys = new DiscordMember[AllPlayers.Keys.Count];
            AllPlayers.Keys.CopyTo(keys, 0);
            foreach (DiscordMember key in keys)
            {
                Console.WriteLine($"{key.Username}'s being removed from team");
                AllPlayers[key] = -1;
                Console.WriteLine($"{key.Username}'s team has been removed.");
            }
            Console.WriteLine("Clearing team lists");
            Team1.Clear();
            Team2.Clear();

            //Randomly assigns 1 to the Half of all players
            Console.WriteLine($"Team 1 will have {counterLim} Players.");
            while (counter < counterLim)
            {
                randomIndex = rand.Next(AllPlayers.Count);
                DiscordMember key = keys[randomIndex];
                if (AllPlayers[key] == -1)
                {
                    AllPlayers[key] = 1;
                    Team1.Add(key);
                    Console.WriteLine($"{key.Username} has been added to Team 1");
                    counter++;
                }
            }

            //Adds the remaining Users to the Team 2
            Console.WriteLine($"Team 2 will have {AllPlayers.Count - counterLim} Players.");
            foreach (DiscordMember key in keys)
            {
                if (!Team1.Contains(key))
                {
                    AllPlayers[key] = 2;
                    Team2.Add(key);
                    Console.WriteLine($"{key.Username} has been added to Team 2");
                }
            }
        }
Exemplo n.º 2
0
 public void DefenderDies(Character defender)
 {
     if (Team1.Contains(defender))
     {
         Team1.Remove(defender);
         if (Team1.Count <= 0)
         {
             WinnerTeam = Team2;
         }
     }
     if (Team2.Contains(defender))
     {
         Team2.Remove(defender);
         if (Team2.Count <= 0)
         {
             WinnerTeam = Team1;
         }
     }
 }
Exemplo n.º 3
0
 public bool IsParticipant(Entity entity)
 {
     return(Team1.Contains(entity) || Team2.Contains(entity));
 }