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;
			}
		}
예제 #2
0
 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),
     };
 }
예제 #3
0
            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);
		}
예제 #5
0
 public ContinentSelector(IAppSettings settings, ICountryCollection collection)
 {
     _settings   = settings;
     _collection = collection;
 }
예제 #6
0
 public RegionSelector(IAppSettings settings, ICountryCollection collection)
 {
     _settings   = settings;
     _collection = collection;
 }
예제 #7
0
 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();
 }
예제 #8
0
 public NeighborsSelector(IAppSettings settings, ICountryCollection collection)
 {
     _settings   = settings;
     _collection = collection;
 }