__init__.py 1016 B

123456789101112131415161718192021222324252627282930313233
  1. from typing import List, Tuple
  2. from .random_street_view import SOURCE_GROUP as RSV_SOURCE_GROUP
  3. from .urban_centers import SOURCE_GROUP as URBAN_CENTER_SOURCE_GROUP
  4. from .shared import ExhaustedSourceError
  5. from ..schemas import GameConfig, GenMethodEnum, CacheInfo
  6. source_groups = {
  7. GenMethodEnum.rsv: RSV_SOURCE_GROUP,
  8. GenMethodEnum.urban: URBAN_CENTER_SOURCE_GROUP,
  9. }
  10. def generate_points(config: GameConfig) -> List[Tuple[float, float]]:
  11. """
  12. Generate points according to the GameConfig.
  13. """
  14. return source_groups[config.generation_method].get_points_from(config.rounds, config.country_lock)
  15. def restock_source(config: GameConfig):
  16. """
  17. Restock any caches associated with the GameConfig.
  18. """
  19. source_groups[config.generation_method].restock(config.country_lock)
  20. def get_cache_info() -> List[CacheInfo]:
  21. """
  22. Get CacheInfo for all caches
  23. """
  24. return [CacheInfo(cache_name=c.get_name(), size=len(c.stock)) for g in source_groups.values() for c in g.cached]