diff --git a/dependencies/astron/dclass/stride.dc b/dependencies/astron/dclass/stride.dc index bc1c1220..1d3199a8 100644 --- a/dependencies/astron/dclass/stride.dc +++ b/dependencies/astron/dclass/stride.dc @@ -332,7 +332,7 @@ from toontown.coghq import BattleBlocker/AI from toontown.ai import DistributedBlackCatMgr/AI from toontown.ai import DistributedReportMgr/AI from toontown.ai import DistributedPolarPlaceEffectMgr/AI -from toontown.ai import DistributedGreenToonEffectMgr/AI +from toontown.ai import DistributedEffectMgr/AI from toontown.ai import DistributedResistanceEmoteMgr/AI from toontown.ai import DistributedScavengerHuntTarget/AI from toontown.ai import DistributedTrickOrTreatTarget/AI @@ -2431,8 +2431,9 @@ dclass DistributedPolarPlaceEffectMgr : DistributedObject { addPolarPlaceEffect() airecv clsend; }; -dclass DistributedGreenToonEffectMgr : DistributedObject { - addGreenToonEffect() airecv clsend; +dclass DistributedEffectMgr : DistributedObject { + setHoliday(uint8) required broadcast; + addEffect() airecv clsend; }; dclass DistributedResistanceEmoteMgr : DistributedObject { diff --git a/toontown/ai/DistributedEffectMgr.py b/toontown/ai/DistributedEffectMgr.py new file mode 100644 index 00000000..7af5c548 --- /dev/null +++ b/toontown/ai/DistributedEffectMgr.py @@ -0,0 +1,26 @@ +from direct.distributed.DistributedObject import DistributedObject +from otp.speedchat import SpeedChatGlobals +import HolidayGlobals + +class DistributedEffectMgr(DistributedObject): + + def delete(self): + self.ignoreAll() + DistributedObject.delete(self) + + def setHoliday(self, holiday): + self.holiday = holiday + print 'holiday is %s' % self.holiday + self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.__saidPhrase) + + def __saidPhrase(self, phraseId): + if not self.cr.newsManager.isHolidayRunning(self.holiday): + return + + holidayInfo = HolidayGlobals.getHoliday(self.holiday) + + if 'speedchatIndex' not in holidayInfo or phraseId != holidayInfo['speedchatIndex']: + return + + self.sendUpdate('addEffect') + self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage') \ No newline at end of file diff --git a/toontown/ai/DistributedEffectMgrAI.py b/toontown/ai/DistributedEffectMgrAI.py new file mode 100644 index 00000000..c2ff1c58 --- /dev/null +++ b/toontown/ai/DistributedEffectMgrAI.py @@ -0,0 +1,26 @@ +from direct.distributed.DistributedObjectAI import DistributedObjectAI +import HolidayGlobals + +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 + + def addEffect(self): + if not self.air.newsManager.isHolidayRunning(self.holiday): + return + + av = self.air.doId2do.get(self.air.getAvatarIdFromSender()) + + if not av: + return + + holiday = HolidayGlobals.getHoliday(self.holiday) + expireTime = int(HolidayGlobals.getUnixTime(HolidayGlobals.getEndDate(holiday)) / 60) + + av.b_setCheesyEffect(self.effectId, 0, expireTime) \ No newline at end of file diff --git a/toontown/ai/DistributedGreenToonEffectMgr.py b/toontown/ai/DistributedGreenToonEffectMgr.py deleted file mode 100755 index 8fe4c605..00000000 --- a/toontown/ai/DistributedGreenToonEffectMgr.py +++ /dev/null @@ -1,32 +0,0 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed import DistributedObject -from direct.interval.IntervalGlobal import * -from otp.speedchat import SpeedChatGlobals -from toontown.toonbase import TTLocalizer - -class DistributedGreenToonEffectMgr(DistributedObject.DistributedObject): - notify = DirectNotifyGlobal.directNotify.newCategory('DistributedGreenToonEffectMgr') - - def __init__(self, cr): - DistributedObject.DistributedObject.__init__(self, cr) - - def announceGenerate(self): - DistributedObject.DistributedObject.announceGenerate(self) - DistributedGreenToonEffectMgr.notify.debug('announceGenerate') - self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.phraseSaid) - - def phraseSaid(self, phraseId): - greenPhrase = 30450 - if phraseId == greenPhrase: - self.addGreenToonEffect() - - def delete(self): - self.ignore(SpeedChatGlobals.SCStaticTextMsgEvent) - DistributedObject.DistributedObject.delete(self) - - def addGreenToonEffect(self): - DistributedGreenToonEffectMgr.notify.debug('addGreenToonEffect') - av = base.localAvatar - self.sendUpdate('addGreenToonEffect', []) - msgTrack = Sequence(Func(av.setSystemMessage, 0, TTLocalizer.GreenToonEffectMsg)) - msgTrack.start() diff --git a/toontown/ai/DistributedGreenToonEffectMgrAI.py b/toontown/ai/DistributedGreenToonEffectMgrAI.py deleted file mode 100755 index ac6345e5..00000000 --- a/toontown/ai/DistributedGreenToonEffectMgrAI.py +++ /dev/null @@ -1,20 +0,0 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectAI import DistributedObjectAI -from direct.distributed.ClockDelta import * -from direct.fsm.FSM import FSM - -class DistributedGreenToonEffectMgrAI(DistributedObjectAI, FSM): - notify = DirectNotifyGlobal.directNotify.newCategory("DistributedGreenToonEffectMgrAI") - - def __init__(self, air): - DistributedObjectAI.__init__(self, air) - FSM.__init__(self, 'GreenToonFSM') - self.air = air - - def enterOff(self): - self.requestDelete() - - def addGreenToonEffect(self): - avId = self.air.getAvatarIdFromSender() - av = self.air.doId2do.get(avId) - av.b_setCheesyEffect(15, 0, 0) diff --git a/toontown/ai/HolidayGlobals.py b/toontown/ai/HolidayGlobals.py index 4f0f163c..a4a1bc66 100644 --- a/toontown/ai/HolidayGlobals.py +++ b/toontown/ai/HolidayGlobals.py @@ -1,4 +1,5 @@ from toontown.toonbase import ToontownGlobals, TTLocalizer +import calendar, datetime Holidays = { ToontownGlobals.LAUGHING_MAN: { @@ -43,8 +44,35 @@ Holidays = { 'startMessage': TTLocalizer.AprilToonsWeekStart, 'ongoingMessage': TTLocalizer.AprilToonsWeekStart, 'endMessage': TTLocalizer.AprilToonsWeekEnd + }, + ToontownGlobals.IDES_OF_MARCH: { + 'startMonth': 3, + 'startDay': 14, + 'endMonth': 3, + 'endDay': 20, + 'startMessage': TTLocalizer.IdesOfMarchStart, + 'ongoingMessage': TTLocalizer.IdesOfMarchStart, + 'endMessage': TTLocalizer.IdesOfMarchEnd, + 'speedchatIndex': 30450, # It's easy to be green! + 'effectMessage': TTLocalizer.GreenToonEffectMsg } } def getHoliday(id): - return Holidays.get(id, {}) \ No newline at end of file + return Holidays.get(id, {}) + +def getUnixTime(date): + epoch = datetime.datetime.fromtimestamp(0) + delta = date - epoch + + return delta.total_seconds() + +def getEndDate(holiday): + rightNow = datetime.datetime.now() + endMonth = holiday['endMonth'] if 'endMonth' in holiday else rightNow.month + endDay = holiday['endDay'] if 'endDay' in holiday else (rightNow.day if 'weekDay' in holiday else calendar.monthrange(rightNow.year, endMonth)[1]) + + date = datetime.datetime(rightNow.year, endMonth, endDay) + date += datetime.timedelta(days=1) + + return date \ No newline at end of file diff --git a/toontown/ai/NewsManager.py b/toontown/ai/NewsManager.py index 9673ad40..3c809def 100755 --- a/toontown/ai/NewsManager.py +++ b/toontown/ai/NewsManager.py @@ -60,6 +60,8 @@ class NewsManager(DistributedObject): base.localAvatar.startAprilToonsControls() base.localAvatar.chatMgr.chatInputSpeedChat.addAprilToonsMenu() + elif id == ToontownGlobals.IDES_OF_MARCH: + base.localAvatar.chatMgr.chatInputSpeedChat.addIdesOfMarchMenu() def endSpecialHoliday(self, id): if id == ToontownGlobals.LAUGHING_MAN: @@ -69,4 +71,6 @@ class NewsManager(DistributedObject): if isinstance(base.cr.playGame.getPlace(), Estate.Estate): base.localAvatar.stopAprilToonsControls() - base.localAvatar.chatMgr.chatInputSpeedChat.removeAprilToonsMenu() \ No newline at end of file + base.localAvatar.chatMgr.chatInputSpeedChat.removeAprilToonsMenu() + elif id == ToontownGlobals.IDES_OF_MARCH: + base.localAvatar.chatMgr.chatInputSpeedChat.removeIdesOfMarchMenu() \ No newline at end of file diff --git a/toontown/distributed/PlayGame.py b/toontown/distributed/PlayGame.py index 90084be9..403752df 100755 --- a/toontown/distributed/PlayGame.py +++ b/toontown/distributed/PlayGame.py @@ -393,9 +393,6 @@ class PlayGame(StateData.StateData): base.localAvatar.chatMgr.obscure(1, 1) base.localAvatar.obscureFriendsListButton(1) requestStatus['how'] = 'tutorial' - if base.config.GetString('language', 'english') == 'japanese': - musicVolume = base.config.GetFloat('tutorial-music-volume', 0.5) - requestStatus['musicVolume'] = musicVolume self.hood.enter(requestStatus) def exitTutorialHood(self): @@ -557,8 +554,4 @@ class PlayGame(StateData.StateData): return self.place def getPlaceId(self): - if self.hood: - return self.hood.hoodId - else: - return None - return None + return self.hood.hoodId if self.hood else None \ No newline at end of file diff --git a/toontown/hood/DGHoodAI.py b/toontown/hood/DGHoodAI.py index 5e049939..4a860004 100755 --- a/toontown/hood/DGHoodAI.py +++ b/toontown/hood/DGHoodAI.py @@ -4,11 +4,10 @@ from toontown.safezone import DistributedButterflyAI from toontown.safezone import DistributedDGFlowerAI from toontown.safezone import DistributedTrolleyAI from toontown.toonbase import ToontownGlobals -#from toontown.ai import DistributedGreenToonEffectMgrAI -from toontown.ai import DistributedTrickOrTreatTargetAI - +from toontown.ai import DistributedEffectMgrAI, DistributedTrickOrTreatTargetAI class DGHoodAI(HoodAI.HoodAI): + def __init__(self, air): HoodAI.HoodAI.__init__(self, air, ToontownGlobals.DaisyGardens, @@ -28,8 +27,8 @@ class DGHoodAI(HoodAI.HoodAI): if simbase.config.GetBool('want-butterflies', True): self.createButterflies() - #self.GreenToonEffectManager = DistributedGreenToonEffectMgrAI.DistributedGreenToonEffectMgrAI(self.air) - #self.GreenToonEffectManager.generateWithRequired(5819) + self.greenToonMgr = DistributedEffectMgrAI.DistributedEffectMgrAI(self.air, ToontownGlobals.IDES_OF_MARCH, 15) + self.greenToonMgr.generateWithRequired(5819) if simbase.air.wantHalloween: self.TrickOrTreatTargetManager = DistributedTrickOrTreatTargetAI.DistributedTrickOrTreatTargetAI(self.air) diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index c309ecf4..3160c507 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -7988,6 +7988,7 @@ WinterCarolingStart = 'Caroling has come to Toontown. Sing for your Snowman Head ExpandedClosetsStart = 'Attention Toons: For a limited time, Members can purchase the new 50 item Closet from the Cattlelog for the low price of 50 Jellybeans!' KartingTicketsHolidayStart = 'Get double tickets from Practice races at Goofy Speedway today!' IdesOfMarchStart = 'Toons go GREEN!' +IdesOfMarchEnd = 'Hope you had fun being green.' LogoutForced = 'You have done something wrong\n and are being logged out automatically,\n additionally your account may be frozen.\n Try going on a walk outside, it is fun.' CountryClubToonEnterElevator = '%s \nhas jumped in the golf kart.' CountryClubBossConfrontedMsg = '%s is battling the Club President!'