Esempio n. 1
0
        public IEnumerable <Game> FindListings(MapFlags map, int impostorCount, GameKeywords language, int count = 10)
        {
            int results = 0;

            // Find games that have not started yet.
            foreach (var(_, game) in _games.Where(x =>
                                                  x.Value.IsPublic &&
                                                  x.Value.GameState == GameStates.NotStarted &&
                                                  x.Value.PlayerCount < x.Value.Options.MaxPlayers))
            {
                // Check for options.
                if (!map.HasFlag((MapFlags)(1 << (byte)game.Options.Map)))
                {
                    continue;
                }

                if (!language.HasFlag(game.Options.Keywords))
                {
                    continue;
                }

                if (impostorCount != 0 && game.Options.NumImpostors != impostorCount)
                {
                    continue;
                }

                // Add to result.
                yield return(game);

                // Break out if we have enough.
                if (++results == count)
                {
                    yield break;
                }
            }
        }
 public static int GetGameCount(this IGameManager manager, MapFlags map)
 {
     return(manager.Games.Count(game => map.HasFlag((MapFlags)(1 << game.Options.MapId))));
 }