mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Added year field, and appropriate message for month, day and year code rejection.
This commit is contained in:
parent
712e41a369
commit
f814b63c08
3 changed files with 23 additions and 4 deletions
|
@ -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))
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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!'
|
||||
|
|
Loading…
Reference in a new issue