예제 #1
0
파일: app.py 프로젝트: rrees/crumbly-castle
def move(player_id, new_node_id):
    player = graph.player(player_id)

    if int(new_node_id) in [rel.end.id for rel in player.location.relationships.outgoing(["Route"])]:
        graph.unlink(player, "Location")
        graph.link(player, graph.node_by_id(new_node_id), "Location")

    return redirect("/player/" + player_id)
예제 #2
0
파일: app.py 프로젝트: rrees/crumbly-castle
def game(player_id):
    player = graph.player(player_id)

    other_players = [
        rel.start for rel in player.location.relationships.incoming(["Location"]) if not rel.start == player
    ]

    exits = [
        (rel.get("description", "A stone path"), rel.end.id)
        for rel in player.location.relationships.outgoing(["Route"])
    ]

    return render_template(
        "game.html", player=player.properties, location=player.location, other_players=other_players, exits=exits
    )