public ContinentSelectorOptions(IAppSettings settings, ICountryCollection collection, ContinentSelectorFlags flags) { IgnoreBorderExlusion = (flags & ContinentSelectorFlags.IgnoreBorderExlusion) != 0; _counts = new IDictionary<Continent, int>[] { GetCountryCount(collection, IgnoreBorderExlusion, (flags & ContinentSelectorFlags.LimitByNeighbors) != 0, (flags & ContinentSelectorFlags.LimitByContinent) != 0, false), GetCountryCount(collection, IgnoreBorderExlusion, (flags & ContinentSelectorFlags.LimitByNeighbors) != 0, (flags & ContinentSelectorFlags.LimitByContinent) != 0, true) }; var continent = new ChoiceOption<Continent>("continent", "Continent", Enum .GetValues(typeof(Continent)) .Cast<Continent>(); var maritime = new ToggleOption("maritime", "Use Maritime Borders", false, (flags & ContinentSelectorFlags.MaritimeBorders) != 0, p => RefreshValues()); _optionsList.AddOption(continent); _optionsList.AddOption(maritime); if ((flags & ContinentSelectorFlags.RangeLimits) != 0) { var limit = _counts[0][Continent.Unspecified]; var min = new RangedOption<int>("min", "Countries (min)", 1, 1, limit, p => RefreshValues()); var max = new RangedOption<int>("max", "Countries (max)", limit, 1, limit, p => RefreshValues()); min.Depandancies = new List<IOption> { continent, maritime, max }; max.Depandancies = new List<IOption> { continent, maritime, min }; _optionsList.AddOption(min); _optionsList.AddOption(max); _hasRange = true; } }
public GameProvider(IAppSettings settings, ITimerService timerService, ICountryCollection countryCollection) { _games = new List <IGameDescription>() { new FlagsMapGame.GameDescription(settings, timerService, countryCollection), new FlagsQuizGame.GameDescription(FlagsQuizGame.Direction.GuessFlag, settings, timerService, countryCollection), new FlagsQuizGame.GameDescription(FlagsQuizGame.Direction.GuessName, settings, timerService, countryCollection), }; }
public GameDescription(IAppSettings settings, ITimerService timerService, ICountryCollection countryCollection) { _timerService = timerService; _countryCollection = countryCollection; Selectors = new List <ICountrySelector> { new ContinentSelector(settings, countryCollection), new RegionSelector(settings, countryCollection), new NeighborsSelector(settings, countryCollection), }; }
private IDictionary<Continent, int> GetCountryCount(ICountryCollection collection, bool ignoreExlusion, bool neighbors, bool maxContinent, bool maritime) { var counts = collection.Countries .GroupBy(c => c.Continent) .Select(i => new { Continent = i.Key, Count = neighbors ? i.Max(c => c.Borders .Where(b => (b.HasLandBorder || (b.HasMaritimeBorder && maritime)) && (!b.Excluded || ignoreExlusion)) .Count()) : i.Count() }) .ToList(); return counts .Union(Enumerable.Repeat(new { Continent = Continent.Unspecified, Count = neighbors || maxContinent ? counts.Max(c => c.Count) : collection.Countries.Count() }, 1)) .ToDictionary(k => k.Continent, v => v.Count); }
public ContinentSelector(IAppSettings settings, ICountryCollection collection) { _settings = settings; _collection = collection; }
public RegionSelector(IAppSettings settings, ICountryCollection collection) { _settings = settings; _collection = collection; }
public FlagsMapGame(IOptions gameOptions, ICountrySelector selector, IOptions selectorOptions, ITimerService timerService, ICountryCollection countryCollection) : base(gameOptions, selector, selectorOptions, timerService) { _randomizedContryList = countryCollection.Countries .Select(c => new { Country = c, Order = _random.Next() }) .OrderBy(i => i.Order) .Select(i => i.Country) .ToList(); }
public NeighborsSelector(IAppSettings settings, ICountryCollection collection) { _settings = settings; _collection = collection; }