예제 #1
0
파일: tasks.py 프로젝트: solsword/dunyazad
def filter_keep(story):
  result = []
  for sch, bnd in ans.bindings(KEEP, story):
    result.append(bnd[sch])
  # Unique key handling:
  max_unique_key = None
  for pr in story:
    b = ans.bind(SC["unique_key_used"], pr)
    if b:
      k = int(str(b["unique_key_used.Key"]))
      if max_unique_key == None or k > max_unique_key:
        max_unique_key = k
    b = ans.bind(SC["max_unique"], pr)
    if b:
      k = int(str(b["max_unique.Key"]))
      if max_unique_key == None or k > max_unique_key:
        max_unique_key = k
  if max_unique_key == None:
    result.append(Pr("max_unique", Pr(0)))
  else:
    result.append(Pr("max_unique", Pr(max_unique_key)))
  return result
예제 #2
0
def filter_keep(story):
    result = []
    for sch, bnd in ans.bindings(KEEP, story):
        result.append(bnd[sch])
    # Unique key handling:
    max_unique_key = None
    for pr in story:
        b = ans.bind(SC["unique_key_used"], pr)
        if b:
            k = int(str(b["unique_key_used.Key"]))
            if max_unique_key == None or k > max_unique_key:
                max_unique_key = k
        b = ans.bind(SC["max_unique"], pr)
        if b:
            k = int(str(b["max_unique.Key"]))
            if max_unique_key == None or k > max_unique_key:
                max_unique_key = k
    if max_unique_key == None:
        result.append(Pr("max_unique", Pr(0)))
    else:
        result.append(Pr("max_unique", Pr(max_unique_key)))
    return result
예제 #3
0
def find_node_structure(story):
  """
  Takes a story and looks at successor/3 predicates to determine the structure
  of nodes in the story, returning a dictionary that maps node names to both
  successor and predecessor entries: successor entries being option->node
  mappings and predecessor entries being a list of nodes that have this node as
  a successor.
  """
  result = {}
  for pr in story:
    scc = ans.bind(SUCCESSOR, pr)
    if scc:
      frm = scc["successor.From"].unquoted()
      opt = scc["successor.option.Opt"].unquoted()
      to = scc["successor.To"].unquoted()
      if frm not in result:
        result[frm] = {"successors":{}, "predecessors":[]}
      if to not in result:
        result[to] = {"successors":{}, "predecessors":[]}
      result[frm]["successors"][opt] = to
      result[to]["predecessors"].append(frm)
  return result
예제 #4
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_polished_nodes(story):
  for pr in story:
    b = ans.bind(SC["polished"], pr)
    if b:
      yield b["node_status.Node"]
예제 #5
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_successors(story):
  for pr in story:
    b = ans.bind(SC["successor"], pr)
    if b:
      yield (b["successor.From"], b["successor.option.Opt"], b["successor.To"])
예제 #6
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_options(story):
  for pr in story:
    b = ans.bind(SC["option"], pr)
    if b:
      yield (b["at.Node"], b["at.option.Opt"])
예제 #7
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_vignette_beginnings(story):
  # TODO: Fix me!
  for pr in story:
    b = ans.bind(SC["setup"], pr)
    if b:
      yield b["setup.Node"]
예제 #8
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_endings(story):
  for pr in story:
    b = ans.bind(SC["node_type"], pr)
    if b and str(b["node_type.Type"]) == "ending":
      yield b["node_type.Node"]
예제 #9
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_nodes(story):
  for pr in story:
    b = ans.bind(SC["story_node"], pr)
    if b:
      yield b["story_node.Node"]
예제 #10
0
파일: tasks.py 프로젝트: solsword/dunyazad
def all_initialized_nodes(story):
  for pr in story:
    b = ans.bind(SC["setup"], pr)
    if b:
      yield b["setup.Node"]
예제 #11
0
def all_polished_nodes(story):
    for pr in story:
        b = ans.bind(SC["polished"], pr)
        if b:
            yield b["node_status.Node"]
예제 #12
0
def all_successors(story):
    for pr in story:
        b = ans.bind(SC["successor"], pr)
        if b:
            yield (b["successor.From"], b["successor.option.Opt"],
                   b["successor.To"])
예제 #13
0
def all_options(story):
    for pr in story:
        b = ans.bind(SC["option"], pr)
        if b:
            yield (b["at.Node"], b["at.option.Opt"])
예제 #14
0
def all_vignette_beginnings(story):
    # TODO: Fix me!
    for pr in story:
        b = ans.bind(SC["setup"], pr)
        if b:
            yield b["setup.Node"]
예제 #15
0
def all_endings(story):
    for pr in story:
        b = ans.bind(SC["node_type"], pr)
        if b and str(b["node_type.Type"]) == "ending":
            yield b["node_type.Node"]
예제 #16
0
def all_nodes(story):
    for pr in story:
        b = ans.bind(SC["story_node"], pr)
        if b:
            yield b["story_node.Node"]