コード例 #1
0
ファイル: Enemy.py プロジェクト: dl-stuff/dl-datamine
 def outfile_name_with_subdir(res,
                              ext=".json",
                              aiscript_dir="./out/_aiscript",
                              enemies_dir="./out/enemies"):
     subdir = EnemyParam.general_param_group(res)
     try:
         name = res["_Name"]
     except KeyError:
         name = "UNNAMED"
     check_target_path(os.path.join(enemies_dir, subdir))
     try:
         _, ai_file = res["_Ai"].split("/")
         ai_path = os.path.join(aiscript_dir, ai_file)
         if os.path.exists(ai_path + ".py"):
             filename = snakey(f"{ai_file}_{name}")
             link_target = os.path.join(enemies_dir, subdir,
                                        f"{filename}.py")
             try:
                 os.link(ai_path + ".py", link_target)
             except FileExistsError:
                 os.remove(link_target)
                 os.link(ai_path + ".py", link_target)
             except OSError:
                 shutil.copy(ai_path + ".py", link_target)
             return subdir, snakey(f"{filename}{ext}")
     except KeyError:
         pass
     return subdir, snakey(f'{res["_Id"]:02}_{name}{ext}')
コード例 #2
0
ファイル: Aiscript.py プロジェクト: dl-stuff/dl-datamine
def fmt_def(inst):
    name = inst.params[0].values[0]
    name = snakey(name, with_ext=False)
    if name[0].isdigit():
        name = "_" + name
    # return f"{INDENT*inst.depth}@log_call(logfmt=logfmt_funcdef, indent=True)\n{INDENT*inst.depth}def {name}(self):"
    return f"{INDENT*inst.depth}\n{INDENT*inst.depth}def {name}(self):"
コード例 #3
0
ファイル: Enemy.py プロジェクト: dl-stuff/dl-datamine
 def export_all_to_folder(self, out_dir="./out", ext=".json"):
     aiscript_dir = os.path.join(out_dir, "_aiscript")
     out_dir = os.path.join(out_dir, "enemies")
     aiscript_init_link = os.path.join(out_dir, "__init__.py")
     all_res = self.get_all()
     check_target_path(out_dir)
     try:
         os.link(AISCRIPT_INIT_PATH, aiscript_init_link)
     except FileExistsError:
         os.remove(aiscript_init_link)
         os.link(AISCRIPT_INIT_PATH, aiscript_init_link)
     except OSError:
         shutil.copy(AISCRIPT_INIT_PATH, aiscript_init_link)
     misc_data = defaultdict(list)
     for res in tqdm(all_res, desc="enemies"):
         res = self.process_result(res)
         subdir, out_file = self.outfile_name_with_subdir(
             res, ext=ext, aiscript_dir=aiscript_dir, enemies_dir=out_dir)
         if subdir is None:
             misc_data[out_file].append(res)
             continue
         out_path = os.path.join(out_dir, subdir, out_file)
         with open(out_path, "w", newline="", encoding="utf-8") as fp:
             json.dump(res, fp, indent=2, ensure_ascii=False, default=str)
     for group_name, res_list in misc_data.items():
         out_name = snakey(f"{group_name}{ext}")
         output = os.path.join(out_dir, out_name)
         with open(output, "w", newline="", encoding="utf-8") as fp:
             json.dump(res_list,
                       fp,
                       indent=2,
                       ensure_ascii=False,
                       default=str)
コード例 #4
0
ファイル: Aiscript.py プロジェクト: dl-stuff/dl-datamine
def s(v, prefix="self."):
    if isinstance(v, str):
        if v == "true":
            return "True"
        elif v == "false":
            return "False"
        elif v == "_m":
            return "var_m"
        snek = snakey(v, with_ext=False)
        if snek[0].isdigit():
            snek = "_" + snek
        return f"{prefix}{snek}"
    else:
        return v
コード例 #5
0
ファイル: BattleRoyal.py プロジェクト: dl-stuff/dl-datamine
 def export_all_to_folder(self, out_dir="./out", ext=".json"):
     where = "_SpecialSkillId != 0"
     out_dir = os.path.join(out_dir, "_br")
     all_res = self.get_all(where=where)
     check_target_path(out_dir)
     sorted_res = {}
     for res in tqdm(all_res, desc="_br"):
         res = self.process_result(res)
         sorted_res[res["_Id"]] = res
     out_name = snakey(f"_chara_skin.json")
     output = os.path.join(out_dir, out_name)
     with open(output, "w", newline="", encoding="utf-8") as fp:
         json.dump(sorted_res,
                   fp,
                   indent=2,
                   ensure_ascii=False,
                   default=str)
コード例 #6
0
ファイル: Enemy.py プロジェクト: dl-stuff/dl-datamine
 def outfile_name(res, ext):
     return snakey(
         f'{res["_Id"]:02}_{res.get("_ParamGroupName", "UNKNOWN")}{ext}')
コード例 #7
0
                        full_query=False,
                    )
        else:
            res = super().get(pk,
                              by=by,
                              fields=fields,
                              mode=DBManager.LIKE,
                              full_query=False)
        if not full_query:
            return res
        return self.process_result(res, full_abilities=full_abilities)

    @staticmethod
    def outfile_name(res, ext=".json"):
        name = "UNKNOWN" if "_Name" not in res else res[
            "_Name"] if "_SecondName" not in res else res["_SecondName"]
        if (emblem := res.get("_EmblemId")) and emblem != res["_Id"]:
            return f'{res["_Id"]:02}_{name}{ext}'
        return snakey(f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}')

    def export_all_to_folder(self, out_dir="./out", ext=".json"):
        out_dir = os.path.join(out_dir, "dragons")
        super().export_all_to_folder(out_dir, ext, full_abilities=False)


if __name__ == "__main__":
    index = DBViewIndex()
    view = DragonData(index)
    view.export_one_to_folder(20050217, out_dir="./out/dragons")
    # view.export_all_to_folder()
コード例 #8
0
ファイル: Weapons.py プロジェクト: dl-stuff/dl-datamine
 def outfile_name(res, ext=".json"):
     name = "UNKNOWN" if "_Name" not in res else res["_Name"]
     return snakey(f'{res["_Id"]:02}_{name}{ext}')
コード例 #9
0
ファイル: Wyrmprints.py プロジェクト: dl-stuff/dl-datamine
 def outfile_name(res, ext=".json"):
     name = "UNKNOWN" if "_Name" not in res else res["_Name"]
     # FIXME: do better name sanitation here
     return snakey(f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}')
コード例 #10
0
                if not isinstance(value, dict):
                    continue
                if not isinstance(
                    (action_group := value.get("_ActionGroupName")), dict):
                    continue
                is_data = False
                for hitattr in action_group.values():
                    if not isinstance(hitattr, dict) or not (
                            act_cond := hitattr.get("_ActionCondition")):
                        continue
                    if check_condition(act_cond):
                        is_data = True
                if is_data:
                    sub_data[f"{as_key}{key}"] = value
        if sub_data:
            key = snakey(
                f'{res.get("_ParamGroupName", "UNKNOWN")}_{res.get("_Name")}')
            all_data[key] = sub_data
    with open(f"{output_name}.json", "w") as fn:
        json.dump(all_data, fn, indent=2, ensure_ascii=False)


def export_nihility_data():
    find_enemy_actionset_data(
        "nihility", lambda act_cond: act_cond.get("_CurseOfEmptiness"))


def export_corrosion_data():
    # res_where="_ParamGroupName LIKE 'DIABOLOS_%'"
    find_enemy_actionset_data(
        "corrosion", lambda act_cond: act_cond.get("_UniqueIcon") == 96)
コード例 #11
0
 def outfile_name(res, ext=".json"):
     name = "UNKNOWN" if "_Name" not in res else res["_Name"] if "_SecondName" not in res else res["_SecondName"]
     if res["_ElementalType"] == 99:
         return f'{res["_Id"]:02}_{name}{ext}'
     return snakey(f'{res["_BaseId"]}_{res["_VariationId"]:02}_{name}{ext}')