123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- from typing import List, Tuple
- from .random_street_view import SOURCE_GROUP as RSV_SOURCE_GROUP, VALID_COUNTRIES as RSV_COUNTRIES
- from .urban_centers import SOURCE_GROUP as URBAN_CENTER_SOURCE_GROUP, VALID_COUNTRIES as URBAN_COUNTRIES
- from .shared import ExhaustedSourceError
- from ..schemas import GameConfig, GenMethodEnum, CacheInfo, GeneratorInfo
- source_groups = {
- GenMethodEnum.rsv: RSV_SOURCE_GROUP,
- GenMethodEnum.urban: URBAN_CENTER_SOURCE_GROUP,
- }
- def generate_points(config: GameConfig) -> List[Tuple[str, float, float]]:
- """
- Generate points according to the GameConfig.
- """
- return source_groups[config.generation_method].get_points_from(config.rounds, config.country_lock)
- def restock_source(config: GameConfig):
- """
- Restock any caches associated with the GameConfig.
- """
- source_groups[config.generation_method].restock(config.country_lock)
- def get_cache_info() -> List[CacheInfo]:
- """
- Get CacheInfo for all caches.
- """
- return [CacheInfo(cache_name=c.get_name(), size=len(c.stock)) for g in source_groups.values() for c in g.cached]
- def get_generators() -> List[GeneratorInfo]:
- """
- Get all available Generators and their country options
- """
- return [
- GeneratorInfo(
- generation_method=GenMethodEnum.rsv,
- country_locks=RSV_COUNTRIES
- ),
- GeneratorInfo(
- generation_method=GenMethodEnum.urban,
- country_locks=URBAN_COUNTRIES
- ),
- ]
|