schemas.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_race = "COUNTRYRACE"
  21. hard = "HARD"
  22. nightmare = "NIGHTMARE"
  23. ramp = "RAMP"
  24. ramp_hard = "RAMP_HARD"
  25. class GameConfig(CamelModel):
  26. timer: conint(gt=0)
  27. rounds: conint(gt=0)
  28. country_lock: Union[CountryCode, None] = None
  29. generation_method: GenMethodEnum = GenMethodEnum.rsv
  30. game_mode: GameModeEnum = GameModeEnum.normal
  31. clock_mode: ClockModeEnum = ClockModeEnum.normal
  32. score_method: ScoreMethodEnum = ScoreMethodEnum.distance
  33. round_point_cap: Union[int, None] = None
  34. class Config:
  35. orm_mode = True
  36. class Guess(CamelModel):
  37. lat: confloat(ge=-90.0, le=90.0)
  38. lng: confloat(ge=-180.0, le=180.0)
  39. time_remaining: int
  40. class CacheInfo(CamelModel):
  41. cache_name: str
  42. size: int
  43. class GeneratorInfo(CamelModel):
  44. generation_method: GenMethodEnum
  45. country_locks: List[CountryCode]