Poodletooth-iLand/toontown/ai/DistributedEffectMgrAI.py

44 lines
1.5 KiB
Python
Raw Normal View History

from direct.distributed.DistributedObjectAI import DistributedObjectAI
import HolidayGlobals
2015-06-25 03:57:02 -05:00
import datetime
class DistributedEffectMgrAI(DistributedObjectAI):
def __init__(self, air, holiday, effectId):
DistributedObjectAI.__init__(self, air)
self.holiday = holiday
self.effectId = effectId
def getHoliday(self):
return self.holiday
2015-06-23 07:55:15 -05:00
def requestEffect(self):
if not self.air.newsManager.isHolidayRunning(self.holiday):
return
2015-06-23 07:55:15 -05:00
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av:
return
2015-06-23 15:20:41 -05:00
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
2015-06-25 03:57:02 -05:00
expireTime = int(HolidayGlobals.getServerTime(HolidayGlobals.getEndDate(holidayInfo) + datetime.timedelta(days=1)) / 60)
2015-06-23 15:20:41 -05:00
if 'scavengerHunt' in holidayInfo:
scavengerHunt = av.getScavengerHunt()
if self.zoneId in scavengerHunt:
self.sendUpdateToAvatarId(avId, 'effectDone', [0])
else:
scavengerHunt.append(self.zoneId)
av.b_setScavengerHunt(scavengerHunt)
av.addMoney(HolidayGlobals.CAROLING_REWARD)
self.sendUpdateToAvatarId(avId, 'effectDone', [HolidayGlobals.CAROLING_REWARD])
2015-06-23 15:22:35 -05:00
if len(scavengerHunt) == HolidayGlobals.SCAVENGER_HUNT_LOCATIONS:
av.b_setCheesyEffect(self.effectId, 0, expireTime)
2015-06-23 15:20:41 -05:00
else:
av.b_setCheesyEffect(self.effectId, 0, expireTime)
2015-07-05 18:59:25 -05:00
self.sendUpdateToAvatarId(avId, 'effectDone', [0])