Add unique & set names

This commit is contained in:
2023-10-24 19:27:22 +02:00
parent d571d0efbb
commit 788394ea7c
3 changed files with 4313 additions and 2 deletions

1145
d2warehouse/data/sets.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -24,6 +24,8 @@ from enum import Enum
_data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
_basetype_map = None
_stats_map = None
_unique_map = None
_set_item_map = None
class Quality(Enum):
@@ -135,9 +137,11 @@ class Item:
if self.suffixes:
print(" " * indent, "Suffixes:", self.suffixes)
if self.set_id:
print(" " * indent, f"Set Id: {self.set_id}") # TODO: name lookup
itm = lookup_set_item(self.set_id)
print(" " * indent, f"{itm['name']} ({self.set_id}), part of {itm['set']}")
if self.unique_id:
print(" " * indent, f"Set Id: {self.unique_id}") # TODO: name lookup
itm = lookup_unique(self.unique_id)
print(" " * indent, f"{itm['name']} ({self.unique_id})")
if self.runeword_id:
print(" " * indent, f"Runeword Id: {self.runeword_id}") # TODO: name lookup
if self.personal_name:
@@ -180,3 +184,19 @@ def lookup_stat(id: int) -> dict:
with open(os.path.join(_data_path, "stats.json")) as f:
_stats_map = json.load(f)
return _stats_map[str(id)]
def lookup_unique(id: int) -> dict:
global _unique_map
if _unique_map is None:
with open(os.path.join(_data_path, "uniques.json")) as f:
_unique_map = json.load(f)
return _unique_map[str(id)]
def lookup_set_item(id: int) -> dict:
global _set_item_map
if _set_item_map is None:
with open(os.path.join(_data_path, "sets.json")) as f:
_set_item_map = json.load(f)
return _set_item_map[str(id)]