def test_moves(self): board = mv.create_board(4) board[1][1] = 2 board[1][3] = 2 board[2][2] = 2 board[3][1] = 2 newboard = mv.next_board(board, False, False)["newboard"] self.assertEqual(newboard[1][0], 4) self.assertEqual(newboard[2][0], 2) self.assertEqual(newboard[3][0], 2)
def prepareCommitment(game, booleans, clientCommitment): previous_move = game.lastMove previous_board = move_logic.deserialize_board(previous_move.board) full_board = move_logic.next_board(previous_board, *booleans) board = full_board["newboard"] allempty = full_board["allempty"] changed = full_board["changed"] if changed: try: current_move = negotiate_first(game, board, allempty, clientCommitment) except UnfinishedMove: return HttpResponse("Pacta sunt servanda. You are obliged to finish " + "your previous move by exchanging secrets. To " + "give up the negotiation and accept server's" + "choice of the pseudorandom number send" + '"surrender="True""', status=452) else: return HttpResponseForbidden("not changed!") full_board["serverSecretHashed"] = current_move.serverSecretHashed; full_board["moveNumber"] = current_move.moveNumber return HttpResponse(json.dumps(full_board), content_type='application/json')