mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-10-30 16:27:54 +00:00
Safeguard code redemption
This commit is contained in:
parent
f20e720479
commit
e598558eb1
4 changed files with 57 additions and 45 deletions
|
@ -9,7 +9,9 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
notify = DirectNotifyGlobal.directNotify.newCategory("TTCodeRedemptionMgrAI")
|
||||
codes = {
|
||||
'weed': {
|
||||
'item': CatalogClothingItem.CatalogClothingItem(1821, 0),
|
||||
'items': [
|
||||
CatalogClothingItem.CatalogClothingItem(1821, 0)
|
||||
],
|
||||
'month': 4,
|
||||
'day': 20
|
||||
}
|
||||
|
@ -18,10 +20,27 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
|
||||
def getMailboxCount(items):
|
||||
count = 0
|
||||
|
||||
for item in items:
|
||||
if item.getDeliveryTime() < 1:
|
||||
count += 1
|
||||
|
||||
return count
|
||||
|
||||
def redeemCode(self, context, code):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
|
||||
if not av:
|
||||
return
|
||||
|
||||
if code in self.codes:
|
||||
if av.isCodeRedeemed(code):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 4])
|
||||
return
|
||||
|
||||
codeInfo = self.codes[code]
|
||||
date = datetime.now()
|
||||
|
||||
|
@ -29,30 +48,29 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 2, 0])
|
||||
return
|
||||
|
||||
self.requestCodeRedeem(context, codeInfo['item'])
|
||||
av.redeemCode(code)
|
||||
self.requestCodeRedeem(context, avId, av, codeInfo['items'])
|
||||
else:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 1, 0])
|
||||
|
||||
def requestCodeRedeem(self, context, item):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
av = self.air.doId2do.get(avId)
|
||||
|
||||
if not av:
|
||||
def requestCodeRedeem(self, context, avId, av, items):
|
||||
if item in av.onOrder:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 2])
|
||||
return
|
||||
|
||||
if len(av.onOrder) > 5:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 4, 4])
|
||||
if item.reachedPurchaseLimit(av):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 3])
|
||||
return
|
||||
|
||||
if len(av.mailboxContents) + len(av.onOrder) >= ToontownGlobals.MaxMailboxContents:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 4, 3])
|
||||
count = getMailboxCount(items)
|
||||
|
||||
if len(av.onOrder) + count > 5 or len(av.mailboxContents) + len(av.onOrder) + count >= ToontownGlobals.MaxMailboxContents:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 1])
|
||||
return
|
||||
|
||||
if item in av.onOrder or item.reachedPurchaseLimit(av):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 4, 13])
|
||||
return
|
||||
for item in items:
|
||||
item.deliveryDate = int(time.time() / 60) + 0.01
|
||||
av.onOrder.append(item)
|
||||
|
||||
item.deliveryDate = int(time.time() / 60) + 0.01
|
||||
av.onOrder.append(item)
|
||||
av.b_setDeliverySchedule(av.onOrder)
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 0, 0])
|
|
@ -646,36 +646,22 @@ class CodesTabPage(DirectFrame):
|
|||
if result == 0:
|
||||
self.resultPanel['image'] = self.resultPanelSuccessGui
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultSuccess
|
||||
elif result == 1 or result == 3:
|
||||
elif result == 1:
|
||||
self.resultPanel['image'] = self.resultPanelFailureGui
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultInvalidCode
|
||||
elif result == 2:
|
||||
self.resultPanel['image'] = self.resultPanelFailureGui
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultExpiredCode
|
||||
elif result == 4:
|
||||
elif result == 3:
|
||||
self.resultPanel['image'] = self.resultPanelErrorGui
|
||||
if awardMgrResult == 0:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultSuccess
|
||||
elif awardMgrResult == 1 or awardMgrResult == 2 or awardMgrResult == 15 or awardMgrResult == 16:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultUnknownError
|
||||
elif awardMgrResult == 3 or awardMgrResult == 4:
|
||||
if awardMgrResult == 1:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultMailboxFull
|
||||
elif awardMgrResult == 5 or awardMgrResult == 10:
|
||||
elif awardMgrResult == 2:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyInMailbox
|
||||
elif awardMgrResult == 6 or awardMgrResult == 7 or awardMgrResult == 11:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyInQueue
|
||||
elif awardMgrResult == 8:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyInCloset
|
||||
elif awardMgrResult == 9:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyBeingWorn
|
||||
elif awardMgrResult == 12 or awardMgrResult == 13 or awardMgrResult == 14:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyReceived
|
||||
elif result == 5:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultTooManyFails
|
||||
self.__disableCodeEntry()
|
||||
elif result == 6:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultServiceUnavailable
|
||||
self.__disableCodeEntry()
|
||||
elif awardMgrResult == 3:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultReachedLimit
|
||||
elif awardMgrResult == 4:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyRedeemed
|
||||
if result == 0:
|
||||
self.successSfx.play()
|
||||
else:
|
||||
|
|
|
@ -565,6 +565,19 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
|||
def getMaxNPCFriends(self):
|
||||
return self.maxNPCFriends
|
||||
|
||||
def b_setRedeemedCodes(self, redeemedCodes):
|
||||
self.redeemedCodes = redeemedCodes
|
||||
|
||||
def getRedeemedCodes(self, redeemedCodes):
|
||||
return self.redeemedCodes
|
||||
|
||||
def isCodeRedeemed(self, code):
|
||||
return code in self.redeemedCodes
|
||||
|
||||
def redeemCode(self, code):
|
||||
if not isCodeReedemed(code):
|
||||
self.redeemedCodes.append(code)
|
||||
|
||||
def getBattleId(self):
|
||||
if self.battleId >= 0:
|
||||
return self.battleId
|
||||
|
|
|
@ -4698,15 +4698,10 @@ CdrInstructions = 'Enter your code to receive a special item in your mailbox.'
|
|||
CdrResultSuccess = 'Congratulations! Check your mailbox to claim your item!'
|
||||
CdrResultInvalidCode = "You've entered an invalid code. Please check the code and try again."
|
||||
CdrResultExpiredCode = "We're sorry. This code has expired."
|
||||
CdrResultUnknownError = "We're sorry. This code cannot be applied to your Toon."
|
||||
CdrResultMailboxFull = 'Your mailbox is full. Please remove an item, then enter your code again.'
|
||||
CdrResultAlreadyInMailbox = "You've already received this item. Check your mailbox to confirm."
|
||||
CdrResultAlreadyInQueue = 'Your item is on its way. Check your mailbox in a few minutes to receive it.'
|
||||
CdrResultAlreadyInCloset = "You've already received this item. Check your closet to confirm."
|
||||
CdrResultAlreadyBeingWorn = "You've already received this item, and you are wearing it!"
|
||||
CdrResultAlreadyReceived = "You've already received this item."
|
||||
CdrResultTooManyFails = "We're sorry. You've tried to enter an incorrect code too many times. Please try again after some time."
|
||||
CdrResultServiceUnavailable = "We're sorry. This feature is temporarily unavailable. Please try again during your next login."
|
||||
CdrResultReachedLimit = "You reached your limit for today. Please try again later."
|
||||
CdrResultAlreadyRedeemed = "You've already redeemed this item!"
|
||||
TrackPageTitle = 'Gag Track Training'
|
||||
TrackPageShortTitle = 'Gag Training'
|
||||
TrackPageSubtitle = 'Complete ToonTasks to learn how to use new gags!'
|
||||
|
|
Loading…
Reference in a new issue