Skip to content

Commit

Permalink
Fix purchase limits for mall item searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
scelis committed Dec 24, 2009
1 parent f0b4bb7 commit b115a18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/kol/data/Patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@
# Rumpus Room patterns.
'rumpusRoomFurniture' : r'rump([0-9])_([0-9])\.gif',

# Mall patterns.
'mallItemSearchResult' : r'<a[^<>]*href="mallstore\.php\?whichstore=(?P<storeId>[0-9]+)&searchitem=(?P<itemId>[0-9]+)&searchprice=(?P<price>[0-9]+)"><b>(?P<storeName>[^<>]+)<\/b><\/a>[^<>]*<\/td><td[^<>]*>(?P<quantity>[0-9,]+)<\/td><td[^<>]*>[^<>]*(?P<limit>[0-9,]*)[^<>]*<\/td>',
# Mall search patterns.
"mallItemSearchResult" : r'<tr class="graybelow(.*?)<\/tr>',
"mallItemSearchDetails" : r'<a[^<>]*href="mallstore\.php\?whichstore=(?P<storeId>[0-9]+)&searchitem=(?P<itemId>[0-9]+)&searchprice=(?P<price>[0-9]+)"><b>(?P<storeName>[^<>]+)<\/b><\/a>[^<>]*<\/td><td[^<>]*>(?P<quantity>[0-9,]+)<\/td><td[^<>]*>(?:&nbsp;)*(?P<limit>[0-9,]*)[^<>]*<\/td>',

# Mall purchase patterns.
"cantAffordItem" : r"<td>You can't afford that item\.<\/td>",
"mallNoItemAtThatPrice" : r"<td>This store doesn't have that item at that price\.",
"cantBuyItemIgnoreList" : r"<td>That player will not sell to you, because you are on his or her ignore list\.<\/td>",
Expand Down
7 changes: 6 additions & 1 deletion src/kol/request/MallItemSearchRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def __init__(self, session, searchQuery, category=CATEGORY_ALL, noLimits=False,
def parseResponse(self):
items = []
itemMatchPattern = PatternManager.getOrCompilePattern('mallItemSearchResult')
for match in itemMatchPattern.finditer(self.responseText):
itemDetailsPattern = PatternManager.getOrCompilePattern('mallItemSearchDetails')
for itemMatch in itemMatchPattern.finditer(self.responseText):
matchText = itemMatch.group(1)
match = itemDetailsPattern.search(matchText)
itemId = int(match.group('itemId'))
try:
item = ItemDatabase.getItemFromId(itemId, self.session)
Expand All @@ -55,6 +58,8 @@ def parseResponse(self):
if len(limit) > 0:
limit = int(limit)
item["limit"] = limit
if matchText.find('limited"') >= 0:
item["hitLimit"] = True
items.append(item)
except ItemNotFoundError, inst:
Report.info("itemdatabase", "Unrecognized item found in mall search: %s" % itemId, inst)
Expand Down

0 comments on commit b115a18

Please sign in to comment.