mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-10-31 00:37:54 +00:00
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from direct.distributed.DistributedObject import DistributedObject
|
|
from otp.speedchat import SpeedChatGlobals
|
|
import HolidayGlobals, time
|
|
|
|
class DistributedEffectMgr(DistributedObject):
|
|
|
|
def __init__(self, cr):
|
|
DistributedObject.__init__(self, cr)
|
|
self.nextTime = 0
|
|
|
|
def delete(self):
|
|
self.ignoreAll()
|
|
DistributedObject.delete(self)
|
|
|
|
def setHoliday(self, holiday):
|
|
self.holiday = holiday
|
|
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.__saidPhrase)
|
|
|
|
def __saidPhrase(self, phraseId):
|
|
if not self.cr.newsManager.isHolidayRunning(self.holiday):
|
|
return
|
|
|
|
currentTime = time.time()
|
|
|
|
if self.nextTime > currentTime:
|
|
return
|
|
|
|
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
|
|
|
|
if 'speedchatIndexes' not in holidayInfo or phraseId not in holidayInfo['speedchatIndexes']:
|
|
return
|
|
|
|
if 'effectDelay' in holidayInfo:
|
|
self.nextTime = currentTime + holidayInfo['effectDelay']
|
|
|
|
self.sendUpdate('requestEffect')
|
|
|
|
def effectDone(self, amount):
|
|
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
|
|
|
|
self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage')
|
|
|
|
if 'scavengerHunt' in holidayInfo:
|
|
type = holidayInfo['scavengerHunt']
|
|
|
|
if type == HolidayGlobals.TRICK_OR_TREAT:
|
|
base.localAvatar.trickOrTreatTargetMet(amount)
|
|
elif type == HolidayGlobals.WINTER_CAROLING:
|
|
base.localAvatar.winterCarolingTargetMet(amount)
|