Exemplo n.º 1
0
def getBagItems(item):
    result = []
    i = 0
    for p in item.gff['ItemList']:
        gff_inst = GffInstance(item.gff, 'ItemList', i)
        st_inst = ItemInstance(gff_inst, item)

        equip_slot = p['_STRUCT_TYPE_']
        result.append((equip_slot, st_inst))
        i += 1

    return result
Exemplo n.º 2
0
    def equips(self):
        """ Creature's equipment list.

        :returns: List of tuples containing equipment ID and :class:`pynwn.ItemInstance`.
        """
        result = []
        i = 0
        for p in self.gff['Equip_ItemList']:
            gff_inst = GffInstance(self.gff, 'Equip_ItemList', i)
            st_inst = ItemInstance(gff_inst, self.parent_obj)

            equip_slot = p['_STRUCT_TYPE_']
            result.append((equip_slot, st_inst))
            i += 1

        return result
Exemplo n.º 3
0
    def items(self):
        """ Creature's equipment list.

        :returns: List of tuples containing equipment ID and ItemInstance.
        """
        result = []
        i = 0
        for p in self.gff['ItemList']:
            gff_inst = GffInstance(self.gff, 'ItemList', i)
            st_inst = ItemInstance(gff_inst, self)

            equip_slot = p['_STRUCT_TYPE_']
            result.append((equip_slot, st_inst))
            i += 1

        return result
Exemplo n.º 4
0
    def items(self):
        """Inventory items.

        :returns: List of Tupels contiain repository position
                  and the ItemInstance.
        """

        result = []
        i = 0
        # If the creature doesn't have inventory items they won't
        # have an 'ItemList' field in their gff structure.
        try:
            for p in self.gff['ItemList']:
                gff_inst = GffInstance(self.gff, 'ItemList', i)
                st_inst = ItemInstance(gff_inst, self)
                repo_pos = (p['Repos_PosX'], p['Repos_Posy'])
                result.append((repo_pos, st_inst))
                i += 1
        except KeyError:
            pass

        return result
Exemplo n.º 5
0
    def items(self):
        """Items in inventory.

        :returns: a two dimensional array with the format:
                  [<store page>][<ItemInstance objects>]
        """
        res = []
        for page in self['StoreList']:
            items = []
            try:
                for p in self.gff['ItemList']:
                    gff_inst = GffInstance(self.parent_obj, self.gff, 'ItemList', i)
                    st_inst  = ItemInstance(gff_inst)
                    items.append(st_inst)
                    i += 1

            except Exception as e:
                print(e)
                pass

            res.append( items )

        return res
Exemplo n.º 6
0
if __name__ == '__main__':

    bicFile = sys.argv[1]
    pc = PlayerCharacter(bicFile, DirectoryContainer("./"))
    #TODO get portrait etc
    print("----")
    #TODO print(pc.get_name_first())
    print("----")

    equips = pc.equips
    items = pc.items
    equips.extend(items)
    bags = []
    #fill the lists
    for x in range(len(equips)):
        item = ItemInstance(equips[x][1], pc)
        item = item.gff

        # BAG OF HOLDING SCAN ITEMS
        if item.base_type == 66:
            bags.extend(getBagItems(item))

    equips.extend(bags)

    #iterate over all items including bag contents
    i = 0
    for z in range(len(equips)):
        i = i + 1
        item = ItemInstance(equips[z][1], z)
        item = item.gff
        printItem(item, tlk)