2015-05-11 11:21:07 -05:00
|
|
|
from toontown.toonbase import ToontownGlobals
|
2015-07-25 01:08:54 -05:00
|
|
|
import LaffRestockGlobals, DistributedNPCToonBaseAI
|
2015-05-11 11:21:07 -05:00
|
|
|
|
2015-07-25 01:08:54 -05:00
|
|
|
class DistributedNPCLaffRestockAI(DistributedNPCToonBaseAI.DistributedNPCToonBaseAI):
|
2015-05-11 11:21:07 -05:00
|
|
|
|
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])
|
2015-05-11 11:21:07 -05:00
|
|
|
return
|
2015-07-25 01:08:54 -05:00
|
|
|
elif laff <= 0 or newLaff <= av.getHp():
|
|
|
|
self.sendUpdate('restockResult', [LaffRestockGlobals.LESS_LAFF])
|
2015-05-12 00:06:23 -05:00
|
|
|
return
|
2015-07-25 01:08:54 -05:00
|
|
|
|
2015-05-11 11:21:07 -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])
|
2015-05-11 11:21:07 -05:00
|
|
|
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])
|