mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 11:42:39 -06:00
Upgrade the code redemption system - you can't use the same code twice anymore and expiration dates are added.
This commit is contained in:
parent
1951b91907
commit
e9ffbadbd6
8 changed files with 52 additions and 33 deletions
|
@ -626,6 +626,7 @@ dclass DistributedToon : DistributedPlayer {
|
|||
flagAv(uint32, uint16, string []) airecv ownsend;
|
||||
setAnimalSound(uint8 index) ram broadcast ownrecv;
|
||||
setBuffs(uint32[] = []) required ownrecv db;
|
||||
setRedeemedCodes(string [] = []) required ownrecv db;
|
||||
};
|
||||
|
||||
dclass DistributedCCharBase : DistributedObject {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from pandac.PandaModules import *
|
||||
|
||||
|
||||
hashVal = 1907452799
|
||||
hashVal = 1165841663
|
||||
|
||||
|
||||
from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot
|
||||
|
|
|
@ -2,9 +2,23 @@ from direct.directnotify import DirectNotifyGlobal
|
|||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
from toontown.catalog import CatalogClothingItem
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import time
|
||||
|
||||
"""
|
||||
Code example:
|
||||
|
||||
'codeName': {
|
||||
'items': [
|
||||
CatalogTypeItem.CatalogTypeItem(arguments)
|
||||
]
|
||||
'expirationDate': datetime(2020, 1, 30),
|
||||
'month': 1,
|
||||
'day': 30
|
||||
}
|
||||
|
||||
Expiration date, month and day are optional fields.
|
||||
"""
|
||||
class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("TTCodeRedemptionMgrAI")
|
||||
codes = {
|
||||
|
@ -20,7 +34,7 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
|
||||
def getMailboxCount(items):
|
||||
def getMailboxCount(self, items):
|
||||
count = 0
|
||||
|
||||
for item in items:
|
||||
|
@ -38,13 +52,13 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
|
||||
if code in self.codes:
|
||||
if av.isCodeRedeemed(code):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 4])
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 2])
|
||||
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']):
|
||||
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)):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 2, 0])
|
||||
return
|
||||
|
||||
|
@ -54,21 +68,16 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
|
|||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 1, 0])
|
||||
|
||||
def requestCodeRedeem(self, context, avId, av, items):
|
||||
if item in av.onOrder:
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 2])
|
||||
return
|
||||
|
||||
if item.reachedPurchaseLimit(av):
|
||||
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [context, 3, 3])
|
||||
return
|
||||
|
||||
count = getMailboxCount(items)
|
||||
count = self.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
|
||||
|
||||
for item in items:
|
||||
if item in av.onOrder or item.reachedPurchaseLimit:
|
||||
continue
|
||||
|
||||
item.deliveryDate = int(time.time() / 60) + 0.01
|
||||
av.onOrder.append(item)
|
||||
|
||||
|
|
|
@ -657,10 +657,6 @@ class CodesTabPage(DirectFrame):
|
|||
if awardMgrResult == 1:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultMailboxFull
|
||||
elif awardMgrResult == 2:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyInMailbox
|
||||
elif awardMgrResult == 3:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultReachedLimit
|
||||
elif awardMgrResult == 4:
|
||||
self.resultPanel['text'] = TTLocalizer.CdrResultAlreadyRedeemed
|
||||
if result == 0:
|
||||
self.successSfx.play()
|
||||
|
|
|
@ -185,6 +185,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
|||
self.canEarnAchievements = False
|
||||
self.promotionStatus = [0, 0, 0, 0]
|
||||
self.buffs = []
|
||||
self.redeemedCodes = []
|
||||
|
||||
def disable(self):
|
||||
for soundSequence in self.soundSequenceList:
|
||||
|
@ -2635,6 +2636,9 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
|
|||
self.buffs = buffs
|
||||
self.applyBuffs()
|
||||
|
||||
def setRedeemedCodes(self, redeemedCodes):
|
||||
self.redeemedCodes = redeemedCodes
|
||||
|
||||
def applyBuffs(self):
|
||||
for id, timestamp in enumerate(self.buffs):
|
||||
if id == ToontownGlobals.BMovementSpeed:
|
||||
|
|
|
@ -566,19 +566,6 @@ 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
|
||||
|
@ -4292,6 +4279,27 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
|
|||
self.setBuffs(buffs)
|
||||
self.d_setBuffs(buffs)
|
||||
|
||||
def setRedeemedCodes(self, redeemedCodes):
|
||||
self.redeemedCodes = redeemedCodes
|
||||
|
||||
def d_setRedeemedCodes(self, redeemedCodes):
|
||||
self.sendUpdate('setRedeemedCodes', [redeemedCodes])
|
||||
|
||||
def b_setRedeemedCodes(self, redeemedCodes):
|
||||
self.setRedeemedCodes(redeemedCodes)
|
||||
self.d_setRedeemedCodes(redeemedCodes)
|
||||
|
||||
def getRedeemedCodes(self, redeemedCodes):
|
||||
return self.redeemedCodes
|
||||
|
||||
def isCodeRedeemed(self, code):
|
||||
return code in self.redeemedCodes
|
||||
|
||||
def redeemCode(self, code):
|
||||
if not self.isCodeRedeemed(code):
|
||||
self.redeemedCodes.append(code)
|
||||
self.b_setRedeemedCodes(self.redeemedCodes)
|
||||
|
||||
|
||||
@magicWord(category=CATEGORY_PROGRAMMER, types=[str, int, int])
|
||||
def cheesyEffect(value, hood=0, expire=0):
|
||||
|
|
|
@ -543,3 +543,6 @@ class DistributedToonUD(DistributedObjectUD):
|
|||
|
||||
def setAchievements(self, achievements):
|
||||
pass
|
||||
|
||||
def setRedeemedCodes(self, redeemedCodes):
|
||||
pass
|
||||
|
|
|
@ -4699,8 +4699,6 @@ 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."
|
||||
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."
|
||||
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'
|
||||
|
|
Loading…
Reference in a new issue