]> git.xn--bdkaa.com Git - where-are-you.py.git/commitdiff
fix move
authora.soldatof <a.soldatof@gmail.com>
Sat, 18 May 2019 23:02:59 +0000 (02:02 +0300)
committera.soldatof <a.soldatof@gmail.com>
Sat, 18 May 2019 23:03:52 +0000 (02:03 +0300)
app.py
src/GameController.js
src/createMap.js

diff --git a/app.py b/app.py
index 04f2309d8912344678ea5200cfb99262e376b589..d76a986e6dfb7b837c8dc5c659fa3e6696f372b7 100644 (file)
--- a/app.py
+++ b/app.py
@@ -227,7 +227,7 @@ def get_game(game_id):
 
 @get('/api/games/<game_id>/tips')
 @enable_cors
-def get_game(game_id):
+def get_tips(game_id):
     game = games[game_id]
 
     return {'tips': game.shown_tips}
@@ -235,7 +235,7 @@ def get_game(game_id):
 
 @post('/api/games/<game_id>/ask-tip')
 @enable_cors
-def get_game(game_id):
+def get_tip(game_id):
     if not game_id in games:
         return bottle.HTTPResponse(status=404, body='game not found')
 
@@ -245,26 +245,19 @@ def get_game(game_id):
     return {'tips': game.shown_tips}
 
 
-@post('/api/games/<game_id>/move')
+@post('/api/games/<game_id>/move/<direction>')
 @enable_cors
-def get_game(game_id):
+def move(game_id, direction):
     if not game_id in games:
         return bottle.HTTPResponse(status=404, body='game not found')
 
     game = games[game_id]
 
-    direction = request.json['direction']
-
-    if not direction:
-        return bottle.HTTPResponse(status=400, body='direction is required')
-
-    game.move(direction)
-
     game.tips = []
 
     add_tips(game)
 
-    game.shown_tips.append(f'Вы переместились на {move_distance} м на ' + convert_direction(direction))
+    game.shown_tips.append(f'Вы переместились на {move_distance} м на ')
 
     show_tips(game, 1)
 
index b304209fc818fb573ad02008ffc879f5aefbc239..32aa03a3ab97b21dcc24ec251de0a7d84fb1700d 100644 (file)
@@ -19,7 +19,7 @@ export class GameController {
   }
 
   goForward() {
-    return api.post(`/games/${this.gameId}/move`).then(json => {
+    return api.post(`/games/${this.gameId}/move/south`).then(json => {
       this._tips = json.data.tips;
     })
   }
index 74355ef9bb4412d60a3c0c23b5afd08b524ae805..9babee1acb64fa61908e938554d61632a4725cb0 100644 (file)
@@ -14,9 +14,9 @@ export function createMap(elementId) {
   const map = new L.Map(elementId);
 
   const service = new L.tileLayer(
-    'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoiZnJ1bWNoZWciLCJhIjoiY2p2dHBwNnc0MWFkZDRhbHF4MDYzNGdnYiJ9.CpcLysWuR3U-eebecVBENw',
+    'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
     {
-      attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery � <a href="http://mapbox.com">Mapbox</a>',
+      attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
       maxZoom: 13,
       id: 'mapbox.streets'
     }