min_lat, max_lat, min_lon, max_lon = 56.807556, 56.847826, 60.570744, 60.657791
+
class Game:
def __init__(self, game_id, current_coordinates):
self.id = game_id
radius = 0.0025
coordinate = game.current_coordinates
near_objects = describe_objects(coordinate[0] - radius, coordinate[1] - radius, coordinate[0] + radius,
- coordinate[1] + radius)
+ coordinate[1] + radius)
for o in near_objects['amenities']:
game.tips.append(f'Рядом с вами находится {o["name"]}')
for s in near_objects['streets']:
- success, summary = parse_summary(s['name'].replace('улица', '').replace('проспект', '').replace('переулок', '').strip())
+ success, summary = parse_summary(
+ s['name'].replace('улица', '').replace('проспект', '').replace('переулок', '').strip())
if success:
game.tips.append(f'Недалеко есть улица, имя которой дал(а) {summary}')
game.shown_tips.append(not_shown_tips[i])
-lat = min_lat + (max_lat - min_lat) * random()
-lon = min_lon + (max_lon - min_lon) * random()
+def create_test_game():
+ lat = min_lat + (max_lat - min_lat) * random()
+ lon = min_lon + (max_lon - min_lon) * random()
+
+ test_game = Game('test', (lat, lon))
+ add_tips(test_game)
+ show_tips(test_game, 20)
+
+ return test_game
-test_game = Game('test', (lat, lon))
-add_tips(test_game)
-show_tips(test_game, 20)
-games = {'test': test_game}
+
+games = {'test': create_test_game()}
@get('/api/games')
def post_game():
game_id = str(uuid.uuid4())
- game = Game(game_id, (56.832469, 60.605989))
+ lat = min_lat + (max_lat - min_lat) * random()
+ lon = min_lon + (max_lon - min_lon) * random()
+
+ game = Game(game_id, (lat, lon))
games[game_id] = game
return {