Exemplo n.º 1
0
def submitscore(mazeid, user, score, solution=None):
    r = web.ctx.db.where("published_mazes", what="lowscore,data", id=mazeid)
    try:
        row = r[0]
    except IndexError:
        return {"error": "INCORRECT_MAZE_ID"}
    lowscore = row.lowscore
    maze_data = json.loads(row.data)
    maze = Maze.fromJSON(maze_data["maze"])
    board = CircuitBoard.fromJSON(json.loads(solution))
    # check that solution is valid
    try:
        time = run_maze(maze, board)
    except MazeRunError, e:
        return {"error": e.args[0]}