schemas.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from enum import Enum
  2. from typing import Union, List
  3. from fastapi_camelcase import CamelModel
  4. from pydantic import conint, confloat, constr
  5. CountryCode = constr(to_lower=True, min_length=2, max_length=2)
  6. class GenMethodEnum(str, Enum):
  7. rsv = "RANDOMSTREETVIEW"
  8. urban = "URBAN"
  9. diff_tiered = "DIFFICULTY_TIERED"
  10. class GameModeEnum(str, Enum):
  11. normal = "NORMAL"
  12. frozen = "FROZEN"
  13. gun_game = "GUN_GAME"
  14. class ClockModeEnum(str, Enum):
  15. normal = "NORMAL"
  16. race = "RACE"
  17. time_bank = "TIMEBANK"
  18. class ScoreMethodEnum(str, Enum):
  19. distance = "DISTANCE"
  20. country_distance = "COUNTRYDIST"
  21. country_race = "COUNTRYRACE"
  22. hard = "HARD"
  23. nightmare = "NIGHTMARE"
  24. ramp = "RAMP"
  25. ramp_hard = "RAMP_HARD"
  26. class GameConfig(CamelModel):
  27. timer: conint(gt=0)
  28. rounds: conint(gt=0)
  29. country_lock: Union[CountryCode, None] = None
  30. generation_method: GenMethodEnum = GenMethodEnum.rsv
  31. game_mode: GameModeEnum = GameModeEnum.normal
  32. clock_mode: ClockModeEnum = ClockModeEnum.normal
  33. score_method: ScoreMethodEnum = ScoreMethodEnum.distance
  34. round_point_cap: Union[int, None] = None
  35. class Config:
  36. orm_mode = True
  37. class Guess(CamelModel):
  38. lat: confloat(ge=-90.0, le=90.0)
  39. lng: confloat(ge=-180.0, le=180.0)
  40. time_remaining: int
  41. class CacheInfo(CamelModel):
  42. cache_name: str
  43. size: int
  44. class GeneratorInfo(CamelModel):
  45. generation_method: GenMethodEnum
  46. country_locks: List[CountryCode]