2015-05-11 16:21:07 +00:00
|
|
|
from toontown.chat.ChatGlobals import CFSpeech, CFTimeout
|
|
|
|
from toontown.toonbase import TTLocalizer, ToontownGlobals
|
|
|
|
from toontown.toontowngui import TTDialog
|
|
|
|
from DistributedNPCToonBase import DistributedNPCToonBase
|
|
|
|
import LaffRestockGlobals
|
|
|
|
|
|
|
|
class DistributedNPCLaffRestock(DistributedNPCToonBase):
|
|
|
|
|
|
|
|
def __init__(self, cr):
|
|
|
|
DistributedNPCToonBase.__init__(self, cr)
|
|
|
|
|
|
|
|
def disable(self):
|
|
|
|
self.ignoreAll()
|
|
|
|
self.destroyDialog()
|
|
|
|
DistributedNPCToonBase.disable(self)
|
|
|
|
|
|
|
|
def destroyDialog(self):
|
|
|
|
if hasattr(self, 'dialog'):
|
|
|
|
self.dialog.cleanup()
|
|
|
|
del self.dialog
|
2015-05-11 17:06:27 +00:00
|
|
|
|
2015-05-11 16:21:07 +00:00
|
|
|
def getCollSphereRadius(self):
|
|
|
|
return 1.0
|
|
|
|
|
|
|
|
def handleCollisionSphereEnter(self, collEntry):
|
|
|
|
laff = base.localAvatar.getMaxHp() - base.localAvatar.getHp()
|
|
|
|
|
|
|
|
if laff <= 0:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockFullLaffMessage, CFSpeech|CFTimeout)
|
|
|
|
return
|
|
|
|
|
|
|
|
cost = laff * ToontownGlobals.CostPerLaffRestock
|
|
|
|
|
|
|
|
if cost > base.localAvatar.getTotalMoney():
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockNoMoneyMessage % cost, CFSpeech|CFTimeout)
|
|
|
|
return
|
|
|
|
|
|
|
|
base.cr.playGame.getPlace().setState('stopped')
|
|
|
|
base.setCellsActive(base.bottomCells, 0)
|
|
|
|
|
|
|
|
self.dialog = TTDialog.TTDialog(style=TTDialog.YesNo, text=TTLocalizer.RestockAskMessage % (laff, cost), command=self.confirmRestock)
|
|
|
|
self.dialog.show()
|
|
|
|
|
|
|
|
def confirmRestock(self, value):
|
|
|
|
base.cr.playGame.getPlace().setState('walk')
|
|
|
|
base.setCellsActive(base.bottomCells, 1)
|
|
|
|
|
|
|
|
if value > 0:
|
|
|
|
self.sendUpdate('restock')
|
|
|
|
else:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockLaffCancelMessage, CFSpeech|CFTimeout)
|
|
|
|
|
|
|
|
self.destroyDialog()
|
|
|
|
|
|
|
|
def restockResult(self, state, cost):
|
|
|
|
if state == LaffRestockGlobals.NO_LAFF:
|
|
|
|
message = TTLocalizer.RestockFullLaffMessage
|
|
|
|
elif state == LaffRestockGlobals.NO_MONEY:
|
|
|
|
message = TTLocalizer.RestockNoMoneyMessage % cost
|
|
|
|
else:
|
|
|
|
message = TTLocalizer.RestockLaffMessage
|
|
|
|
|
|
|
|
self.setChatAbsolute(message, CFSpeech|CFTimeout)
|