Poodletooth-iLand/toontown/toon/DistributedNPCGloveAI.py

28 lines
981 B
Python
Raw Normal View History

from DistributedNPCToonBaseAI import DistributedNPCToonBaseAI
from ToonDNA import ToonDNA
from toontown.toonbase import ToontownGlobals
class DistributedNPCGloveAI(DistributedNPCToonBaseAI):
def requestTransformation(self, color):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
2015-05-11 14:05:59 -05:00
if av is None or not hasattr(av, 'dna'):
return
2015-05-11 14:05:59 -05:00
if av.dna.gloveColor == color:
self.sendUpdate('doTransformation', [avId, 1])
return
2015-05-11 14:05:59 -05:00
if av.getTotalMoney() < ToontownGlobals.GloveCost:
self.sendUpdate('doTransformation', [avId, 2])
return
av.takeMoney(ToontownGlobals.GloveCost)
newDNA = ToonDNA()
newDNA.makeFromNetString(av.getDNAString())
newDNA.gloveColor = color
taskMgr.doMethodLater(1.0, lambda task: av.b_setDNAString(newDNA.makeNetString()), 'transform-%d' % avId)
2015-05-11 14:05:59 -05:00
self.sendUpdate('doTransformation', [avId, 3])