racing: more progress on leaderboards
This commit is contained in:
parent
6d46f8cd32
commit
1f84f3a96c
2 changed files with 34 additions and 1 deletions
|
@ -25,6 +25,7 @@ from toontown.hood.TTHoodDataAI import TTHoodDataAI
|
|||
from toontown.pets.PetManagerAI import PetManagerAI
|
||||
from toontown.quest.QuestManagerAI import QuestManagerAI
|
||||
from toontown.racing.DistributedLeaderBoardAI import DistributedLeaderBoardAI
|
||||
from toontown.racing.RaceManagerAI import RaceManagerAI
|
||||
from toontown.shtiker.CogPageManagerAI import CogPageManagerAI
|
||||
from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI
|
||||
from toontown.toon import NPCToons
|
||||
|
@ -50,6 +51,7 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
self.questManager = None
|
||||
self.promotionMgr = None
|
||||
self.cogPageManager = None
|
||||
self.raceMgr = None
|
||||
self.timeManager = None
|
||||
self.newsManager = None
|
||||
self.welcomeValleyManager = None
|
||||
|
@ -114,6 +116,9 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
# Create our Cog page manager...
|
||||
self.cogPageManager = CogPageManagerAI(self)
|
||||
|
||||
# Create our race manager...
|
||||
self.raceMgr = RaceManagerAI(self)
|
||||
|
||||
def createGlobals(self):
|
||||
"""
|
||||
Creates "global" (distributed) objects.
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import cPickle
|
||||
|
||||
from direct.directnotify import DirectNotifyGlobal
|
||||
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
||||
|
||||
from toontown.toonbase import TTLocalizer
|
||||
|
||||
|
||||
class DistributedLeaderBoardAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLeaderBoardAI')
|
||||
|
@ -9,6 +13,14 @@ class DistributedLeaderBoardAI(DistributedObjectAI):
|
|||
DistributedObjectAI.__init__(self, air)
|
||||
self.name = name
|
||||
self.posHpr = (x, y, z, h, p, r)
|
||||
self.records = {}
|
||||
self.subscriptions = []
|
||||
self.currentIndex = -1
|
||||
|
||||
def announceGenerate(self):
|
||||
DistributedObjectAI.announceGenerate(self)
|
||||
self.accept('UpdateRaceRecord', self.handleUpdateRaceRecord)
|
||||
self.accept('GS_LeaderBoardSwap' + str(self.zoneId), self.updateDisplay)
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
@ -17,4 +29,20 @@ class DistributedLeaderBoardAI(DistributedObjectAI):
|
|||
return self.posHpr
|
||||
|
||||
def subscribeTo(self, subscription):
|
||||
pass # TODO
|
||||
self.records.setdefault(subscription[0], {})[subscription[1]] = [(x[0], x[3]) for x in
|
||||
self.air.raceMgr.getRecords(subscription[0],
|
||||
subscription[1])]
|
||||
self.subscriptions.append(subscription)
|
||||
|
||||
def handleUpdateRaceRecord(self, record):
|
||||
self.notify.info('handleUpdateRaceRecord TODO')
|
||||
|
||||
def updateDisplay(self):
|
||||
self.currentIndex += 1
|
||||
if self.currentIndex >= len(self.subscriptions):
|
||||
self.currentIndex = 0
|
||||
|
||||
trackName = TTLocalizer.KartRace_TrackNames[self.subscriptions[self.currentIndex][0]]
|
||||
periodName = TTLocalizer.RecordPeriodStrings[self.subscriptions[self.currentIndex][1]]
|
||||
leaderList = self.records[self.subscriptions[self.currentIndex][0]][self.subscriptions[self.currentIndex][1]]
|
||||
self.sendUpdate('setDisplay', [cPickle.dumps((trackName, periodName, leaderList))])
|
||||
|
|
Loading…
Reference in a new issue