Add runeword parsing

This commit is contained in:
2023-10-24 20:26:21 +02:00
parent 29af4ccaa7
commit c170241746
5 changed files with 1185 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ _basetype_map = None
_stats_map = None
_unique_map = None
_set_item_map = None
_runeword_map = None
class Quality(Enum):
@@ -127,6 +128,8 @@ class Item:
properties.append("Unidentified")
if self.is_socketed:
properties.append("Socketed")
if self.is_runeword:
properties.append("Runeword")
if properties:
print(" " * indent, ", ".join(properties))
print(" " * indent, f"at {self.pos_x}, {self.pos_y}")
@@ -143,7 +146,8 @@ class Item:
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
rw = lookup_runeword(self.runeword_id)
print(" " * indent, f"{rw['name']} runeword")
if self.personal_name:
print(" " * indent, f"Personal name: {self.personal_name}")
if self.defense:
@@ -200,3 +204,11 @@ def lookup_set_item(id: int) -> dict:
with open(os.path.join(_data_path, "sets.json")) as f:
_set_item_map = json.load(f)
return _set_item_map[str(id)]
def lookup_runeword(id: int) -> dict:
global _runeword_map
if _runeword_map is None:
with open(os.path.join(_data_path, "runewords.json")) as f:
_runeword_map = json.load(f)
return _runeword_map[str(id)]