giant freakin documentation and reorganization pass, it also uses cmake because all the building was getting too complicated for shell scripts
This commit is contained in:
@@ -10,6 +10,8 @@ valid_resources = [
|
||||
"food", "shinies", "psi" # early game
|
||||
]
|
||||
|
||||
## \internal
|
||||
# \brief The environment variable map to run Rant with.
|
||||
rant_env = os.environ.copy()
|
||||
rant_env["RANT_MODULES_PATH"] = (core.path_appdir / "basepak/rant").as_posix()
|
||||
|
||||
@@ -18,6 +20,12 @@ doc_item_schema = xmltree.parse(pth_item_schema.as_posix())
|
||||
item_schema = xmltree.XMLSchema(doc_item_schema)
|
||||
item_schema_parser = xmltree.XMLParser(schema=item_schema)
|
||||
|
||||
## \brief Generates an absolutely reasonable description of a given item that a target might have.
|
||||
# \param resource The resource to generate a description for.
|
||||
# \param target The poor soul carrying the item.
|
||||
# \return An absolutely reasonable description of an item.
|
||||
#
|
||||
# \include{doc,local} res/doc/python/items.generate_item_description.mdpart
|
||||
def generate_item_description(resource, target):
|
||||
if core.desktop_mode:
|
||||
rant_path = core.path_appdir / "opt/rant/bin/rant"
|
||||
@@ -29,6 +37,13 @@ def generate_item_description(resource, target):
|
||||
core.log.warning("rant is throwing up:\n" + proc_rant.stderr.decode())
|
||||
return proc_rant.stdout.decode().strip()
|
||||
|
||||
## \brief Generates a list of items worth `min`-`max` `resource` that `target` would reasonably have.
|
||||
# \param resource The resource to generate a description for.
|
||||
# \param target The poor soul carrying the item.
|
||||
# \param min The lowest possible value, per item.
|
||||
# \param max The highest possible value, per item.
|
||||
# \param storybeat Inform the rule parsing engine where we are in the story.
|
||||
# \return A list of TickItem instances.
|
||||
def generate_item_list(resource, target, min, max, storybeat=0):
|
||||
count = random.randint(min, max)
|
||||
result = []
|
||||
@@ -43,12 +58,12 @@ def generate_item_list(resource, target, min, max, storybeat=0):
|
||||
maxdata = res_rule.xpath("./items:Max", namespaces=core.xml_namespaces)[0]
|
||||
resource_rules.append((res_rule, int(mindata.text), int(maxdata.text)))
|
||||
for i in range(0, count):
|
||||
core.log.warning("TODO: we don't know which rule this parses yet")
|
||||
core.log.warning(f"{resource} vs humans: {resource_rules[0]}")
|
||||
core.log.warning(f"{resource} vs humans: {resource_rules[0][1]} <-> {resource_rules[0][2]} (sb: {resource_rules[0][0].get("StoryBeat", "0")})")
|
||||
result.append(TickItem(resource, round(random.uniform(resource_rules[0][1], resource_rules[0][2]), 2), target))
|
||||
|
||||
return result
|
||||
|
||||
## \brief A tick item.
|
||||
class TickItem(object):
|
||||
def __init__(self, resource, amount, target):
|
||||
if resource not in valid_resources:
|
||||
|
Reference in New Issue
Block a user