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
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)

View file

@ -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()
base.localAvatar.getDustCloud(0.0, color=base.localAvatar.style.getBlackColor()).start()

View file

@ -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', [])

View file

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

View file

@ -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)

View file

@ -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)