def _parse(self, stream, context, path): obj = ListContainer() try: while True: obj.append(self.subcon._parse(stream, context, path)) except (StopFieldError, StreamError): pass except Exception: raise return obj
def save_to_packet(self): lc = ListContainer() for item in chain(*self.metalist): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=self.wid, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item[0], secondary=item[1], count=item[2])) packet = make_packet("inventory", name=self.identifier, length=len(lc), items=lc) return packet
def _parse(self, stream, context, path): discard = self.discard obj = ListContainer() try: for i in itertools.count(): context._index = i e = self.subcon._parsereport(stream, context, path) if not discard: obj.append(e) except StreamError: pass return obj
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=0, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in self.items: if item is None: lc.append(Container(id=-1)) else: lc.append(Container(id=item[0], damage=item[1], count=item[2])) packet = make_packet("inventory", unknown1=self.unknown1, length=len(lc), items=lc) return packet
def save_to_packet(self): lc = ListContainer() for item in chain(*self.metalist): if item is None: lc.append(Container(primary=-1)) else: lc.append( Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=self.wid, length=len(lc), items=lc) return packet
def _encode(self, obj, context, path): if not isinstance(obj, dict): raise TypeError("dict should be passed for decoding") n_obj = ListContainer() count = self.subcon.count # Array count for k in range(self._first_index, self._first_index + count): o = {"_index": k} v = obj.get(k) if v is not None: if self._pick_key: v = {self._pick_key: v} o.update(v) n_obj.append(o) return n_obj
def save_to_packet(self): lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append( Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", name=self.identifier, length=len(lc), items=lc) return packet
def save_to_packet(self, wid=None): # XXX This is a horrible place for this kind of silliness. Inventories # don't need to know or care about WIDs. Use a partial and fill this # out in inherited classes. if wid is not None: self.wid = wid lc = ListContainer() for item in chain(self.crafted, self.crafting, self.armor, self.storage, self.holdables): if item is None: lc.append(Container(primary=-1)) else: lc.append(Container(primary=item.primary, secondary=item.secondary, count=item.quantity)) packet = make_packet("inventory", wid=self.wid, length=len(lc), items=lc) return packet