Poodletooth-iLand/toontown/toon/DistributedNPCGloveAI.py
Master Jumblespeed d882959bfa switch to remote
2015-05-18 22:11:33 -04:00

27 lines
981 B
Python
Executable file

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)
if av is None or not hasattr(av, 'dna'):
return
if av.dna.gloveColor == color:
self.sendUpdate('doTransformation', [avId, 1])
return
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)
self.sendUpdate('doTransformation', [avId, 3])