This commit is contained in:
Administrator 2022-08-26 08:56:32 +03:00
parent 984441d033
commit bad63330c5
2 changed files with 1 additions and 14 deletions

View File

@ -74,7 +74,7 @@ def check_opponent(request):
token = data['token']
player = Player.objects.get(game_id=game_id, token=token)
player2 = Player.objects.filter(game_id=game_id, number=(1 - player.number)).first()
if player2 is None:
if player2.token is None:
return JsonResponse({"attend": False, "ready": False})
return JsonResponse({"attend": True, "ready": player2.field != ' ' * 100})
@ -143,15 +143,3 @@ def check_field_correct(request):
return JsonResponse({
'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
})

View File

@ -27,5 +27,4 @@ urlpatterns = [
path('api/place_ships', views.place_ships),
path('api/shoot', views.shoot),
path('api/check_field_correct', views.check_field_correct),
path('api/get_field', views.get_field)
]