mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-26 05:02:31 -06:00
27 lines
881 B
Python
27 lines
881 B
Python
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)
|
|
|
|
if not av:
|
|
return
|
|
|
|
laff = av.getMaxHp() - av.getHp()
|
|
|
|
if laff <= 0:
|
|
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_LAFF, 0])
|
|
return
|
|
|
|
cost = laff * ToontownGlobals.CostPerLaffRestock
|
|
|
|
if cost > av.getTotalMoney():
|
|
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.NO_MONEY, cost])
|
|
return
|
|
|
|
av.takeMoney(cost)
|
|
av.b_setHp(av.getMaxHp())
|
|
self.sendUpdateToAvatarId(avId, 'restockResult', [LaffRestockGlobals.SUCCESS, 0])
|