Poodletooth-iLand/toontown/toon/DistributedNPCLaffRestockAI.py

28 lines
881 B
Python
Raw Normal View History

from toontown.toonbase import ToontownGlobals
import LaffRestockGlobals, DistributedNPCToonBaseAI
class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI):
def restock(self):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
2015-05-11 19:05:59 +00:00
if not av:
return
2015-05-11 19:05:59 +00:00
laff = av.getMaxHp() - av.getHp()
2015-05-11 19:05:59 +00:00
if laff <= 0:
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_LAFF, 0])
return
2015-05-11 19:05:59 +00:00
cost = laff * ToontownGlobals.CostPerLaffRestock
2015-05-11 19:05:59 +00:00
if cost > av.getTotalMoney():
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_MONEY, cost])
return
2015-05-11 19:05:59 +00:00
av.takeMoney(cost)
av.b_setHp(av.getMaxHp())
2015-05-11 19:05:59 +00:00
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.SUCCESS, 0])