get field
This commit is contained in:
parent
a2bb905def
commit
984441d033
@ -143,3 +143,15 @@ def check_field_correct(request):
|
|||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'correct': correct
|
'correct': correct
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def get_field(request):
|
||||||
|
if request.method == 'OPTIONS':
|
||||||
|
return JsonResponse({})
|
||||||
|
data = json.loads(request.body.decode('utf-8'))
|
||||||
|
player = Player.objects.get(game_id=data['gam_id'], token=data['token']).one()
|
||||||
|
cells = list(player.field)
|
||||||
|
cells = [cells[x * 10: (x + 1) * 10] for x in range(0, 10)]
|
||||||
|
return JsonResponse({
|
||||||
|
'field': cells
|
||||||
|
})
|
||||||
|
@ -26,5 +26,6 @@ urlpatterns = [
|
|||||||
path('api/attend_game', views.attend_game),
|
path('api/attend_game', views.attend_game),
|
||||||
path('api/place_ships', views.place_ships),
|
path('api/place_ships', views.place_ships),
|
||||||
path('api/shoot', views.shoot),
|
path('api/shoot', views.shoot),
|
||||||
path('api/check_field_correct', views.check_field_correct)
|
path('api/check_field_correct', views.check_field_correct),
|
||||||
|
path('api/get_field', views.get_field)
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user