"""Artifact catalog parsed from WhiteDog1004/sephiria's artifacts.json. Each entry exposes the fields we actually need for icon matching and rendering: value (canonical key), Korean label, tier, and the CDN image URL. The full effect text / description is kept opaque — the matcher only cares about the image, and effects are not applied to the optimizer (slab effects only, per existing design). """ from __future__ import annotations import json from dataclasses import dataclass from importlib import resources from typing import Dict, List, Optional @dataclass(frozen=True) class Artifact: value: str ko_label: str eng_label: str tier: str # common / advanced / rare / legend / solid image: str # CDN URL level: int # max level (0 = unique / non-leveling) def _load() -> List[Artifact]: try: text = resources.files(__package__).joinpath("_artifacts.json").read_text( encoding="utf-8" ) except Exception: return [] data = json.loads(text) out: List[Artifact] = [] for row in data: if row.get("disabled"): continue out.append( Artifact( value=row["value"], ko_label=row.get("label_kor") or row["value"], eng_label=row.get("label_eng") or row["value"], tier=row.get("tier") or "common", image=row.get("image") or "", level=int(row.get("level") or 0), ) ) return out ARTIFACTS: List[Artifact] = _load() ARTIFACTS_BY_VALUE: Dict[str, Artifact] = {a.value: a for a in ARTIFACTS} def get(value: str) -> Optional[Artifact]: return ARTIFACTS_BY_VALUE.get(value)