Ejemplo n.º 1
0
def new_game(request):
    """
    Game instance uses this function to generate a new game
    """
    game_state = services.new_game()
    serializer = GameStateSerializer(game_state)
    return Response(serializer.data)
Ejemplo n.º 2
0
def new_game(request):
    """ REST view function to create new GameState object and return serialized JSON

    :param request:
    :return: Returns GameState object in JSON
    :rtype: json
    """
    game_state = services.new_game()
    if game_state == "validation_error":
        return Response(status=400, data={"status": 400, "description": "There was a problem"})
    serializer = GameStateSerializer(game_state)
    return Response(serializer.data)