2015-03-09 17:33:29 +00:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
2015-03-03 22:10:12 +00:00
|
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
from CatalogGenerator import CatalogGenerator
|
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
import time
|
|
|
|
|
|
|
|
class CatalogManagerAI(DistributedObjectAI):
|
2015-03-09 17:33:29 +00:00
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory("CatalogManagerAI")
|
|
|
|
|
2015-03-03 22:10:12 +00:00
|
|
|
def __init__(self, air):
|
|
|
|
DistributedObjectAI.__init__(self, air)
|
|
|
|
self.catalogGenerator = CatalogGenerator()
|
|
|
|
|
|
|
|
def startCatalog(self):
|
|
|
|
avId = self.air.getAvatarIdFromSender()
|
|
|
|
av = self.air.doId2do.get(avId)
|
|
|
|
if av:
|
2015-03-09 17:33:29 +00:00
|
|
|
self.deliverCatalogFor(av)
|
|
|
|
|
2015-03-03 22:10:12 +00:00
|
|
|
def deliverCatalogFor(self, av):
|
|
|
|
monthlyCatalog = self.catalogGenerator.generateMonthlyCatalog(av, time.time() / 60)
|
|
|
|
newWeek = (av.catalogScheduleCurrentWeek + 1) % ToontownGlobals.CatalogNumWeeks
|
|
|
|
weeklyCatalog = self.catalogGenerator.generateWeeklyCatalog(av, newWeek, monthlyCatalog)
|
|
|
|
backCatalog = self.catalogGenerator.generateBackCatalog(av, newWeek, av.catalogScheduleCurrentWeek, monthlyCatalog)
|
|
|
|
av.b_setCatalog(monthlyCatalog, weeklyCatalog, backCatalog)
|
|
|
|
av.b_setCatalogSchedule(newWeek, int((time.time() + 604800)/60))
|
|
|
|
av.b_setCatalogNotify(ToontownGlobals.NewItems, av.mailboxNotify)
|
2015-03-09 17:33:29 +00:00
|
|
|
|
|
|
|
def isItemReleased(self, accessory):
|
|
|
|
return 1
|
2015-03-03 22:10:12 +00:00
|
|
|
|