2015-05-12 05:06:23 +00:00
|
|
|
from pandac.PandaModules import *
|
|
|
|
from direct.distributed import ClockDelta
|
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
|
2015-05-11 20:36:31 +00:00
|
|
|
from toontown.toon import NPCToons
|
2015-05-11 16:21:07 +00:00
|
|
|
from DistributedNPCToonBase import DistributedNPCToonBase
|
|
|
|
import LaffRestockGlobals
|
2015-05-12 05:06:23 +00:00
|
|
|
from LaffShopGui import *
|
2015-05-11 16:21:07 +00:00
|
|
|
|
|
|
|
class DistributedNPCLaffRestock(DistributedNPCToonBase):
|
|
|
|
|
2015-05-27 07:08:39 +00:00
|
|
|
zone2id = {
|
|
|
|
10000: 0,
|
|
|
|
13000: 1,
|
|
|
|
12000: 2,
|
|
|
|
11000: 3,
|
|
|
|
}
|
|
|
|
|
2015-05-11 16:21:07 +00:00
|
|
|
def __init__(self, cr):
|
|
|
|
DistributedNPCToonBase.__init__(self, cr)
|
2015-05-12 05:06:23 +00:00
|
|
|
self.isLocalToon = 0
|
|
|
|
self.av = None
|
|
|
|
self.laffGui = None
|
2015-05-11 16:21:07 +00:00
|
|
|
|
|
|
|
def disable(self):
|
|
|
|
self.ignoreAll()
|
2015-05-12 05:06:23 +00:00
|
|
|
if self.laffGui:
|
|
|
|
self.laffGui.destroy()
|
|
|
|
self.laffGui = None
|
|
|
|
self.av = None
|
2015-05-11 16:21:07 +00:00
|
|
|
DistributedNPCToonBase.disable(self)
|
|
|
|
|
2015-05-11 20:36:31 +00:00
|
|
|
def initToonState(self):
|
|
|
|
self.setAnimState('neutral', 0.9, None, None)
|
|
|
|
if self.name in NPCToons.LaffRestockPositions:
|
|
|
|
pos = NPCToons.LaffRestockPositions[self.name]
|
|
|
|
self.setPos(*pos[0])
|
|
|
|
self.setH(pos[1])
|
2015-05-27 07:08:39 +00:00
|
|
|
self.putOnSuit(self.zone2id.get(self.zoneId, -1), rental=True)
|
2015-05-11 19:05:59 +00:00
|
|
|
|
2015-05-11 16:21:07 +00:00
|
|
|
def getCollSphereRadius(self):
|
2015-05-27 07:08:39 +00:00
|
|
|
return 3.0
|
2015-05-11 16:21:07 +00:00
|
|
|
|
|
|
|
def handleCollisionSphereEnter(self, collEntry):
|
2015-05-12 05:06:23 +00:00
|
|
|
base.cr.playGame.getPlace().fsm.request('purchase')
|
|
|
|
self.sendUpdate('avatarEnter', [])
|
2015-05-11 16:21:07 +00:00
|
|
|
|
2015-05-12 05:06:23 +00:00
|
|
|
def __handleUnexpectedExit(self):
|
|
|
|
self.notify.warning('unexpected exit')
|
|
|
|
self.av = None
|
2015-05-11 16:21:07 +00:00
|
|
|
|
2015-05-12 05:06:23 +00:00
|
|
|
def resetLaffClerk(self):
|
|
|
|
self.ignoreAll()
|
|
|
|
if self.laffGui:
|
|
|
|
self.laffGui.destroy()
|
|
|
|
self.laffGui = None
|
|
|
|
self.show()
|
|
|
|
self.startLookAround()
|
|
|
|
self.detectAvatars()
|
|
|
|
if self.isLocalToon:
|
|
|
|
self.showNametag2d()
|
|
|
|
self.freeAvatar()
|
|
|
|
return Task.done
|
|
|
|
|
|
|
|
def setMovie(self, mode, npcId, avId, extraArgs, timestamp):
|
|
|
|
timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
|
|
|
|
self.remain = NPCToons.CLERK_COUNTDOWN_TIME - timeStamp
|
|
|
|
self.npcId = npcId
|
|
|
|
self.isLocalToon = avId == base.localAvatar.doId
|
|
|
|
if mode == NPCToons.SELL_MOVIE_CLEAR:
|
2015-05-11 16:21:07 +00:00
|
|
|
return
|
2015-05-12 05:06:23 +00:00
|
|
|
if mode == NPCToons.SELL_MOVIE_TIMEOUT:
|
|
|
|
if self.isLocalToon:
|
|
|
|
if self.laffGui:
|
|
|
|
self.laffGui.destroy()
|
|
|
|
self.laffGui = None
|
|
|
|
self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech | CFTimeout)
|
|
|
|
self.resetLaffClerk()
|
|
|
|
elif mode == NPCToons.SELL_MOVIE_START:
|
|
|
|
self.av = base.cr.doId2do.get(avId)
|
|
|
|
if self.av is None:
|
|
|
|
self.notify.warning('Avatar %d not found in doId' % avId)
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.accept(self.av.uniqueName('disable'), self.__handleUnexpectedExit)
|
|
|
|
self.setupAvatars(self.av)
|
|
|
|
if self.isLocalToon:
|
|
|
|
self.hideNametag2d()
|
|
|
|
laff = self.av.getMaxHp() - self.av.getHp()
|
|
|
|
cost = laff * ToontownGlobals.CostPerLaffRestock
|
|
|
|
self.popupLaffGUI(laff, cost)
|
|
|
|
elif mode == NPCToons.SELL_MOVIE_COMPLETE:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockLaffMessage, CFSpeech | CFTimeout)
|
|
|
|
self.resetLaffClerk()
|
|
|
|
elif mode == LaffRestockGlobals.FullLaff:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockFullLaffMessage, CFSpeech | CFTimeout)
|
|
|
|
self.resetLaffClerk()
|
|
|
|
elif mode == LaffRestockGlobals.NoMoney:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockNoMoneyMessage, CFSpeech | CFTimeout)
|
|
|
|
self.resetLaffClerk()
|
2015-05-21 23:45:40 +00:00
|
|
|
elif mode == NPCToons.SELL_MOVIE_CHEATER:
|
|
|
|
self.setChatAbsolute(TTLocalizer.RestockCheaterMessage, CFSpeech | CFTimeout)
|
|
|
|
self.resetLaffClerk()
|
2015-05-12 05:06:23 +00:00
|
|
|
|
2015-05-12 08:10:49 +00:00
|
|
|
def __handleRestock(self, laff, cost):
|
|
|
|
self.sendUpdate('restock', [self.av.doId, laff, cost])
|
2015-05-12 05:06:23 +00:00
|
|
|
|
|
|
|
def __handleGuiDone(self, bTimedOut=False):
|
|
|
|
self.ignoreAll()
|
|
|
|
if self.laffGui:
|
|
|
|
self.laffGui.destroy()
|
|
|
|
self.laffGui = None
|
|
|
|
if not bTimedOut:
|
|
|
|
self.sendUpdate('transactionDone')
|
|
|
|
|
|
|
|
def popupLaffGUI(self, laff, cost):
|
|
|
|
self.setChatAbsolute('', CFSpeech)
|
|
|
|
self.accept('restockLaff', self.__handleRestock)
|
|
|
|
self.acceptOnce('guiDone', self.__handleGuiDone)
|
2015-05-12 08:10:49 +00:00
|
|
|
self.laffGui = LaffShopGui(text=TTLocalizer.RestockAskMessage % (laff, cost))
|