From 3c853dbc004b2678856ac6562da2110d1765ee65 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 21 Jun 2015 11:29:47 +0300 Subject: [PATCH] Some AI cleanup --- toontown/ai/CogSuitManagerAI.py | 22 +++++++++----------- toontown/ai/DistributedBlackCatMgr.py | 16 ++++++++------ toontown/ai/DistributedBlackCatMgrAI.py | 2 +- toontown/ai/ReportGlobals.py | 2 +- toontown/ai/ToontownAIRepository.py | 2 +- toontown/coghq/DistributedBattleFactoryAI.py | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/toontown/ai/CogSuitManagerAI.py b/toontown/ai/CogSuitManagerAI.py index db801e03..6a7f806c 100755 --- a/toontown/ai/CogSuitManagerAI.py +++ b/toontown/ai/CogSuitManagerAI.py @@ -1,26 +1,24 @@ from toontown.coghq import CogDisguiseGlobals - -suitTrackIndex = { -'s' : 3, -'m' : 2, -'l' : 1, -'c' : 0 -} +from toontown.suit import SuitDNA class CogSuitManagerAI: - def __init__(self, air): - self.air = air - def recoverPart(self, toon, factoryType, suitTrack, zoneId, toons): + def recoverPart(self, toon, factoryType, suitTrack): + if suitTrack not in SuitDNA.suitDepts: + return + recoveredParts = [0, 0, 0, 0] parts = toon.getCogParts() - suitTrack = suitTrackIndex[suitTrack] + suitTrack = SuitDNA.suitDepts.index(suitTrack) + if CogDisguiseGlobals.isSuitComplete(parts, suitTrack): return recoveredParts + recoveredParts[suitTrack] = toon.giveGenericCogPart(factoryType, suitTrack) return recoveredParts def removeParts(self, toon, suitDept): parts = toon.getCogParts() + if CogDisguiseGlobals.isSuitComplete(parts, suitDept): - toon.loseCogParts(suitDept) + toon.loseCogParts(suitDept) \ No newline at end of file diff --git a/toontown/ai/DistributedBlackCatMgr.py b/toontown/ai/DistributedBlackCatMgr.py index f1f50717..c6ec9b14 100755 --- a/toontown/ai/DistributedBlackCatMgr.py +++ b/toontown/ai/DistributedBlackCatMgr.py @@ -1,20 +1,24 @@ from direct.directnotify import DirectNotifyGlobal -from direct.distributed import DistributedObject - -class DistributedBlackCatMgr(DistributedObject.DistributedObject): +from direct.distributed.DistributedObject import DistributedObject +from toontown.toonbase import ToontownGlobals + +class DistributedBlackCatMgr(DistributedObject): neverDisable = 1 notify = DirectNotifyGlobal.directNotify.newCategory('DistributedBlackCatMgr') def announceGenerate(self): - DistributedObject.DistributedObject.announceGenerate(self) + DistributedObject.announceGenerate(self) base.cr.blackCatMgr = self def delete(self): base.cr.blackCatMgr = None - DistributedObject.DistributedObject.delete(self) + DistributedObject.delete(self) def requestBlackCatTransformation(self): + if not base.cr.newsManager.isHolidayRunning(ToontownGlobals.BLACK_CAT_DAY): + return + self.sendUpdate('requestBlackCatTransformation') def doBlackCatTransformation(self): - getDustCloudIval(base.localAvatar, color=base.localAvatar.style.getBlackColor()).start() \ No newline at end of file + base.localAvatar.getDustCloud(0.0, color=base.localAvatar.style.getBlackColor()).start() \ No newline at end of file diff --git a/toontown/ai/DistributedBlackCatMgrAI.py b/toontown/ai/DistributedBlackCatMgrAI.py index 5227e89f..0a28ef90 100755 --- a/toontown/ai/DistributedBlackCatMgrAI.py +++ b/toontown/ai/DistributedBlackCatMgrAI.py @@ -20,4 +20,4 @@ class DistributedBlackCatMgrAI(DistributedObjectAI): 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', []) \ No newline at end of file diff --git a/toontown/ai/ReportGlobals.py b/toontown/ai/ReportGlobals.py index 67e5f668..8f95c6f5 100755 --- a/toontown/ai/ReportGlobals.py +++ b/toontown/ai/ReportGlobals.py @@ -7,4 +7,4 @@ def isValidCategoryName(value): return value in categories def getCategory(value): - return categories[value] + return categories[value] \ No newline at end of file diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index f280b8e8..1ca52f57 100755 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -116,7 +116,7 @@ class ToontownAIRepository(ToontownInternalRepository): self.reportMgr.generateWithRequired(2) self.trophyMgr = DistributedTrophyMgrAI(self) self.trophyMgr.generateWithRequired(2) - self.cogSuitMgr = CogSuitManagerAI.CogSuitManagerAI(self) + self.cogSuitMgr = CogSuitManagerAI.CogSuitManagerAI() self.promotionMgr = PromotionManagerAI.PromotionManagerAI(self) self.cogPageManager = CogPageManagerAI.CogPageManagerAI() self.holidayManager = HolidayManagerAI(self) diff --git a/toontown/coghq/DistributedBattleFactoryAI.py b/toontown/coghq/DistributedBattleFactoryAI.py index 75a865f0..c8ef63ed 100755 --- a/toontown/coghq/DistributedBattleFactoryAI.py +++ b/toontown/coghq/DistributedBattleFactoryAI.py @@ -34,7 +34,7 @@ class DistributedBattleFactoryAI(DistributedLevelBattleAI.DistributedLevelBattle else: self.notify.debug('toon %d not helpful, skipping merits' % toon.doId) if self.bossBattle: - self.toonParts[toon.doId] = self.air.cogSuitMgr.recoverPart(toon, self.level.factoryType, self.suitTrack, self.getTaskZoneId(), toons) + self.toonParts[toon.doId] = self.air.cogSuitMgr.recoverPart(toon, self.level.factoryType, self.suitTrack) self.notify.debug('toonParts = %s' % self.toonParts)