@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}
@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')
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)
}
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;
})
}
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 © <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 © <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'
}