Mgrs: Added Trophy manager
This commit is contained in:
parent
828ae1d54b
commit
78acde1f2b
3 changed files with 42 additions and 4 deletions
|
@ -41,6 +41,7 @@ from toontown.parties import PartyGlobals
|
|||
from DistributedAprilToonsMgrAI import DistributedAprilToonsMgrAI
|
||||
|
||||
from toontown.quest.QuestManagerAI import QuestManagerAI
|
||||
from toontown.building.DistributedTrophyMgrAI import DistributedTrophyMgrAI
|
||||
|
||||
class ToontownAIRepository(ToontownInternalRepository):
|
||||
def __init__(self, baseChannel, serverId, districtName):
|
||||
|
@ -142,6 +143,9 @@ class ToontownAIRepository(ToontownInternalRepository):
|
|||
self.estateManager = EstateManagerAI(self)
|
||||
self.estateManager.generateWithRequired(2)
|
||||
|
||||
self.trophyMgr = DistributedTrophyMgrAI(self)
|
||||
self.trophyMgr.generateWithRequired(2)
|
||||
|
||||
def startFireworks(self, task):
|
||||
allFwTypes = [PartyGlobals.FireworkShows.Summer, ToontownGlobals.JULY4_FIREWORKS]
|
||||
fwType = allFwTypes[random.randint(0, len(allFwTypes)-1)]
|
||||
|
|
|
@ -37,8 +37,6 @@ class DistributedHQInteriorAI(DistributedObjectAI.DistributedObjectAI):
|
|||
self.sendUpdate('setLeaderBoard', [cPickle.dumps(self.air.trophyMgr.getLeaderInfo(), 1)])
|
||||
|
||||
def getLeaderBoard(self):
|
||||
return cPickle.dumps(([], [], []), 1)
|
||||
#TODO: trophyMgr
|
||||
return cPickle.dumps(self.air.trophyMgr.getLeaderInfo(), 1)
|
||||
|
||||
def getTutorial(self):
|
||||
|
|
|
@ -4,6 +4,42 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|||
class DistributedTrophyMgrAI(DistributedObjectAI):
|
||||
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedTrophyMgrAI")
|
||||
|
||||
def requestTrophyScore(self):
|
||||
pass
|
||||
def __init__(self, air):
|
||||
DistributedObjectAI.__init__(self, air)
|
||||
self.scores = {}
|
||||
|
||||
def requestTrophyScore(self):
|
||||
avId = self.air.getAvatarIdFromSender()
|
||||
if avId in self.scores:
|
||||
self.air.sendUpdateToAvatarId(avId, 'setTrophyScore', [self.scores[avId][1]])
|
||||
|
||||
def removeTrophy(self, avId, numFloors):
|
||||
if not avId in self.scores:
|
||||
self.notify.warn("avId %d is not in scores"%avId)
|
||||
return
|
||||
self.scores[avId][1] -= numFloors
|
||||
if self.scores[avId][1] < 0:
|
||||
self.notify.warn("avId %d has a negative scorevalue?~?~?!"%avId)
|
||||
self.scores[avId][1] = 0
|
||||
self.air.sendUpdateToAvatarId(avId, 'setTrophyScore', [self.scores[avId][1]])
|
||||
|
||||
def addTrophy(self, avId, name, numFloors):
|
||||
if not avId in self.scores:
|
||||
if not self.air.doId2do.has_key(avId):
|
||||
return
|
||||
self.scores[avId] = ['', 0]
|
||||
self.scores[avId][1] = 0
|
||||
av = self.air.doId2do[avId]
|
||||
self.scores[avId][0] = av.getName()
|
||||
self.scores[avId][1] += numFloors
|
||||
self.air.sendUpdateToAvatarId(avId, 'setTrophyScore', [self.scores[avId][1]])
|
||||
|
||||
def getLeaderInfo(self):
|
||||
avIds = []
|
||||
names = []
|
||||
scores = []
|
||||
for avId, data in self.scores.items():
|
||||
avIds.append(avId)
|
||||
names.append(data[0])
|
||||
scores.append(data[1])
|
||||
return (avIds, names, scores)
|
||||
|
|
Loading…
Reference in a new issue