diff --git a/toontown/ai/HolidayGlobals.py b/toontown/ai/HolidayGlobals.py index d9ebdef3..56c5688e 100644 --- a/toontown/ai/HolidayGlobals.py +++ b/toontown/ai/HolidayGlobals.py @@ -65,10 +65,10 @@ Holidays = { 'effectDelay': 10 }, ToontownGlobals.CHRISTMAS: { - """'startMonth': 12, + 'startMonth': 12, 'startDay': 14, 'endMonth': 1, - 'endDay': 4,""" + 'endDay': 4, 'startMessage': TTLocalizer.WinterCarolingStart, 'ongoingMessage': TTLocalizer.WinterCarolingStart, 'endMessage': TTLocalizer.WinterCarolingEnd, @@ -87,6 +87,24 @@ Holidays = { 'speedchatIndexes': [10003], 'effectDelay': 15, 'scavengerHunt': TRICK_OR_TREAT + }, + ToontownGlobals.SUMMER_FIREWORKS: { + 'startMonth': 6, + 'startDay': 30, + 'endMonth': 7, + 'endDay': 15, + 'startMessage': TTLocalizer.SummerFireworksStart, + 'ongoingMessage': TTLocalizer.SummerFireworksStart, + 'endMessage': TTLocalizer.SummerFireworksEnd + }, + ToontownGlobals.NEW_YEAR_FIREWORKS: { + 'startMonth': 12, + 'startDay': 31, + 'endMonth': 1, + 'endDay': 7, + 'startMessage': TTLocalizer.NewYearFireworksStart, + 'ongoingMessage': TTLocalizer.NewYearFireworksStart, + 'endMessage': TTLocalizer.NewYearFireworksEnd } } diff --git a/toontown/ai/NewsManagerAI.py b/toontown/ai/NewsManagerAI.py index 450c5388..9377d16d 100755 --- a/toontown/ai/NewsManagerAI.py +++ b/toontown/ai/NewsManagerAI.py @@ -1,14 +1,19 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI +from direct.distributed.ClockDelta import globalClockDelta from direct.task import Task -from datetime import datetime +from toontown.effects.DistributedFireworkShowAI import DistributedFireworkShowAI +from toontown.effects import FireworkShows from toontown.toonbase import ToontownGlobals +from toontown.parties import PartyGlobals import HolidayGlobals +import datetime, random class NewsManagerAI(DistributedObjectAI): def __init__(self, air): DistributedObjectAI.__init__(self, air) self.activeHolidays = [] + self.fireworkTask = None def announceGenerate(self): DistributedObjectAI.announceGenerate(self) @@ -19,27 +24,39 @@ class NewsManagerAI(DistributedObjectAI): def delete(self): DistributedObjectAI.delete(self) taskMgr.remove(self.checkTask) + self.deleteFireworkTask() + def deleteFireworkTask(self): + if self.fireworkTask: + taskMgr.remove(self.fireworkTask) + self.fireworkTask = None + def __handleAvatarEntered(self, av): self.sendUpdateToAvatarId(av.getDoId(), 'setActiveHolidays', [self.activeHolidays]) - + def getActiveHolidays(self): return self.activeHolidays - + def __checkHolidays(self, task=None): - date = datetime.now() + date = datetime.datetime.utcnow().replace(tzinfo=HolidayGlobals.TIME_ZONE) for id in HolidayGlobals.Holidays: holiday = HolidayGlobals.Holidays[id] running = self.isHolidayRunning(id) - if ('weekDay' not in holiday or date.weekday() == holiday['weekDay']) and ('startMonth' not in holiday or holiday['startMonth'] <= date.month <= holiday['endMonth']) and ('startDay' not in holiday or holiday['startDay'] <= date.day <= holiday['endDay']): + if self.isHolidayInRange(holiday, date): if not running: self.startHoliday(id) elif running: self.endHoliday(id) return Task.again + + def isHolidayInRange(self, holiday, date): + if 'weekDay' in holiday: + return holiday['weekDay'] == date.weekday() + else: + return HolidayGlobals.getStartDate(holiday) <= date <= HolidayGlobals.getEndDate(holiday) def isHolidayRunning(self, id): return id in self.activeHolidays @@ -63,7 +80,26 @@ class NewsManagerAI(DistributedObjectAI): def startSpecialHoliday(self, id): if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY: messenger.send('checkBingoState') + elif id in [ToontownGlobals.SUMMER_FIREWORKS, ToontownGlobals.NEW_YEAR_FIREWORKS]: + if not self.fireworkTask: + self.fireworkTask = taskMgr.doMethodLater(3600, self.startFireworks, 'newsFireworkTask', extraArgs=[id, Task.again]) + taskMgr.doMethodLater(10, self.startFireworks, 'newsFireworkTask-initial', extraArgs=[id, Task.done]) def endSpecialHoliday(self, id): if id == ToontownGlobals.FISH_BINGO or id == ToontownGlobals.SILLY_SATURDAY: - messenger.send('checkBingoState') \ No newline at end of file + messenger.send('checkBingoState') + elif id in [ToontownGlobals.SUMMER_FIREWORKS, ToontownGlobals.NEW_YEAR_FIREWORKS]: + self.deleteFireworkTask() + + def startFireworks(self, type, again, task=None): + maxShow = len(FireworkShows.shows.get(type, [])) - 1 + + for hood in self.air.hoods: + if hood.zoneId == ToontownGlobals.GolfZone: + continue + + fireworkShow = DistributedFireworkShowAI(self.air) + fireworkShow.generateWithRequired(hood.zoneId) + fireworkShow.b_startShow(type, random.randint(0, maxShow), globalClockDelta.getRealNetworkTime()) + + return again \ No newline at end of file diff --git a/toontown/effects/DistributedFireworkShowAI.py b/toontown/effects/DistributedFireworkShowAI.py index 7663114c..e04b2d7b 100755 --- a/toontown/effects/DistributedFireworkShowAI.py +++ b/toontown/effects/DistributedFireworkShowAI.py @@ -43,9 +43,9 @@ def fireworks(showName='july4'): """ showName = showName.lower() if showName == 'july4': - showType = ToontownGlobals.JULY4_FIREWORKS + showType = ToontownGlobals.SUMMER_FIREWORKS elif showName == 'newyears': - showType = ToontownGlobals.NEWYEARS_FIREWORKS + showType = ToontownGlobals.NEW_YEAR_FIREWORKS elif showName == 'summer': showType = PartyGlobals.FireworkShows.Summer else: diff --git a/toontown/effects/FireworkShow.py b/toontown/effects/FireworkShow.py index f884bdb3..572e535a 100755 --- a/toontown/effects/FireworkShow.py +++ b/toontown/effects/FireworkShow.py @@ -15,9 +15,9 @@ colors = [Vec4(1, 1, 1, 1), Vec4(1, 0.1, 1, 1), Vec4(0.1, 1, 1, 1), Vec4(0.1, 0.5, 1, 1)] -fireworkShowTypes = [ToontownGlobals.JULY4_FIREWORKS, +fireworkShowTypes = [ToontownGlobals.SUMMER_FIREWORKS, PartyGlobals.FireworkShows.Summer, - ToontownGlobals.NEWYEARS_FIREWORKS, + ToontownGlobals.NEW_YEAR_FIREWORKS, ToontownGlobals.COMBO_FIREWORKS] class FireworkShow(NodePath): @@ -43,7 +43,7 @@ class FireworkShow(NodePath): def rD(): return random.randint(1, 20) / 10.0 - showData = {ToontownGlobals.JULY4_FIREWORKS: [[FireworkType.GlowFlare, + showData = {ToontownGlobals.SUMMER_FIREWORKS: [[FireworkType.GlowFlare, Vec3(-90, 0, 80), Vec3(120, 0, 0), rS(), @@ -739,7 +739,7 @@ class FireworkShow(NodePath): Vec4(1, 1, 1, 1), 1.5, 10.0]], - ToontownGlobals.NEWYEARS_FIREWORKS: [[FireworkType.GlowFlare, + ToontownGlobals.NEW_YEAR_FIREWORKS: [[FireworkType.GlowFlare, Vec3(0, 0, 180), Vec3(-120, 0, 0), rS(), @@ -1075,10 +1075,10 @@ class FireworkShow(NodePath): rC(), 2.0, 10.0]]} - showData[ToontownGlobals.COMBO_FIREWORKS] = showData[ToontownGlobals.NEWYEARS_FIREWORKS] - sectionData = {ToontownGlobals.JULY4_FIREWORKS: [(0, 24), (24, len(showData[ToontownGlobals.JULY4_FIREWORKS]))], + showData[ToontownGlobals.COMBO_FIREWORKS] = showData[ToontownGlobals.NEW_YEAR_FIREWORKS] + sectionData = {ToontownGlobals.SUMMER_FIREWORKS: [(0, 24), (24, len(showData[ToontownGlobals.SUMMER_FIREWORKS]))], PartyGlobals.FireworkShows.Summer: [(0, 24), (24, len(showData[PartyGlobals.FireworkShows.Summer]))], - ToontownGlobals.NEWYEARS_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))], + ToontownGlobals.NEW_YEAR_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))], ToontownGlobals.COMBO_FIREWORKS: [(0, len(showData[PartyGlobals.FireworkShows.Summer]))]} showMusic = {} @@ -1089,7 +1089,7 @@ class FireworkShow(NodePath): else: return False - def __init__(self, showType = ToontownGlobals.NEWYEARS_FIREWORKS): + def __init__(self, showType = ToontownGlobals.NEW_YEAR_FIREWORKS): NodePath.__init__(self, 'FireworkShow') self.showType = showType self.sectionIvals = [] diff --git a/toontown/effects/FireworkShowMixin.py b/toontown/effects/FireworkShowMixin.py index 4a5a82c6..f497b2a7 100755 --- a/toontown/effects/FireworkShowMixin.py +++ b/toontown/effects/FireworkShowMixin.py @@ -19,7 +19,7 @@ class FireworkShowMixin: self.startDelay = startDelay self.timestamp = None self.fireworkShow = None - self.eventId = JULY4_FIREWORKS + self.eventId = SUMMER_FIREWORKS self.accept('MusicEnabled', self.startMusic) return @@ -77,13 +77,13 @@ class FireworkShowMixin: return def preShow(self, eventId, songId, startT): - if eventId == JULY4_FIREWORKS: + if eventId == SUMMER_FIREWORKS: instructionMessage = TTLocalizer.FireworksInstructions startMessage = TTLocalizer.FireworksJuly4Beginning endMessage = TTLocalizer.FireworksJuly4Ending songs = ['tt_summer', 'firework_music'] musicFile = 'phase_4/audio/bgm/%s.ogg' % songs[songId] - elif eventId == NEWYEARS_FIREWORKS: + elif eventId == NEW_YEAR_FIREWORKS: instructionMessage = TTLocalizer.FireworksInstructions startMessage = TTLocalizer.FireworksNewYearsEveBeginning endMessage = TTLocalizer.FireworksNewYearsEveEnding @@ -146,9 +146,9 @@ class FireworkShowMixin: base.camLens.setFar(DefaultCameraFar) def postShow(self, eventId): - if eventId == JULY4_FIREWORKS: + if eventId == SUMMER_FIREWORKS: endMessage = TTLocalizer.FireworksJuly4Ending - elif eventId == NEWYEARS_FIREWORKS: + elif eventId == NEW_YEAR_FIREWORKS: endMessage = TTLocalizer.FireworksNewYearsEveEnding elif eventId == PartyGlobals.FireworkShows.Summer: endMessage = TTLocalizer.FireworksActivityEnding diff --git a/toontown/effects/FireworkShows.py b/toontown/effects/FireworkShows.py index 2c4c1c52..c1f196ec 100755 --- a/toontown/effects/FireworkShows.py +++ b/toontown/effects/FireworkShows.py @@ -1,7 +1,7 @@ from FireworkGlobals import * from toontown.toonbase import ToontownGlobals from toontown.parties import PartyGlobals -shows = {ToontownGlobals.JULY4_FIREWORKS: [((2, +shows = {ToontownGlobals.SUMMER_FIREWORKS: [((2, ROCKET, RED, RED, @@ -5065,7 +5065,7 @@ shows = {ToontownGlobals.JULY4_FIREWORKS: [((2, -23, 3, 100))], - ToontownGlobals.NEWYEARS_FIREWORKS: [((0.5, + ToontownGlobals.NEW_YEAR_FIREWORKS: [((0.5, ROCKET, WHITE, WHITE, diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index fedcc30e..e68c95bf 100755 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -6879,7 +6879,6 @@ PetTrait2descriptions = {'hungerThreshold': ('Always Hungry', 'Often Affectionate', 'Always Affectionate')} FireworksInstructions = lToonHQ + ': Hit the "Page Up" key to see the show!' -startFireworksResponse = "Usage: startFireworksShow ['num']\n 'num' = %s - New Years\n %s - Party Summer \n %s - 4th of July" FireworksJuly4Beginning = lToonHQ + ': Welcome to summer fireworks! Enjoy the show!' FireworksJuly4Ending = lToonHQ + ': Hope you enjoyed the show! Have a great summer!' FireworksNewYearsEveBeginning = lToonHQ + ': Happy New Year! Enjoy the fireworks show, sponsored by Flippy!' @@ -8222,6 +8221,10 @@ DayNamesAbbrev = ('MON', 'FRI', 'SAT', 'SUN') +SummerFireworksStart = 'Celebrate Summer with a fireworks show every hour in each playground!' +SummerFireworksEnd = 'Summer Fireworks are over. Hope you had fun.' +NewYearFireworksStart = 'Happy New Year! Enjoy a fireworks show every hour in each playground!' +NewYearFireworksEnd = 'New Year Fireworks are over. See you next year!' HolidayNamesInCalendar = {1: ('Summer Fireworks', 'Celebrate Summer with a fireworks show every hour in each playground!'), 2: ('New Year Fireworks', 'Happy New Year! Enjoy a fireworks show every hour in each playground!'), 3: ('Halloween', 'Happy Halloween! Trick or treat throughout Toontown to get a nifty Halloween pumpkin head reward!'), diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index ce774f19..bda0face 100755 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -824,9 +824,8 @@ WaiterInvasionBulletin = 9 V2InvasionBegin = 10 V2InvasionEnd = 11 V2InvasionBulletin = 12 -NO_HOLIDAY = 0 -JULY4_FIREWORKS = 1 -NEWYEARS_FIREWORKS = 2 +SUMMER_FIREWORKS = 1 +NEW_YEAR_FIREWORKS = 2 HALLOWEEN = 3 CHRISTMAS = 4 SKELECOG_INVASION = 5