Poodletooth-iLand/toontown/toon/DistributedNPCLaffRestockAI.py

29 lines
973 B
Python
Raw Normal View History

from toontown.toonbase import ToontownGlobals
2015-07-25 01:08:54 -05:00
import LaffRestockGlobals, DistributedNPCToonBaseAI
2015-07-25 01:08:54 -05:00
class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI):
2015-07-25 01:08:54 -05:00
def restock(self, laff):
av = simbase.air.doId2do.get(self.air.getAvatarIdFromSender())
2015-05-11 14:05:59 -05:00
2015-07-25 01:08:54 -05:00
if not av:
return
2015-05-11 14:05:59 -05:00
2015-07-25 01:08:54 -05:00
newLaff = av.getHp() + laff
2015-05-11 14:05:59 -05:00
2015-07-25 01:08:54 -05:00
if newLaff > av.getMaxHp():
self.sendUpdate('restockResult', [LaffRestockGlobals.FULL_LAFF])
return
2015-07-25 01:08:54 -05:00
elif laff <= 0 or newLaff <= av.getHp():
self.sendUpdate('restockResult', [LaffRestockGlobals.LESS_LAFF])
return
2015-07-25 01:08:54 -05:00
cost = laff * ToontownGlobals.CostPerLaffRestock
2015-05-11 14:05:59 -05:00
2015-07-25 01:08:54 -05:00
if cost > av.getTotalMoney():
self.sendUpdate('restockResult', [LaffRestockGlobals.NOT_ENOUGH_MONEY])
return
2015-05-11 14:05:59 -05:00
2015-07-25 01:08:54 -05:00
av.takeMoney(cost)
av.toonUp(laff)
self.sendUpdate('restockResult', [LaffRestockGlobals.RESTOCK_SUCCESSFUL])