Spaces:
Running
Running
| import os, json | |
| from functools import lru_cache | |
| SPEC_DB_DIR = os.environ.get("SPEC_DB_DIR", ".") | |
| DB_FILES = { | |
| 1: os.path.join(SPEC_DB_DIR, "spec_db_1.json"), # ① 7.0 / Pendant OFF / Gild OFF | |
| 2: os.path.join(SPEC_DB_DIR, "spec_db_2.json"), # ② 9.0 / Pendant ON / Gild OFF | |
| } | |
| def _load_db(profile:int) -> dict: | |
| path = DB_FILES.get(profile) | |
| if not path or not os.path.exists(path): | |
| return {} | |
| try: | |
| with open(path, "r", encoding="utf-8") as f: | |
| data = json.load(f) | |
| # 통일된 키: data[typ][buff] = M(float) | |
| if isinstance(data, dict): | |
| return data | |
| return {} | |
| except Exception: | |
| return {} | |
| def profile_name(p:int)->str: | |
| return {1:"① 7.0/PEND_OFF/GILD_OFF (DB1)", | |
| 2:"② 9.0/PEND_ON/ GILD_OFF (DB2)", | |
| 3:"③ 7.0/PEND_OFF/GILD_ON (Runtime)", | |
| 4:"④ 9.0/PEND_ON/ GILD_ON (Runtime)"}.get(p, f"PRF{p}") | |
| def get_M(profile:int, typ:str, buff_label:str) -> float|None: | |
| if profile not in (1,2): | |
| return None | |
| d = _load_db(profile) | |
| typ = str(typ) | |
| buff = str(buff_label) | |
| M = None | |
| try: | |
| M = d.get(typ, {}).get(buff, None) | |
| if isinstance(M, (int,float)): | |
| return float(M) | |
| except Exception: | |
| pass | |
| return None | |
| def has(profile:int, typ:str, buff_label:str)->bool: | |
| return get_M(profile, typ, buff_label) is not None | |