mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 19:52:37 -06:00
29 lines
No EOL
973 B
Python
29 lines
No EOL
973 B
Python
from toontown.toonbase import ToontownGlobals
|
|
import LaffRestockGlobals, DistributedNPCToonBaseAI
|
|
|
|
class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI):
|
|
|
|
def restock(self, laff):
|
|
av = simbase.air.doId2do.get(self.air.getAvatarIdFromSender())
|
|
|
|
if not av:
|
|
return
|
|
|
|
newLaff = av.getHp() + laff
|
|
|
|
if newLaff > av.getMaxHp():
|
|
self.sendUpdate('restockResult', [LaffRestockGlobals.FULL_LAFF])
|
|
return
|
|
elif laff <= 0 or newLaff <= av.getHp():
|
|
self.sendUpdate('restockResult', [LaffRestockGlobals.LESS_LAFF])
|
|
return
|
|
|
|
cost = laff * ToontownGlobals.CostPerLaffRestock
|
|
|
|
if cost > av.getTotalMoney():
|
|
self.sendUpdate('restockResult', [LaffRestockGlobals.NOT_ENOUGH_MONEY])
|
|
return
|
|
|
|
av.takeMoney(cost)
|
|
av.toonUp(laff)
|
|
self.sendUpdate('restockResult', [LaffRestockGlobals.RESTOCK_SUCCESSFUL]) |