Esempio n. 1
0
def _dict_to_drop(drop_dict: dict) -> ParameterIO:
    pio = ParameterIO()
    pio.type = "xml"
    header = ParameterObject()
    header.params["TableNum"] = Parameter(len(drop_dict))
    for i, table in enumerate(drop_dict.keys()):
        header.params[f"Table{i + 1:02}"] = Parameter(
            oead.FixedSafeString64(table))
    pio.objects["Header"] = header
    for i, (table, contents) in enumerate(drop_dict.items()):
        header.params[f"Table{i:02}"] = table
        table_obj = ParameterObject()
        table_obj.params["RepeatNumMin"] = Parameter(
            contents["repeat_num_min"])
        table_obj.params["RepeatNumMax"] = Parameter(
            contents["repeat_num_max"])
        table_obj.params["ApproachType"] = Parameter(contents["approach_type"])
        table_obj.params["OccurrenceSpeedType"] = Parameter(
            contents["occurrence_speed_type"])
        table_obj.params["ColumnNum"] = Parameter(len(contents["items"]))
        for idx, item in enumerate(contents["items"]):
            table_obj.params[f"ItemName{idx + 1:02}"] = Parameter(
                oead.FixedSafeString64(item))
            table_obj.params[f"ItemProbability{idx + 1:02}"] = Parameter(
                contents["items"][item])
        pio.objects[table] = table_obj
    return pio
Esempio n. 2
0
 def make_bshop(plist: ParameterList) -> ParameterIO:
     bshop = ParameterIO()
     bshop.type = "xml"
     tables: List[str] = [
         str(t.v) for _, t in plist.objects["TableNames"].params.items()
     ]
     bshop.objects["Header"] = ParameterObject()
     bshop.objects["Header"].params["TableNum"] = Parameter(len(tables))
     for i, table in enumerate(tables, 1):
         table_hash = crc32(table.encode())
         bshop.objects["Header"].params[f"Table{i:02d}"] = Parameter(
             FixedSafeString64(table)
         )
         table_pobj = ParameterObject()
         table_pobj.params["ColumnNum"] = Parameter(
             len(plist.lists[table_hash].objects)
         )
         for j, item in enumerate(
             [item for _, item in plist.lists[table_hash].objects.items()], 1
         ):
             table_pobj.params[f"ItemSort{j:03d}"] = Parameter(j - 1)
             for shop_key in shop_keys:
                 table_pobj.params[f"{shop_key}{j:03d}"] = item.params[shop_key]
         if table_pobj.params:
             bshop.objects[table_hash] = table_pobj
     return bshop
Esempio n. 3
0
 def _to_pio(self, obj) -> ParameterIO:
     pio = ParameterIO()
     pio.type = obj["type"]
     pio.version = obj["version"]
     obj = obj["lists"]["param_root"]
     if "lists" in obj and obj["lists"]:
         for name, content in obj["lists"].items():
             if name.isnumeric():
                 pio.lists[int(name)] = self._to_plist(content)
             else:
                 pio.lists[name] = self._to_plist(content)
     if "objects" in obj and obj["objects"]:
         for name, content in obj["objects"].items():
             if "params" in content and content["params"]:
                 if name.isnumeric():
                     pio.objects[int(name)] = self._to_pobj(content)
                 else:
                     pio.objects[name] = self._to_pobj(content)
     return pio