def parseResponse(self): cantPulverizePattern = PatternManager.getOrCompilePattern('cantPulverizeItem') if cantPulverizePattern.search(self.responseText) != None: item = ItemDatabase.getOrDiscoverItemFromId(self.itemId, self.session) raise Error.Error("'%s' is not an item that can be pulverized." % item["name"], Error.WRONG_KIND_OF_ITEM) notEnoughItemsPattern = PatternManager.getOrCompilePattern('notEnoughItems') if notEnoughItemsPattern.search(self.responseText) != None: item = ItemDatabase.getOrDiscoverItemFromId(self.itemId, self.session) if self.quantity == 1: itemStr = item["name"] else: itemStr = item["plural"] raise Error.Error("You do not have %s (%s)." % (itemStr, self.quantity), Error.ITEM_NOT_FOUND) items = [] singleItemPattern = PatternManager.getOrCompilePattern('acquireSingleItem') for match in singleItemPattern.finditer(self.responseText): descId = int(match.group(1)) item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session) item["quantity"] = 1 items.append(item) multiItemPattern = PatternManager.getOrCompilePattern('acquireMultipleItems') for match in multiItemPattern.finditer(self.responseText): descId = int(match.group(1)) quantity = int(match.group(2).replace(',', '')) item = ItemDatabase.getOrDiscoverItemFromDescId(descId, self.session) item["quantity"] = quantity items.append(item) self.responseData["results"] = items
def parseResponse(self): """ Searches managestore.php for item name, quantity, price, limit, and ID. Returns the items with the usual keys in the item data base along with: quantity -- The number of the item in your mall store. price -- The price of the item in your mall store. limit -- The limit on the item in your mall store. """ storeInventoryPattern = PatternManager.getOrCompilePattern( 'storeInventory') items = [] for match in storeInventoryPattern.finditer(self.responseText): name = match.group(1) if match.group(2) == None: quantity = 1 else: quantity = int(match.group(2)) price = int(match.group(3).replace(',', '')) if match.group(4) == '<font size=1>(unlimited)</font> ': limit = 0 else: limit = int(match.group(4)) itemID = int(match.group(5)) item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session) item["quantity"] = quantity item["price"] = price item["limit"] = limit items.append(item) self.responseData["items"] = items
def parseResponse(self): item = ItemDatabase.getOrDiscoverItemFromId(int(self.itemId), self.session) mallPricesUnlimitedPattern = PatternManager.getOrCompilePattern('mallPricesUnlimited') for match in mallPricesUnlimitedPattern.finditer(self.responseText): unlimited = [] price = {"price" : match.group(1).replace(",", ""), "count" : match.group(2).replace(",", "")} unlimited.append(price) price = {"price" : match.group(3).replace(",", ""), "count" : match.group(4).replace(",", "")} unlimited.append(price) price = {"price" : match.group(5).replace(",", ""), "count" : match.group(6).replace(",", "")} unlimited.append(price) price = {"price" : match.group(7).replace(",", ""), "count" : match.group(8).replace(",", "")} unlimited.append(price) item["unlimited"] = unlimited mallPricesLimitedPattern = PatternManager.getOrCompilePattern('mallPricesLimited') for match in mallPricesLimitedPattern.finditer(self.responseText): limited = [] print price = {"price" : match.group(1).replace(",", ""), "limit" : match.group(2).replace(",", ""), "count" : match.group(3).replace(",", "")} limited.append(price) price = {"price" : match.group(4).replace(",", ""), "limit" : match.group(5).replace(",", ""), "count" : match.group(6).replace(",", "")} limited.append(price) price = {"price" : match.group(7).replace(",", ""), "limit" : match.group(8).replace(",", ""), "count" : match.group(9).replace(",", "")} limited.append(price) item["limited"] = limited self.responseData["item"] = item
def parseResponse(self): """ Searches backoffice.php for item name, quantity, price, limit, and ID. Returns the items with the usual keys in the item data base along with: quantity -- The number of the item in your mall store. price -- The price of the item in your mall store. limit -- The limit on the item in your mall store. cheapest -- The cheapest in mall. This includes limited items, use at own risk. orderId -- Item order in your store. 0 is the first listed and so on. RegExp match notes: Group 3,6,9, and 11 are garbage HTML data. """ storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory') items = [] for match in storeInventoryPattern.finditer(self.responseText): descId = match.group(1) orderId = match.group(2) name = match.group(4) quantity = match.group(5) itemID = int(match.group(7)) item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session) price = match.group(8) limit = int(match.group(10)) cheapest = int(match.group(12)) item["orderId"] = orderId item["quantity"] = quantity item["price"] = price item["limit"] = limit item["cheapest"] = cheapest items.append(item) self.responseData["items"] = items
def parseResponse(self): """ Searches managestore.php for item name, quantity, price, limit, and ID. Returns the items with the usual keys in the item data base along with: quantity -- The number of the item in your mall store. price -- The price of the item in your mall store. limit -- The limit on the item in your mall store. """ storeInventoryPattern = PatternManager.getOrCompilePattern('storeInventory') items = [] for match in storeInventoryPattern.finditer(self.responseText): name = match.group(1) if match.group(2) == None: quantity = 1 else: quantity = int(match.group(2)) price = int(match.group(3).replace(',','')) if match.group(4) == '<font size=1>(unlimited)</font> ': limit = 0 else: limit = int(match.group(4)) itemID = int(match.group(5)) item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session) item["quantity"] = quantity item["price"] = price item["limit"] = limit items.append(item) self.responseData["items"] = items
def parseResponse(self): super(InventoryRequest, self).parseResponse() items = [] for itemId, quantity in self.jsonData.iteritems(): if self.ignoreItemDatabase: item = {} item["id"] = int(itemId) item["quantity"] = int(quantity) items.append(item) else: item = ItemDatabase.getOrDiscoverItemFromId(int(itemId), self.session) item["quantity"] = int(quantity) items.append(item) self.responseData["items"] = items
def parseResponse(self): super(InventoryRequest, self).parseResponse() items = [] for itemId, quantity in self.jsonData.iteritems(): if self.ignoreItemDatabase: item = {} item["id"] = int(itemId) item["quantity"] = int(quantity) items.append(item) else: item = ItemDatabase.getOrDiscoverItemFromId( int(itemId), self.session) item["quantity"] = int(quantity) items.append(item) self.responseData["items"] = items
def parseResponse(self): # Check for items first items = [] itemsAcquiredPattern = PatternManager.getOrCompilePattern("acquireItemFromItemUse") for match in itemsAcquiredPattern.finditer(self.responseText): itemID = int(match.group(1)) item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session) items.append(item) if len(items): self.responseData["items"] = items # Check for meat gained gainMeatPattern = PatternManager.getOrCompilePattern("gainMeat") for match in gainMeatPattern.finditer(self.responseText): self.responseData["meat"] = match.group(1) # Check if we don't have the item notEnoughPattern = PatternManager.getOrCompilePattern("notEnoughItems") notEnoughMatch = notEnoughPattern.search(self.responseText) if notEnoughMatch: raise Error.Error("You don't appear to have that item") if not len(self.responseData): print self.responseText
def parseResponse(self): """ Searches backoffice.php for item name, quantity, price, limit, and ID. Returns the items with the usual keys in the item data base along with: quantity -- The number of the item in your mall store. price -- The price of the item in your mall store. limit -- The limit on the item in your mall store. cheapest -- The cheapest in mall. This includes limited items, use at own risk. orderId -- Item order in your store. 0 is the first listed and so on. RegExp match notes: Group 3,6,9, and 11 are garbage HTML data. """ storeInventoryPattern = PatternManager.getOrCompilePattern( 'storeInventory') items = [] for match in storeInventoryPattern.finditer(self.responseText): descId = match.group(1) orderId = match.group(2) name = match.group(4) quantity = match.group(5) itemID = int(match.group(7)) item = ItemDatabase.getOrDiscoverItemFromId(itemID, self.session) price = match.group(8) limit = int(match.group(10)) cheapest = int(match.group(12)) item["orderId"] = orderId item["quantity"] = quantity item["price"] = price item["limit"] = limit item["cheapest"] = cheapest items.append(item) self.responseData["items"] = items