Revert ranch retention, breakthroughs and exploration
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
"""Extract the original normal-team exploration areas for offline planning."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
from tools.research_battle_v12 import recover_table
|
||||
from ranch_assistant.game_data import ORIGINAL_APK_SHA256
|
||||
|
||||
|
||||
def repair(value):
|
||||
if isinstance(value, dict):
|
||||
return {str(key): repair(item) for key, item in value.items()}
|
||||
if isinstance(value, list):
|
||||
return [repair(item) for item in value]
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
return value.encode("latin1").decode("gbk")
|
||||
except (UnicodeEncodeError, UnicodeDecodeError):
|
||||
pass
|
||||
return value
|
||||
|
||||
|
||||
def build(apk, output):
|
||||
import hashlib
|
||||
with Path(apk).open("rb") as stream:
|
||||
if hashlib.file_digest(stream, "sha256").hexdigest() != ORIGINAL_APK_SHA256:
|
||||
raise ValueError("Only the verified original 1.9.68 APK is accepted")
|
||||
with zipfile.ZipFile(apk) as archive:
|
||||
original, metadata = recover_table(archive, "explore_info")
|
||||
source = original.get("datas", original)["areas"]
|
||||
fields = ("id", "name", "passStage", "costTi", "costTime", "level", "team", "monExpMin", "monExpMax", "dlevel", "reward")
|
||||
areas = [{key: repair(row.get(key)) for key in fields} for row in source.values() if row.get("team") == "normal"]
|
||||
document = {"schema": 1, "source_apk_sha256": ORIGINAL_APK_SHA256,
|
||||
"source_table_sha256": metadata.get("sha256"), "areas": areas}
|
||||
Path(output).write_text(json.dumps(document, ensure_ascii=False, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
return document
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--apk", type=Path)
|
||||
parser.add_argument("--output", type=Path, default=ROOT / "ranch_assistant/data/exploration.json")
|
||||
arguments = parser.parse_args()
|
||||
if arguments.apk is None:
|
||||
candidates = list(ROOT.glob("*_1.9.68.apk"))
|
||||
if len(candidates) != 1:
|
||||
parser.error("Pass --apk with the original 1.9.68 APK")
|
||||
arguments.apk = candidates[0]
|
||||
result = build(arguments.apk, arguments.output)
|
||||
print(json.dumps({"areas": len(result["areas"]), "output": str(arguments.output)}, ensure_ascii=True))
|
||||
@@ -39,7 +39,7 @@ with zipfile.ZipFile(apk) as archive:
|
||||
if name == "stack_price":
|
||||
tables["stack_meta"] = {"total": int(value["total"])}
|
||||
print(name, len(tables[name]))
|
||||
fields = {"type", "name", "star", "element", "job", "time_1", "time_2", "sell_money", "sell_exp", "hideLib", "npc", "atk", "def", "hp", "dex", "like"}
|
||||
fields = {"type", "name", "star", "time_1", "time_2", "sell_money", "sell_exp", "hideLib", "npc", "atk", "def", "hp", "dex", "like"}
|
||||
fields |= {p + "_grow_" + bound for p in ("atk", "def", "hp", "dex") for bound in ("min", "max")}
|
||||
tables["monster_info"] = {str(k): {f: v for f, v in row.items() if f in fields} for k, row in tables["monster_info"].items()}
|
||||
tables = repair_names(tables)
|
||||
@@ -53,8 +53,7 @@ tables["entangle_info"] = {"haoganMax": tables["entangle_info"]["haoganMax"]}
|
||||
tables["markets"] = {row["id"]: {k: row.get(k) for k in ("id", "money", "ke", "max", "eggs", "freegift")} |
|
||||
{"city": int(row["id"][7:]), "name": tables["game_setting"]["cityInfo"][row["id"][7:]]["name"]}
|
||||
for row in tables.pop("gacha_machine") if row["id"].startswith("sc_city")}
|
||||
tables["potential_info"] = {k: tables["potential_info"][k] for k in
|
||||
("potentialLevelMaxAdd", "maxPotentialLevel", "potential", "potentialLevelItem", "elementItem")}
|
||||
tables["potential_info"] = {k: tables["potential_info"][k] for k in ("potentialLevelMaxAdd", "maxPotentialLevel")}
|
||||
tables["stage_info"] = {r["id"]: {f: r.get(f) for f in ("id", "name", "city", "closed", "cost", "tagname", "special", "posmode")} |
|
||||
{"level": {k: {f: v for f, v in level.items() if f in ("cost", "levelLock", "reward", "monExp")} for k, level in r.get("level", {}).items()}}
|
||||
for r in tables["stage_info"]}
|
||||
|
||||
Reference in New Issue
Block a user