Fix house in cattlelog

This commit is contained in:
John 2015-05-28 20:55:37 +03:00 committed by Loudrob
parent 0f53845b05
commit 755c9afc6a
4 changed files with 17 additions and 23 deletions

View file

@ -264,6 +264,9 @@ class CatalogItem:
def getEmblemPrices(self):
return ()
def hasEmblemPrices(self):
return len(self.getEmblemPrices()) >= ToontownGlobals.NumEmblemTypes
def loadModel(self):
return None

View file

@ -941,10 +941,9 @@ class CatalogScreen(DirectFrame):
self.update()
return
if item.__class__.__name__ == "CatalogHouseItem":
if retCode == ToontownGlobals.P_ItemAvailable:
localAvatar.houseType = item.houseId
self.update()
if hasattr(item, 'houseId') and retCode == ToontownGlobals.P_ItemAvailable:
localAvatar.houseType = item.houseId
self.update()
self.setClarabelleChat(item.getRequestPurchaseErrorText(retCode), item.getRequestPurchaseErrorTextTimeout())

View file

@ -102,26 +102,11 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
price = item.getPrice(CatalogItem.CatalogTypeBackorder)
elif item in av.weeklyCatalog or item in av.monthlyCatalog:
price = item.getPrice(0)
elif item.hasEmblemPrices():
price = 0
else:
return
def _getEmblemPrices():
if config.GetBool('catalog-emblems-OR', False):
ep = list(item.getEmblemPrices())
if len(ep) != 2:
return []
if all(ep):
ep[payMethod] = 0
else:
ep = item.getEmblemPrices()
return ep
def charge():
ep = _getEmblemPrices()
if ep:
av.subtractEmblems(ep)
av.takeMoney(item.getPrice(priceType))
if item.getDeliveryTime():
if len(av.onOrder) > 25:
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_OnOrderListFull])
@ -130,7 +115,7 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
if len(av.mailboxContents) + len(av.onOrder) >= ToontownGlobals.MaxMailboxContents:
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_MailboxFull])
if not av.takeMoney(price):
if not (av.takeMoney(price) and av.subtractEmblems(item.getEmblemPrices())):
return
item.deliveryDate = int(time.time()/60) + item.getDeliveryTime()
@ -139,7 +124,7 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_ItemOnOrder])
taskMgr.doMethodLater(0.2, self.sendUpdateToAvatarId, 'purchaseItemComplete-%d' % self.getDoId(), extraArgs=[avId, 'purchaseItemComplete', []])
else:
if not av.takeMoney(price):
if not (av.takeMoney(price) and av.subtractEmblems(item.getEmblemPrices())):
return
resp = item.recordPurchase(av, optional)

View file

@ -2414,11 +2414,18 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
self.b_setEmblems(newEmblems)
def subtractEmblems(self, emblemsToSubtract):
if len(emblemsToSubtract) < ToontownGlobals.NumEmblemTypes:
return True
newEmblems = self.emblems[:]
for i in xrange(ToontownGlobals.NumEmblemTypes):
if newEmblems[i] < emblemsToSubtract[i]:
return False
newEmblems[i] -= emblemsToSubtract[i]
self.b_setEmblems(newEmblems)
return True
def isEnoughEmblemsToBuy(self, itemEmblemPrices):
for emblemIndex, emblemPrice in enumerate(itemEmblemPrices):