def fromjs(klass, inventory, js): global resource_converters guid = js[0] if inventory.items.has_key(guid): return inventory.items[guid] resource_type = None resource_key = None for key in ['resourceWithLevels', 'resource', 'modResource']: if js[2].has_key(key): resource_type = js[2][key]['resourceType'] resource_key = key break if resource_type is None: error('unable to interpret item: {}'.format(js)) return if not resource_converters.has_key(resource_type): error('don\'t know how to convert: {}'.format(js)) return resource_converters[resource_type].fromjs2(inventory, guid, js[2])
def fromjs2(klass, inventory, guid, js2): entity = b07.gear.Gear.catalogGear(js2['flipCard']) if js2['flipCard']['flipCardType'] == 'ADA': Ada(inventory, guid) elif js2['flipCard']['flipCardType'] == 'JARVIS': Jarvis(inventory, guid) else: error('Unknown flip card: {}'.format(js2))
def _inventory1(self, response, finished): if response.code == 500: error('Got a 500 SERVER ERROR trying to get the inventory!') elif response.code == 200: debug('Got 200 OK response to inventory request') d = defer.Deferred() d.addCallback(self._inventory2, finished) jp = b07.utils.JsonProtocol(d) response.deliverBody(jp) else: error('Don\'t know what to do with {} code in response to inventory request!'.format(response.code))
def _inventory1(self, response, finished): if response.code == 500: error('Got a 500 SERVER ERROR trying to get the inventory!') elif response.code == 200: debug('Got 200 OK response to inventory request') d = defer.Deferred() d.addCallback(self._inventory2, finished) jp = b07.utils.JsonProtocol(d) response.deliverBody(jp) else: error( 'Don\'t know what to do with {} code in response to inventory request!' .format(response.code))