ai: add district stats

This commit is contained in:
Open Toontown 2019-11-22 20:18:26 -05:00
parent 9c258294ab
commit b9c206a8d9
4 changed files with 59 additions and 4 deletions

View file

@ -38,13 +38,15 @@ load-display pandagl
aux-display pandagl aux-display pandagl
aux-display pandadx9 aux-display pandadx9
aux-display tinydisplay aux-display tinydisplay
depth-bits 24
win-size 800 600 win-size 800 600
fullscreen #t fullscreen #t
compress-channels #t compress-channels #f
display-lists 0 display-lists 0
early-random-seed 1 early-random-seed 1
ssl-cipher-list DEFAULT ssl-cipher-list DEFAULT
respect-prev-transform 1 respect-prev-transform 1
default-directnotify-level info
notify-level-collide warning notify-level-collide warning
notify-level-chan warning notify-level-chan warning
notify-level-gobj warning notify-level-gobj warning

View file

@ -3,6 +3,7 @@ from otp.ai.AIZoneData import AIZoneDataStore
from otp.distributed.OtpDoGlobals import * from otp.distributed.OtpDoGlobals import *
from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository
from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI
from toontown.distributed.ToontownDistrictStatsAI import ToontownDistrictStatsAI
from toontown.ai.HolidayManagerAI import HolidayManagerAI from toontown.ai.HolidayManagerAI import HolidayManagerAI
from toontown.ai.NewsManagerAI import NewsManagerAI from toontown.ai.NewsManagerAI import NewsManagerAI
from toontown.catalog.CatalogManagerAI import CatalogManagerAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI
@ -17,6 +18,7 @@ class ToontownAIRepository(ToontownInternalRepository):
self.doLiveUpdates = config.GetBool('want-live-updates', True) self.doLiveUpdates = config.GetBool('want-live-updates', True)
self.districtId = None self.districtId = None
self.district = None self.district = None
self.districtStats = None
self.holidayManager = None self.holidayManager = None
self.zoneDataStore = None self.zoneDataStore = None
self.newsManager = None self.newsManager = None
@ -61,6 +63,12 @@ class ToontownAIRepository(ToontownInternalRepository):
Creates "global" (distributed) objects. Creates "global" (distributed) objects.
""" """
# Generate our district stats...
self.districtStats = ToontownDistrictStatsAI(self)
self.districtStats.settoontownDistrictId(self.districtId)
self.districtStats.generateWithRequiredAndId(self.allocateChannel(), self.district.getDoId(),
OTP_ZONE_ID_DISTRICTS_STATS)
# Generate our news manager... # Generate our news manager...
self.newsManager = NewsManagerAI(self) self.newsManager = NewsManagerAI(self)
self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT)
@ -83,10 +91,10 @@ class ToontownAIRepository(ToontownInternalRepository):
return self.zoneDataStore return self.zoneDataStore
def incrementPopulation(self): def incrementPopulation(self):
print 'TODO districtStats' self.districtStats.b_setAvatarCount(self.districtStats.getAvatarCount() + 1)
def decrementPopulation(self): def decrementPopulation(self):
print 'TODO districtStats' self.districtStats.b_setAvatarCount(self.districtStats.getAvatarCount() - 1)
def sendQueryToonMaxHp(self, avId, callback): def sendQueryToonMaxHp(self, avId, callback):
pass # TODO? pass # TODO?

View file

@ -3,3 +3,48 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI
class ToontownDistrictStatsAI(DistributedObjectAI): class ToontownDistrictStatsAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownDistrictStatsAI') notify = DirectNotifyGlobal.directNotify.newCategory('ToontownDistrictStatsAI')
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
self.toontownDistrictId = 0
self.avatarCount = 0
self.newAvatarCount = 0
def settoontownDistrictId(self, toontownDistrictId):
self.toontownDistrictId = toontownDistrictId
def d_settoontownDistrictId(self, toontownDistrictId):
self.sendUpdate('settoontownDistrictId', [toontownDistrictId])
def b_settoontownDistrictId(self, toontownDistrictId):
self.settoontownDistrictId(toontownDistrictId)
self.d_settoontownDistrictId(toontownDistrictId)
def gettoontownDistrictId(self):
return self.toontownDistrictId
def setAvatarCount(self, avatarCount):
self.avatarCount = avatarCount
def d_setAvatarCount(self, avatarCount):
self.sendUpdate('setAvatarCount', [avatarCount])
def b_setAvatarCount(self, avatarCount):
self.setAvatarCount(avatarCount)
self.d_setAvatarCount(avatarCount)
def getAvatarCount(self):
return self.avatarCount
def setNewAvatarCount(self, newAvatarCount):
self.newAvatarCount = newAvatarCount
def d_setNewAvatarCount(self, newAvatarCount):
self.sendUpdate('setNewAvatarCount', [newAvatarCount])
def b_setNewAvatarCount(self, newAvatarCount):
self.setNewAvatarCount(newAvatarCount)
self.d_setNewAvatarCount(newAvatarCount)
def getNewAvatarCount(self):
return self.newAvatarCount

View file

@ -410,7 +410,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo
def announceZoneChange(self, newZoneId, oldZoneId): def announceZoneChange(self, newZoneId, oldZoneId):
from toontown.pets import PetObserve from toontown.pets import PetObserve
#self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId) # TODO self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId)
broadcastZones = [oldZoneId, newZoneId] broadcastZones = [oldZoneId, newZoneId]
if self.isInEstate() or self.wasInEstate(): if self.isInEstate() or self.wasInEstate():
broadcastZones = union(broadcastZones, self.estateZones) broadcastZones = union(broadcastZones, self.estateZones)