Esempio n. 1
0
        public async Task <IEnumerable <IGameRole> > GenerateCivilianRoles(int count)
        {
            var everyone = GaiaMembers.Concat(GuardianMembers).Concat(OCMembers).Concat(Civilians);
            var all_ids  = new ulong[] { Occult_Club.Id, Guardian.Id, Gaia.Id };

            if (count < 4)
            {
                var random_players = (await ServerHost.GetUsersAsync())
                                     .Where((x) => !x.IsBot &&
                                            !everyone.Contains(x) &&
                                            !x.RoleIds.Any((y) => all_ids.Contains(y))
                                            );
                var random_numbers    = new int[4 - count];
                var total_non_playing = random_players.Count();
                var resultMsg         = String.Empty;
                for (int i = 0; i < 4 - count; i++)
                {
                    do
                    {
                        random_numbers[i] = Randomizer.Next(total_non_playing);
                    } while (random_numbers.Take(i).Contains(random_numbers[i]));
                    var memToAdd = random_players.ElementAt(random_numbers[i]);
                    Civilians.Add(memToAdd);
                    await memToAdd.AddRoleAsync(GvG_Player);

                    resultMsg += $"Because there are too few players, {memToAdd.Mention} is forced to join the game as a Civilian" + ((i == count - 1) ? "" : Environment.NewLine);
                }
                Public_GvG.SendMessageAsync(resultMsg);
            }
            IEnumerable <IGameRole> result = new IGameRole[] { new Kagari(), new NormalCivilian(), new NormalCivilian(), new NormalCivilian() };

            if (count > 4)
            {
                for (int i = 0; i < count - 4; i++)
                {
                    result = result.Append(new NormalCivilian());
                }
            }
            return(result.OrderBy((x) => Randomizer.Next()));
        }
Esempio n. 2
0
        internal async Task ForceJoin(IRole role, List <IGuildUser> roleMembers, int members)
        {
            var possibleMembers = (await ServerHost.GetUsersAsync()).Where((x) => x.RoleIds.Contains(role.Id) && !roleMembers.Contains(x));

            int[]  randomMembers = new int[members];
            string resultMsg     = string.Empty;

            for (int i = 0; i < members; i++)
            {
                do
                {
                    randomMembers[i] = Randomizer.Next(possibleMembers.Count());
                } while (randomMembers.Take(i).Contains(randomMembers[i]));
                var memToAdd = possibleMembers.ElementAt(randomMembers[i]);
                roleMembers.Add(memToAdd);
                resultMsg += $"Because there are too few players, {memToAdd.Mention} is forced to join the game as {role?.Mention}" + ((i == members - 1) ? "" : Environment.NewLine);
                await memToAdd.AddRoleAsync(GvG_Player);

                // force join member goes here.
            }

            await Public_GvG.SendMessageAsync(resultMsg);
        }