rename item kind to item code
This commit is contained in:
@@ -84,7 +84,7 @@ class Item:
|
|||||||
is_runeword: bool
|
is_runeword: bool
|
||||||
pos_x: int
|
pos_x: int
|
||||||
pos_y: int
|
pos_y: int
|
||||||
kind: str
|
code: str
|
||||||
uid: int | None = None
|
uid: int | None = None
|
||||||
lvl: int | None = None
|
lvl: int | None = None
|
||||||
quality: Quality | None = None
|
quality: Quality | None = None
|
||||||
@@ -108,8 +108,8 @@ class Item:
|
|||||||
|
|
||||||
def print(self, indent=5, with_raw=False):
|
def print(self, indent=5, with_raw=False):
|
||||||
properties = []
|
properties = []
|
||||||
kind_name = lookup_basetype(self.kind)["name"]
|
base_name = lookup_basetype(self.code)["name"]
|
||||||
print(" " * indent, f"{kind_name} ({self.kind})")
|
print(" " * indent, f"{base_name} ({self.code})")
|
||||||
if self.lvl:
|
if self.lvl:
|
||||||
print(" " * indent, f"ilvl {self.lvl}")
|
print(" " * indent, f"ilvl {self.lvl}")
|
||||||
if self.is_simple:
|
if self.is_simple:
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ def parse_item(data: bytes) -> tuple[bytes, Item]:
|
|||||||
is_runeword = bool(bits[26])
|
is_runeword = bool(bits[26])
|
||||||
pos_x = ba2int(bits[42:46])
|
pos_x = ba2int(bits[42:46])
|
||||||
pos_y = ba2int(bits[46:50])
|
pos_y = ba2int(bits[46:50])
|
||||||
kind, kind_end = huffman.decode(bits[53:], 3)
|
code, code_end = huffman.decode(bits[53:], 3)
|
||||||
kind_end += 53
|
code_end += 53
|
||||||
# TODO: verify that this socket thing is really 1 bit for simple items...?
|
# TODO: verify that this socket thing is really 1 bit for simple items...?
|
||||||
sockets_end = kind_end + 1 if is_simple else kind_end + 3
|
sockets_end = code_end + 1 if is_simple else code_end + 3
|
||||||
sockets_count = ba2int(bits[kind_end:sockets_end])
|
sockets_count = ba2int(bits[code_end:sockets_end])
|
||||||
print("sockets", sockets_count)
|
print("sockets", sockets_count)
|
||||||
if is_ear:
|
if is_ear:
|
||||||
raise UnsupportedItemError("Ear items are not supported")
|
raise UnsupportedItemError("Ear items are not supported")
|
||||||
@@ -145,7 +145,7 @@ def parse_item(data: bytes) -> tuple[bytes, Item]:
|
|||||||
is_runeword,
|
is_runeword,
|
||||||
pos_x,
|
pos_x,
|
||||||
pos_y,
|
pos_y,
|
||||||
kind,
|
code,
|
||||||
)
|
)
|
||||||
if is_simple:
|
if is_simple:
|
||||||
return data[simple_byte_sz:], item
|
return data[simple_byte_sz:], item
|
||||||
@@ -294,7 +294,7 @@ def parse_personalization(bits: bitarray) -> tuple[str, int]:
|
|||||||
|
|
||||||
|
|
||||||
def parse_basetype_data(bits: bitarray, item: Item) -> tuple[Item, int]:
|
def parse_basetype_data(bits: bitarray, item: Item) -> tuple[Item, int]:
|
||||||
cls = lookup_basetype(item.kind)["class"]
|
cls = lookup_basetype(item.code)["class"]
|
||||||
ptr = 0
|
ptr = 0
|
||||||
|
|
||||||
if cls == "tome":
|
if cls == "tome":
|
||||||
|
|||||||
Reference in New Issue
Block a user