Poodletooth-iLand/toontown/ai/HolidayGlobals.py

144 lines
4.8 KiB
Python
Raw Normal View History

2015-06-22 02:23:46 -05:00
from toontown.toonbase import ToontownGlobals, TTLocalizer
2015-06-25 05:04:26 -05:00
from toontown.parties import ToontownTimeZone
import calendar, datetime
2015-06-22 02:23:46 -05:00
2015-06-25 05:04:26 -05:00
TIME_ZONE = ToontownTimeZone.ToontownTimeZone()
2015-06-23 15:20:41 -05:00
TRICK_OR_TREAT = 0
WINTER_CAROLING = 1
CAROLING_REWARD = 100
SCAVENGER_HUNT_LOCATIONS = 6
2015-06-22 02:23:46 -05:00
Holidays = {
ToontownGlobals.GRAND_PRIX: {
'weekDay': 0,
'startMessage': TTLocalizer.CircuitRaceStart,
'ongoingMessage': TTLocalizer.CircuitRaceOngoing,
'endMessage': TTLocalizer.CircuitRaceEnd
},
ToontownGlobals.FISH_BINGO: {
'weekDay': 2,
'startMessage': TTLocalizer.FishBingoStart,
'ongoingMessage': TTLocalizer.FishBingoOngoing,
'endMessage': TTLocalizer.FishBingoEnd
},
ToontownGlobals.SILLY_SATURDAY: {
'weekDay': 5,
'startMessage': TTLocalizer.SillySaturdayStart,
'ongoingMessage': TTLocalizer.SillySaturdayOngoing,
'endMessage': TTLocalizer.SillySaturdayEnd
},
ToontownGlobals.BLACK_CAT_DAY: {
'startDay': 13,
'endDay': 13,
'startMessage': TTLocalizer.BlackCatHolidayStart,
'ongoingMessage': TTLocalizer.BlackCatHolidayStart,
'endMessage': TTLocalizer.BlackCatHolidayEnd
},
ToontownGlobals.APRIL_TOONS_WEEK: {
'startMonth': 4,
'startDay': 1,
'endMonth': 4,
'endDay': 7,
'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,
'speedchatIndexes': [30450], # It's easy to be green!
2015-06-23 07:55:15 -05:00
'effectMessage': TTLocalizer.GreenToonEffectMsg,
'effectDelay': 10
2015-06-23 15:20:41 -05:00
},
ToontownGlobals.CHRISTMAS: {
2015-06-25 13:20:15 -05:00
'startMonth': 12,
2015-06-23 15:20:41 -05:00
'startDay': 14,
'endMonth': 1,
2015-06-25 13:20:15 -05:00
'endDay': 4,
2015-06-23 15:20:41 -05:00
'startMessage': TTLocalizer.WinterCarolingStart,
'ongoingMessage': TTLocalizer.WinterCarolingStart,
'endMessage': TTLocalizer.WinterCarolingEnd,
'speedchatIndexes': range(30200, 30206),
'effectDelay': 15,
'scavengerHunt': WINTER_CAROLING
},
ToontownGlobals.HALLOWEEN: {
2015-06-23 15:20:41 -05:00
'startMonth': 10,
'startDay': 13,
'endMonth': 10,
'endDay': 31,
'startMessage': TTLocalizer.TrickOrTreatStart,
'ongoingMessage': TTLocalizer.TrickOrTreatStart,
'endMessage': TTLocalizer.TrickOrTreatEnd,
'speedchatIndexes': [10003],
'effectDelay': 15,
'scavengerHunt': TRICK_OR_TREAT
2015-06-25 13:20:15 -05:00
},
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
2015-06-25 13:43:32 -05:00
},
ToontownGlobals.VALENTOONS_DAY: {
'startMonth': 2,
'startDay': 9,
'endMonth': 2,
'endDay': 16,
'startMessage': TTLocalizer.ValentinesDayStart,
'ongoingMessage': TTLocalizer.ValentinesDayStart,
'endMessage': TTLocalizer.ValentinesDayEnd
2015-06-22 02:23:46 -05:00
}
}
def getHoliday(id):
return Holidays.get(id, {})
2015-06-25 03:57:02 -05:00
def getServerTime(date):
2015-06-25 05:04:26 -05:00
epoch = datetime.datetime.fromtimestamp(0, TIME_ZONE)
delta = date - epoch
return delta.total_seconds()
2015-06-25 05:04:26 -05:00
def getStartDate(holiday, rightNow=None):
if not rightNow:
rightNow = datetime.datetime.now()
2015-06-25 03:57:02 -05:00
2015-06-25 05:04:26 -05:00
startMonth = holiday['startMonth'] if 'startMonth' in holiday else rightNow.month
2015-06-25 03:57:02 -05:00
startDay = holiday['startDay'] if 'startDay' in holiday else (rightNow.day if 'weekDay' in holiday else calendar.monthrange(rightNow.year, startMonth)[0])
2015-06-25 05:04:26 -05:00
startDate = datetime.datetime(rightNow.year, startMonth, startDay, tzinfo=TIME_ZONE)
2015-07-05 18:59:25 -05:00
2015-06-25 03:57:02 -05:00
return startDate
2015-06-25 05:04:26 -05:00
def getEndDate(holiday, rightNow=None):
if not rightNow:
rightNow = datetime.datetime.now()
2015-06-25 03:57:02 -05:00
2015-06-25 05:04:26 -05:00
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])
2015-06-25 05:04:26 -05:00
endYear = rightNow.year
2015-06-25 03:57:02 -05:00
if 'startMonth' in holiday and holiday['startMonth'] > endMonth:
endYear += 1
2015-06-25 05:04:26 -05:00
endDate = datetime.datetime(endYear, endMonth, endDay, tzinfo=TIME_ZONE)
2015-07-05 18:59:25 -05:00
return endDate