示例#1
0
def setup():
    for location_name, location_data in data.locations:
        graph.create_unique_node("locations", "location", location_name, location_data)

    for start, finish, description in data.routes:
        graph.link(graph.location(start), graph.location(finish), "Route", {"description": description})

    return redirect("/")
示例#2
0
def new_player():
    form = forms.NewPlayer(request.form)
    if form.validate():
        player_id = uuid.uuid4().hex

        player_data = {"id": player_id}
        player_data.update(form.data)

        player = graph.create_unique_node("characters", "character", player_id, player_data)

        graph.link(player, graph.random_location(), "Location")
        return redirect("/player/" + player_id)

    return render_template("index.html", form=form)
示例#3
0
    "flows",
    "flow",
    "start",
    flow_id,
    {"title": "After the Apocalypse", "description": "Post-apocalypse character generation in a Fallout vein"},
)

questions = [
    ("q1", "When the bombs started falling where were your parents?"),
    ("s1", "Which section did your parents work in?"),
    ("w1", "Were they affected by the radiation from the fallout?"),
]

for q_id, question in questions:

    graph.create_unique_node("questions", flow_id, q_id, {"id": q_id, "text": question})
    graph.link(flow_node, graph.node("questions", flow_id, q_id), "Question")

answers = [
    ("q1a1", "They had a place in the shelters"),
    ("q1a2", "They had nowhere to run"),
    ("s1a1", "Administration"),
    ("s1a2", "Security"),
    ("s1a3", "Science"),
    ("w1a1", "I don't know whether they were tough or lucky but no"),
    ("w1a2", "Why do you think I look this way?"),
]

for a_id, answer in answers:
    graph.create_unique_node("answers", flow_id, a_id, {"id": a_id, "text": answer})