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): def getEmblemPrices(self):
return () return ()
def hasEmblemPrices(self):
return len(self.getEmblemPrices()) >= ToontownGlobals.NumEmblemTypes
def loadModel(self): def loadModel(self):
return None return None

View file

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

View file

@ -102,26 +102,11 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
price = item.getPrice(CatalogItem.CatalogTypeBackorder) price = item.getPrice(CatalogItem.CatalogTypeBackorder)
elif item in av.weeklyCatalog or item in av.monthlyCatalog: elif item in av.weeklyCatalog or item in av.monthlyCatalog:
price = item.getPrice(0) price = item.getPrice(0)
elif item.hasEmblemPrices():
price = 0
else: else:
return 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 item.getDeliveryTime():
if len(av.onOrder) > 25: if len(av.onOrder) > 25:
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_OnOrderListFull]) self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_OnOrderListFull])
@ -130,7 +115,7 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
if len(av.mailboxContents) + len(av.onOrder) >= ToontownGlobals.MaxMailboxContents: if len(av.mailboxContents) + len(av.onOrder) >= ToontownGlobals.MaxMailboxContents:
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_MailboxFull]) self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_MailboxFull])
if not av.takeMoney(price): if not (av.takeMoney(price) and av.subtractEmblems(item.getEmblemPrices())):
return return
item.deliveryDate = int(time.time()/60) + item.getDeliveryTime() item.deliveryDate = int(time.time()/60) + item.getDeliveryTime()
@ -139,7 +124,7 @@ class DistributedPhoneAI(DistributedFurnitureItemAI):
self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_ItemOnOrder]) self.sendUpdateToAvatarId(avId, 'requestPurchaseResponse', [context, ToontownGlobals.P_ItemOnOrder])
taskMgr.doMethodLater(0.2, self.sendUpdateToAvatarId, 'purchaseItemComplete-%d' % self.getDoId(), extraArgs=[avId, 'purchaseItemComplete', []]) taskMgr.doMethodLater(0.2, self.sendUpdateToAvatarId, 'purchaseItemComplete-%d' % self.getDoId(), extraArgs=[avId, 'purchaseItemComplete', []])
else: else:
if not av.takeMoney(price): if not (av.takeMoney(price) and av.subtractEmblems(item.getEmblemPrices())):
return return
resp = item.recordPurchase(av, optional) resp = item.recordPurchase(av, optional)

View file

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