From f814b63c0875bc831556298c48ef49c1d0b7011d Mon Sep 17 00:00:00 2001 From: Loudrob Date: Tue, 5 May 2015 18:10:39 -0400 Subject: [PATCH] Added year field, and appropriate message for month, day and year code rejection. --- .../coderedemption/TTCodeRedemptionMgrAI.py | 20 +++++++++++++++---- toontown/shtiker/OptionsPage.py | 6 ++++++ toontown/toonbase/TTLocalizerEnglish.py | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/toontown/coderedemption/TTCodeRedemptionMgrAI.py b/toontown/coderedemption/TTCodeRedemptionMgrAI.py index a0697f7f..ea955c48 100644 --- a/toontown/coderedemption/TTCodeRedemptionMgrAI.py +++ b/toontown/coderedemption/TTCodeRedemptionMgrAI.py @@ -30,10 +30,11 @@ Code example: ], 'expirationDate': datetime(2020, 1, 30), 'month': 1, - 'day': 30 + 'day': 30, + 'year': 2000' } -Expiration date, month and day are optional fields. +Expiration date, month, day and year are optional fields. If you for some reason are not familiar with arrays or lists, you only include the comma if there are multiple arguments. @@ -42,6 +43,7 @@ only include the comma if there are multiple arguments. class TTCodeRedemptionMgrAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory("TTCodeRedemptionMgrAI") codes = { + # weed code is for testing purposes, remove when done. 'weed': { 'items': [ CatalogClothingItem.CatalogClothingItem(1821, 0) @@ -78,19 +80,28 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI): if code in self.codes: if av.isCodeRedeemed(code): self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [4]) + print ('%s tried to redeem already redeemed code %s' % (avId, code)) return codeInfo = self.codes[code] date = datetime.now() - if ('month' in codeInfo and date.month is not codeInfo['month']) or ('day' in codeInfo and date.day is not codeInfo['day']) or ('expirationDate' in codeInfo and codeInfo['expirationDate'] - date < timedelta(hours = 1)): + if ('year' in codeInfo and date.year is not codeInfo['year']) and date.year > codeInfo['year'] or ('expirationDate' in codeInfo and codeInfo['expirationDate'] - date < timedelta(hours = 1)): self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [2]) + print ('%s attempted to redeem code %s but it was expired!' % (avId, code)) return - + elif ('year' in codeInfo and date.year is not codeInfo['year']) and date.year < codeInfo['year'] or ('month' in codeInfo and date.month is not codeInfo['month']) or ('day' in codeInfo and date.day is not codeInfo['day']): + self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [5]) + print ("%s attempted to redeem code %s but it wasn't usable yet!" % (avId, code)) + return + av.redeemCode(code) self.requestCodeRedeem(avId, av, codeInfo['items']) + print ('%s successfully redeemed %s' % (avId, code)) else: self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [1]) + print ('%s tried to redeem non-existant code %s' % (avId, code)) + def requestCodeRedeem(self, avId, av, items): count = self.getMailboxCount(items) @@ -108,3 +119,4 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI): av.b_setDeliverySchedule(av.onOrder) self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [0]) + print ('%s is being sent %s from redeemed code' % (avId, items)) diff --git a/toontown/shtiker/OptionsPage.py b/toontown/shtiker/OptionsPage.py index 75f11254..532315ab 100644 --- a/toontown/shtiker/OptionsPage.py +++ b/toontown/shtiker/OptionsPage.py @@ -683,6 +683,12 @@ class CodesTabPage(DirectFrame): elif result == 4: self.resultPanel['image'] = self.resultPanelErrorGui self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyRedeemed + elif result == 5: + self.resultPanel['image'] = self.resultPanelErrorGui + self.resultPanel['text'] = TTLocalizer.CdrResultNotReady + elif result == 6: + self.resultPanel['image'] = self.resultPanelErrorGui + self.resultPanel['text'] = TTLocalizer.CdrResultNotEligible if result == 0: self.successSfx.play() else: diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 452d3420..008cf330 100644 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -3871,6 +3871,7 @@ CdrResultExpiredCode = "We're sorry. This code has expired." CdrResultMailboxFull = 'Your mailbox is full. Please remove an item, then enter your code again.' CdrResultAlreadyRedeemed = "You've already redeemed this item!" CdrResultNotReady = "This code can't be used yet!" +CdrResultNotEligible = 'You are not eligible to use this code!' TrackPageTitle = 'Gag Track Training' TrackPageShortTitle = 'Gag Training' TrackPageSubtitle = 'Complete ToonTasks to learn how to use new gags!'