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)
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 )