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
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
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
def all_polished_nodes(story): for pr in story: b = ans.bind(SC["polished"], pr) if b: yield b["node_status.Node"]
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"])
def all_options(story): for pr in story: b = ans.bind(SC["option"], pr) if b: yield (b["at.Node"], b["at.option.Opt"])
def all_vignette_beginnings(story): # TODO: Fix me! for pr in story: b = ans.bind(SC["setup"], pr) if b: yield b["setup.Node"]
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"]
def all_nodes(story): for pr in story: b = ans.bind(SC["story_node"], pr) if b: yield b["story_node.Node"]
def all_initialized_nodes(story): for pr in story: b = ans.bind(SC["setup"], pr) if b: yield b["setup.Node"]
def all_polished_nodes(story): for pr in story: b = ans.bind(SC["polished"], pr) if b: yield b["node_status.Node"]
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"])
def all_options(story): for pr in story: b = ans.bind(SC["option"], pr) if b: yield (b["at.Node"], b["at.option.Opt"])
def all_vignette_beginnings(story): # TODO: Fix me! for pr in story: b = ans.bind(SC["setup"], pr) if b: yield b["setup.Node"]
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"]
def all_nodes(story): for pr in story: b = ans.bind(SC["story_node"], pr) if b: yield b["story_node.Node"]