Some AI cleanup

This commit is contained in:
John 2015-06-21 11:29:47 +03:00
parent ad7c327752
commit 3c853dbc00
6 changed files with 24 additions and 22 deletions

View file

@ -1,26 +1,24 @@
from toontown.coghq import CogDisguiseGlobals from toontown.coghq import CogDisguiseGlobals
from toontown.suit import SuitDNA
suitTrackIndex = {
's' : 3,
'm' : 2,
'l' : 1,
'c' : 0
}
class CogSuitManagerAI: 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] recoveredParts = [0, 0, 0, 0]
parts = toon.getCogParts() parts = toon.getCogParts()
suitTrack = suitTrackIndex[suitTrack] suitTrack = SuitDNA.suitDepts.index(suitTrack)
if CogDisguiseGlobals.isSuitComplete(parts, suitTrack): if CogDisguiseGlobals.isSuitComplete(parts, suitTrack):
return recoveredParts return recoveredParts
recoveredParts[suitTrack] = toon.giveGenericCogPart(factoryType, suitTrack) recoveredParts[suitTrack] = toon.giveGenericCogPart(factoryType, suitTrack)
return recoveredParts return recoveredParts
def removeParts(self, toon, suitDept): def removeParts(self, toon, suitDept):
parts = toon.getCogParts() parts = toon.getCogParts()
if CogDisguiseGlobals.isSuitComplete(parts, suitDept): if CogDisguiseGlobals.isSuitComplete(parts, suitDept):
toon.loseCogParts(suitDept) toon.loseCogParts(suitDept)

View file

@ -1,20 +1,24 @@
from direct.directnotify import DirectNotifyGlobal from direct.directnotify import DirectNotifyGlobal
from direct.distributed import DistributedObject from direct.distributed.DistributedObject import DistributedObject
from toontown.toonbase import ToontownGlobals
class DistributedBlackCatMgr(DistributedObject.DistributedObject): class DistributedBlackCatMgr(DistributedObject):
neverDisable = 1 neverDisable = 1
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedBlackCatMgr') notify = DirectNotifyGlobal.directNotify.newCategory('DistributedBlackCatMgr')
def announceGenerate(self): def announceGenerate(self):
DistributedObject.DistributedObject.announceGenerate(self) DistributedObject.announceGenerate(self)
base.cr.blackCatMgr = self base.cr.blackCatMgr = self
def delete(self): def delete(self):
base.cr.blackCatMgr = None base.cr.blackCatMgr = None
DistributedObject.DistributedObject.delete(self) DistributedObject.delete(self)
def requestBlackCatTransformation(self): def requestBlackCatTransformation(self):
if not base.cr.newsManager.isHolidayRunning(ToontownGlobals.BLACK_CAT_DAY):
return
self.sendUpdate('requestBlackCatTransformation') self.sendUpdate('requestBlackCatTransformation')
def doBlackCatTransformation(self): def doBlackCatTransformation(self):
getDustCloudIval(base.localAvatar, color=base.localAvatar.style.getBlackColor()).start() base.localAvatar.getDustCloud(0.0, color=base.localAvatar.style.getBlackColor()).start()

View file

@ -116,7 +116,7 @@ class ToontownAIRepository(ToontownInternalRepository):
self.reportMgr.generateWithRequired(2) self.reportMgr.generateWithRequired(2)
self.trophyMgr = DistributedTrophyMgrAI(self) self.trophyMgr = DistributedTrophyMgrAI(self)
self.trophyMgr.generateWithRequired(2) self.trophyMgr.generateWithRequired(2)
self.cogSuitMgr = CogSuitManagerAI.CogSuitManagerAI(self) self.cogSuitMgr = CogSuitManagerAI.CogSuitManagerAI()
self.promotionMgr = PromotionManagerAI.PromotionManagerAI(self) self.promotionMgr = PromotionManagerAI.PromotionManagerAI(self)
self.cogPageManager = CogPageManagerAI.CogPageManagerAI() self.cogPageManager = CogPageManagerAI.CogPageManagerAI()
self.holidayManager = HolidayManagerAI(self) self.holidayManager = HolidayManagerAI(self)

View file

@ -34,7 +34,7 @@ class DistributedBattleFactoryAI(DistributedLevelBattleAI.DistributedLevelBattle
else: else:
self.notify.debug('toon %d not helpful, skipping merits' % toon.doId) self.notify.debug('toon %d not helpful, skipping merits' % toon.doId)
if self.bossBattle: 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) self.notify.debug('toonParts = %s' % self.toonParts)