From 2eb1f7a1008daf88b2d255675f87487eee765518 Mon Sep 17 00:00:00 2001 From: "a.soldatof" Date: Sun, 19 May 2019 02:02:59 +0300 Subject: [PATCH] fix move --- app.py | 17 +++++------------ src/GameController.js | 2 +- src/createMap.js | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) 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' } -- 2.50.1