From: a.soldatof Date: Sat, 18 May 2019 23:02:59 +0000 (+0300) Subject: fix move X-Git-Url: https://git.xn--bdkaa.com/?a=commitdiff_plain;h=2eb1f7a1008daf88b2d255675f87487eee765518;p=where-are-you.py.git fix move --- diff --git a/app.py b/app.py index 04f2309..d76a986 100644 --- a/app.py +++ b/app.py @@ -227,7 +227,7 @@ def get_game(game_id): @get('/api/games//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//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//move') +@post('/api/games//move/') @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) diff --git a/src/GameController.js b/src/GameController.js index b304209..32aa03a 100644 --- a/src/GameController.js +++ b/src/GameController.js @@ -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; }) } diff --git a/src/createMap.js b/src/createMap.js index 74355ef..9babee1 100644 --- a/src/createMap.js +++ b/src/createMap.js @@ -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 © OpenStreetMap contributors, CC-BY-SA, Imagery � Mapbox', + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA', maxZoom: 13, id: 'mapbox.streets' }