toontown/ai cleanup

This commit is contained in:
John Cote 2015-04-29 00:01:52 -04:00
parent a71ed6fc7b
commit 59a6e2ece1
27 changed files with 66 additions and 77 deletions

View file

@ -65,4 +65,4 @@ class AchievementsManagerAI():
def toonGotQuest(self, avId):
av = self.air.doId2do.get(avId)
if not av:
return
return

View file

@ -53,4 +53,4 @@ class CogPageManagerAI:
newCogRadar[dept] = cogRadar
newBuildingRadar[dept] = buildingRadar
toon.b_setCogRadar(newCogRadar)
toon.b_setBuildingRadar(newBuildingRadar)
toon.b_setBuildingRadar(newBuildingRadar)

View file

@ -14,11 +14,11 @@ class DistributedAprilToonsMgr(DistributedObject):
def announceGenerate(self):
DistributedObject.announceGenerate(self)
self.d_requestEventsList()
def d_requestEventsList(self):
self.notify.debug("Requesting events list from AI.")
self.sendUpdate('requestEventsList', [])
def requestEventsListResp(self, eventIds):
self.events = eventIds
self.checkActiveEvents()

View file

@ -9,15 +9,15 @@ def getDustCloudIval(toon):
dustCloud.setZ(3)
dustCloud.setScale(0.4)
dustCloud.createTrack()
if hasattr(toon, 'laffMeter'):
toon.laffMeter.color = toon.style.getBlackColor()
sequence = Sequence(Wait(0.5), Func(dustCloud.reparentTo, toon), dustCloud.track, Func(dustCloud.destroy))
if hasattr(toon, 'laffMeter'):
sequence.append(Func(toon.laffMeter.adjustFace, toon.hp, toon.maxHp))
return sequence
class DistributedBlackCatMgr(DistributedObject.DistributedObject):
@ -36,5 +36,4 @@ class DistributedBlackCatMgr(DistributedObject.DistributedObject):
self.sendUpdate('requestBlackCatTransformation')
def doBlackCatTransformation(self):
print 'doit'
getDustCloudIval(base.localAvatar).start()
getDustCloudIval(base.localAvatar).start()

View file

@ -9,15 +9,15 @@ class DistributedBlackCatMgrAI(DistributedObjectAI):
def requestBlackCatTransformation(self):
if not self.air.holidayManager.isHolidayRunning(ToontownGlobals.BLACK_CAT_DAY):
return
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av or av.dna.getAnimal() != 'cat' or av.dna.headColor == 0x1a:
return
newDNA = ToonDNA()
newDNA.makeFromNetString(av.getDNAString())
newDNA.updateToonProperties(armColor=26, legColor=26, headColor=26)
taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
self.sendUpdateToAvatarId(avId, 'doBlackCatTransformation', [])
self.sendUpdateToAvatarId(avId, 'doBlackCatTransformation', [])

View file

@ -9,12 +9,12 @@ class DistributedGreenToonEffectMgr(DistributedObject.DistributedObject):
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:

View file

@ -5,12 +5,12 @@ 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()
@ -18,5 +18,3 @@ class DistributedGreenToonEffectMgrAI(DistributedObjectAI, FSM):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
av.b_setCheesyEffect(15, 0, 0)
pass

View file

@ -16,31 +16,31 @@ def getDustCloudIval(toon):
if getattr(toon, 'laffMeter', None):
seq.append(Func(toon.laffMeter.adjustFace, toon.hp, toon.maxHp))
return seq
class DistributedPolarBearMgr(DistributedObject.DistributedObject):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedPolarBearMgr')
ActivateEvent = 'DistributedPolarBearMgr-activate'
def __init__(self, cr):
DistributedObject.DistributedObject.__init__(self, cr)
def announceGenerate(self):
DistributedPolarBearMgr.notify.debug('announceGenerate')
DistributedObject.DistributedObject.announceGenerate(self)
self.acceptOnce(DistributedPolarBearMgr.ActivateEvent, self.d_requestPolarBearTransformation)
self.dustCloudIval = None
return
def delete(self):
if self.dustCloudIval:
self.dustCloudIval.finish()
del self.dustCloudIval
self.ignore(DistributedPolarBearMgr.ActivateEvent)
DistributedObject.DistributedObject.delete(self)
def d_requestPolarBearTransformation(self):
self.sendUpdate('requestPolarBearTransformation', [])
def doPolarBearTransformation(self, avId):
DistributedPolarBearMgr.notify.debug('doPolarBearTransformation')
toon = self.cr.doId2do.get(avId)

View file

@ -4,12 +4,12 @@ from toontown.toon.ToonDNA import ToonDNA
class DistributedPolarBearMgrAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPolarBearMgrAI")
def requestPolarBearTransformation(self):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av: return
if av.dna.getAnimal() == 'bear' and av.dna.headColor != 0x00:
newDNA = ToonDNA()
newDNA.makeFromNetString(av.getDNAString())
@ -17,5 +17,5 @@ class DistributedPolarBearMgrAI(DistributedObjectAI):
newDNA.armColor = 0x00
newDNA.legColor = 0x00
taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' %avId)
self.sendUpdate('doPolarBearTransformation', [avId])

View file

@ -14,7 +14,7 @@ class DistributedPolarPlaceEffectMgr(DistributedObject.DistributedObject):
DistributedObject.DistributedObject.announceGenerate(self)
DistributedPolarPlaceEffectMgr.notify.debug('announceGenerate')
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.phraseSaid)
def phraseSaid(self, phraseId):
helpPhrase = 104
if phraseId == helpPhrase:

View file

@ -6,12 +6,12 @@ import time
class DistributedPolarPlaceEffectMgrAI(DistributedObjectAI, FSM):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedPolarPlaceEffectMgrAI")
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
FSM.__init__(self, 'ResistanceFSM')
self.air = air
def enterOff(self):
self.requestDelete()
@ -21,4 +21,3 @@ class DistributedPolarPlaceEffectMgrAI(DistributedObjectAI, FSM):
if not av: return
expireTime = int((time.time()/60) + 0.5) + 60
av.b_setCheesyEffect(13, 3000, expireTime)

View file

@ -12,6 +12,6 @@ class DistributedReportMgr(DistributedObject.DistributedObject):
def delete(self):
base.cr.reportMgr = None
DistributedObject.DistributedObject.delete(self)
def sendReport(self, avId, category):
self.sendUpdate('sendReport', [avId, category])
self.sendUpdate('sendReport', [avId, category])

View file

@ -11,27 +11,27 @@ class DistributedReportMgrAI(DistributedObjectAI):
self.reports = []
self.interval = config.GetInt('report-interval', 600)
self.scheduleReport()
def scheduleReport(self):
threading.Timer(self.interval, self.sendAllReports).start()
def sendReport(self, avId, category):
if not ReportGlobals.isValidCategoryName(category) or not len(str(avId)) == 9:
return
reporter = self.air.doId2do.get(self.air.getAvatarIdFromSender())
if not reporter or reporter.isReported(avId):
return
timestamp = int(round(time.time() * 1000))
self.reports.append('%s|%s|%s|%s' % (timestamp, reporter.doId, avId, category))
def sendAllReports(self):
self.scheduleReport()
if not self.reports or config.GetString('accountdb-type', 'developer') != 'remote':
return
executeHttpRequestAndLog('report', reports=','.join(self.reports))
self.reports = []
self.reports = []

View file

@ -16,7 +16,7 @@ class DistributedResistanceEmoteMgr(DistributedObject.DistributedObject):
DistributedObject.DistributedObject.announceGenerate(self)
DistributedResistanceEmoteMgr.notify.debug('announceGenerate')
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.phraseSaid)
def phraseSaid(self, phraseId):
helpPhrase = 513
if phraseId == helpPhrase:

View file

@ -11,7 +11,7 @@ class DistributedResistanceEmoteMgrAI(DistributedObjectAI, FSM):
DistributedObjectAI.__init__(self, air)
FSM.__init__(self, 'ResistanceFSM')
self.air = air
def enterOff(self):
self.requestDelete()
@ -22,4 +22,3 @@ class DistributedResistanceEmoteMgrAI(DistributedObjectAI, FSM):
RESIST_INDEX = EmoteFuncDict['Resistance Salute']
av.emoteAccess[RESIST_INDEX] = 1
av.d_setEmoteAccess(av.emoteAccess)

View file

@ -6,4 +6,3 @@ class DistributedScavengerHuntTargetAI(DistributedObjectAI):
def attemptScavengerHunt(self):
pass

View file

@ -23,4 +23,4 @@ class DistributedSillyMeterMgr(DistributedObject.DistributedObject):
return -1
def getCurPhaseStartDate(self):
return -1
return -1

View file

@ -3,4 +3,3 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI
class DistributedSillyMeterMgrAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedSillyMeterMgrAI")

View file

@ -27,14 +27,14 @@ class DistributedTrickOrTreatTarget(DistributedObject.DistributedObject):
self.triggered = True
self.d_requestScavengerHunt()
taskMgr.doMethodLater(self.triggerDelay, reset, 'ScavengerHunt-phrase-reset', extraArgs=[])
def delete(self):
self.ignore(SpeedChatGlobals.SCStaticTextMsgEvent)
DistributedObject.DistributedObject.delete(self)
def d_requestScavengerHunt(self):
self.sendUpdate('requestScavengerHunt', [])
def doScavengerHunt(self, amount):
DistributedTrickOrTreatTarget.notify.debug('doScavengerHunt')
base.localAvatar.trickOrTreatTargetMet(amount)
base.localAvatar.trickOrTreatTargetMet(amount)

View file

@ -4,15 +4,15 @@ from direct.fsm.FSM import FSM
class DistributedTrickOrTreatTargetAI(DistributedObjectAI, FSM):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTrickOrTreatTargetAI")
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
FSM.__init__(self, 'TrickOrTreatTargeFSM')
self.air = air
def enterOff(self):
self.requestDelete()
def requestScavengerHunt(self):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
@ -28,4 +28,3 @@ class DistributedTrickOrTreatTargetAI(DistributedObjectAI, FSM):
av.addMoney(100)
if len(scavengerHunt) == 6:
av.b_setCheesyEffect(12, 0, 0)

View file

@ -29,11 +29,11 @@ class DistributedWinterCarolingTarget(DistributedObject.DistributedObject):
self.triggered = True
self.d_requestScavengerHunt()
taskMgr.doMethodLater(self.triggerDelay, reset, 'ScavengerHunt-phrase-reset', extraArgs=[])
def delete(self):
self.ignore(SpeedChatGlobals.SCStaticTextMsgEvent)
DistributedObject.DistributedObject.delete(self)
def d_requestScavengerHunt(self):
self.sendUpdate('requestScavengerHunt', [])

View file

@ -9,10 +9,10 @@ class DistributedWinterCarolingTargetAI(DistributedObjectAI, FSM):
DistributedObjectAI.__init__(self, air)
FSM.__init__(self, 'WinterCarolingFSM')
self.air = air
def enterOff(self):
self.requestDelete()
def requestScavengerHunt(self):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
@ -27,4 +27,3 @@ class DistributedWinterCarolingTargetAI(DistributedObjectAI, FSM):
av.b_setScavengerHunt(scavengerHunt)
if len(scavengerHunt) == 6:
av.b_setCheesyEffect(14, 0, 0)

View file

@ -11,22 +11,22 @@ class HolidayManagerAI:
def setup(self):
holidays = config.GetString('active-holidays','')
if holidays != '':
for holiday in holidays.split(","):
holiday = int(holiday)
self.currentHolidays.append(holiday)
date = datetime.now()
if date.month == 10 and date.day == 31:
# Halloween: Black Cat Day
self.currentHolidays.append(ToontownGlobals.BLACK_CAT_DAY)
if date.weekday() == 6:
# Saturday: Fish Bingo
self.currentHolidays.append(ToontownGlobals.SILLY_SATURDAY_BINGO)
simbase.air.newsManager.setHolidayIdList([self.currentHolidays])
def isHolidayRunning(self, holidayId):

View file

@ -731,17 +731,17 @@ def getHoliday(id):
return getattr(ToontownGlobals, id)
return -1
@magicWord(category=CATEGORY_PROGRAMMER, types=[str])
def startHoliday(id):
"""
Start a holiday.
"""
holiday = getHoliday(id.upper())
if holiday < 0:
return "Couldn't find holiday " + id + '!'
if base.cr.newsManager.startHoliday(holiday):
return 'Successfully started holiday ' + id + '!'
else:
@ -753,11 +753,11 @@ def endHoliday(id):
End a holiday.
"""
holiday = getHoliday(id.upper())
if holiday < 0:
return "Couldn't find holiday " + id + '!'
if base.cr.newsManager.endHoliday(holiday):
return 'Successfully stopped holiday ' + id + '!'
else:
return id + ' is not running!'
return id + ' is not running!'

View file

@ -85,4 +85,3 @@ class NewsManagerAI(DistributedObjectAI):
def sendSystemMessage(self, todo0, todo1):
pass

View file

@ -7,4 +7,4 @@ def isValidCategoryName(value):
return value in categories
def getCategory(value):
return categories[value]
return categories[value]

View file

@ -9,10 +9,9 @@ class WelcomeValleyManagerAI(DistributedObjectAI):
def toonSetZone(self, doId, newZoneId):
pass #TODO
def requestZoneIdMessage(self, todo0, todo1):
pass
def requestZoneIdResponse(self, todo0, todo1):
pass