2 Commits 570d446d01 ... 2ff7369551

Autor SHA1 Mensagem Data
  Jason K. MacDuffie 2ff7369551 take the name from the ini title 1 mês atrás
  Jason K. MacDuffie 99524940d0 make a script to generate a linear story 1 mês atrás
1 arquivos alterados com 33 adições e 0 exclusões
  1. 33 0
      util/generate_story.py

+ 33 - 0
util/generate_story.py

@@ -0,0 +1,33 @@
+import configparser
+import json
+
+def parse_ini_to_json(ini_path):
+    config = configparser.ConfigParser()
+    config.read(ini_path, encoding="utf-8")
+
+    levels = []
+    level_names = [section for section in config.sections() if section != "Metadata"]
+
+    for h, level_name in enumerate(level_names):
+        i = h + 1
+        level_data = config[level_name]
+        levels.append({
+            "id": str(i),
+            "index": h + 10,
+            "name": level_name,
+            "pre_narrative": level_data.get("pre_narrative", ""),
+            "post_narrative": level_data.get("post_narrative", ""),
+            "next_level": str(i + 1) if i + 1 < len(level_names) else None,
+            "decisions": None,
+            "ending": "win" if h == len(level_names) - 1 else None
+        })
+
+    return json.dumps([{
+        "name": config["Metadata"]["name"],
+        "id": config["Metadata"]["id"],
+        "init_level": "1",
+        "levels": levels}], indent=4)
+
+ini_path = "story.ini"
+json_output = parse_ini_to_json(ini_path)
+print(json_output)