get field

This commit is contained in:
Administrator
2022-08-25 11:45:48 +03:00
parent a2bb905def
commit 984441d033
2 changed files with 14 additions and 1 deletions

View File

@@ -143,3 +143,15 @@ 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
})