Пример #1
0
 def read_attribute_as_char(item, offset, char_count, bits_per_char):
     item_code = ''
     for _ in range(char_count):  # Reach each char individually
         char = chr(read_bits(item, offset, bits_per_char))
         offset += bits_per_char
         if char == ' ':
             break
         item_code += char
     return item_code, offset
Пример #2
0
 def get_item_code(item):
     # Get the item code
     if Item.is_ear(
             item
     ):  # Ears lack the bits that indicate item code, but they have a specific ear indicator
         return 'ear'
     item_code = ''
     for i in range(4):  # Reach each char individually
         char = chr(read_bits(item, 76 + i * 8, 8))
         if char != ' ':  # Item codes are 4 bytes long but most of them have a space as the last char which
             # should be ignored
             item_code += char
     return item_code
Пример #3
0
 def get_set_id(self, item):
     # Get the set id of the item.
     if self.rarity is not Rarity.SET:  # First, make sure it's actually a set item
         return None
     # The relevant bit offset depends on whether the item has multiple graphics and/or is class specific
     offset = 156
     if self.has_multiple_pictures(item):
         offset += 3
     if self.is_class_specific(item):
         offset += 11
     # Once the set id is obtained, get the "true" set id from item_data.py
     # The set id as given in the item data actually indicates the specific item and not the set, i.e. Sigon parts
     # have different ids in the 35-40 range, Death's set is 47-49, etc. We want a single id for each set.
     return get_true_set_id(read_bits(item, offset, 12))
Пример #4
0
 def is_class_specific(item):
     # The bits indicating if an item is class specific vary in location based on whether it has multiple pictures
     if Item.has_multiple_pictures(item):
         return read_bits(item, 158, 1)
     return read_bits(item, 155, 1)
Пример #5
0
 def get_picture_id(item):
     # Return id of picture for items with multiple pictures
     if Item.is_simple(item) or not Item.has_multiple_pictures(item):
         return None
     return read_bits(item, 155, 3)
Пример #6
0
 def has_multiple_pictures(item):
     # Used to indicate whether an item can have multiple graphics (like rings, amulets, jewels etc)
     return read_bits(item, 154, 1)
Пример #7
0
 def get_rarity(item):
     if Item.is_simple(item):
         return None
     return Rarity(read_bits(item, 150, 4))
Пример #8
0
 def is_simple(item):
     return read_bits(item, 37, 1)
Пример #9
0
 def is_runeword(item):
     return read_bits(item, 42, 1)
Пример #10
0
 def is_ear(item):
     return read_bits(item, 32, 1)
Пример #11
0
 def get_position(item):
     # Get position in stash
     x_pos = read_bits(item, 65, 4)
     y_pos = read_bits(item, 69, 4)
     return x_pos, y_pos
Пример #12
0
 def num_filled_sockets(item):
     # Return number of socketed items in item
     if Item.is_ear(item):
         return 0
     return read_bits(item, 108, 3)
Пример #13
0
 def read_attribute(item, offset, bits_to_read):
     return read_bits(item, offset, bits_to_read), offset + bits_to_read