mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-10-31 00:37:54 +00:00
Merge branch 'master' into news
This commit is contained in:
commit
4ec772e549
3 changed files with 0 additions and 92 deletions
|
@ -1,75 +0,0 @@
|
|||
|
||||
|
||||
class ServerEventBuffer:
|
||||
|
||||
def __init__(self, air, name, avId, period = None):
|
||||
self.air = air
|
||||
self.name = name
|
||||
self.avId = avId
|
||||
if period is None:
|
||||
period = 6 * 60.0
|
||||
self.period = period
|
||||
self.lastFlushTime = None
|
||||
return
|
||||
|
||||
def destroy(self):
|
||||
self.flush()
|
||||
|
||||
def flush(self):
|
||||
self.lastFlushTime = None
|
||||
return
|
||||
|
||||
def writeEvent(self, msg):
|
||||
self.air.writeServerEvent(self.name, self.avId, msg)
|
||||
|
||||
def considerFlush(self):
|
||||
if self.lastFlushTime is None:
|
||||
self.lastFlushTime = globalClock.getFrameTime()
|
||||
elif globalClock.getFrameTime() - self.lastFlushTime > self.period * 60.0:
|
||||
self.flush()
|
||||
return
|
||||
|
||||
|
||||
class ServerEventAccumulator(ServerEventBuffer):
|
||||
|
||||
def __init__(self, air, name, avId, period = None):
|
||||
ServerEventBuffer.__init__(self, air, name, avId, period)
|
||||
self.count = 0
|
||||
|
||||
def flush(self):
|
||||
ServerEventBuffer.flush(self)
|
||||
if not self.count:
|
||||
return
|
||||
self.writeEvent('%s' % self.count)
|
||||
self.count = 0
|
||||
|
||||
def addEvent(self):
|
||||
self.count += 1
|
||||
self.considerFlush()
|
||||
|
||||
|
||||
class ServerEventMultiAccumulator(ServerEventBuffer):
|
||||
|
||||
def __init__(self, air, name, avId, period = None):
|
||||
ServerEventBuffer.__init__(self, air, name, avId, period)
|
||||
self.events = {}
|
||||
|
||||
def flush(self):
|
||||
ServerEventBuffer.flush(self)
|
||||
if not len(self.events):
|
||||
return
|
||||
msg = ''
|
||||
eventNames = self.events.keys()
|
||||
eventNames.sort()
|
||||
for eventName in eventNames:
|
||||
msg += '%s:%s' % (eventName, self.events[eventName])
|
||||
if eventName != eventNames[-1]:
|
||||
msg += ','
|
||||
|
||||
self.writeEvent(msg)
|
||||
self.events = {}
|
||||
|
||||
def addEvent(self, eventName):
|
||||
self.events.setdefault(eventName, 0)
|
||||
self.events[eventName] += 1
|
||||
self.considerFlush()
|
|
@ -16,7 +16,6 @@ from toontown.pets import PetObserve, PetBrain, PetMood
|
|||
from toontown.pets import PetActionFSM, PetBase, PetGoal, PetTricks
|
||||
from direct.fsm import FSM
|
||||
from toontown.toon import DistributedToonAI
|
||||
from toontown.ai import ServerEventBuffer
|
||||
import random
|
||||
import time
|
||||
import string
|
||||
|
@ -475,10 +474,6 @@ class DistributedPetAI(DistributedSmoothNodeAI.DistributedSmoothNodeAI, PetLooke
|
|||
self.leashMode = 0
|
||||
self.leashAvId = None
|
||||
self.leashGoal = None
|
||||
self.trickLogger = ServerEventBuffer.ServerEventMultiAccumulator(self.air, 'petTricksPerformed', self.doId)
|
||||
self.trickFailLogger = ServerEventBuffer.ServerEventMultiAccumulator(self.air, 'petTricksFailed', self.doId)
|
||||
self.feedLogger = ServerEventBuffer.ServerEventAccumulator(self.air, 'petFeedings', self.doId)
|
||||
self.scratchLogger = ServerEventBuffer.ServerEventAccumulator(self.air, 'petScratchings', self.doId)
|
||||
self.traits = PetTraits.PetTraits(self.traitSeed, self.safeZone)
|
||||
if not hasattr(self, '_beingCreatedInDB'):
|
||||
for i in xrange(len(self.traitList)):
|
||||
|
@ -540,14 +535,6 @@ class DistributedPetAI(DistributedSmoothNodeAI.DistributedSmoothNodeAI, PetLooke
|
|||
DistributedSmoothNodeAI.DistributedSmoothNodeAI.requestDelete(self)
|
||||
|
||||
def _doDeleteCleanup(self):
|
||||
self.trickLogger.destroy()
|
||||
self.trickFailLogger.destroy()
|
||||
self.feedLogger.destroy()
|
||||
self.scratchLogger.destroy()
|
||||
del self.trickLogger
|
||||
del self.trickFailLogger
|
||||
del self.feedLogger
|
||||
del self.scratchLogger
|
||||
taskMgr.remove(self.uniqueName('clearMovie'))
|
||||
taskMgr.remove(self.uniqueName('PetMovieWait'))
|
||||
taskMgr.remove(self.uniqueName('PetMovieClear'))
|
||||
|
@ -716,12 +703,10 @@ class DistributedPetAI(DistributedSmoothNodeAI.DistributedSmoothNodeAI, PetLooke
|
|||
if avatar.takeMoney(PetConstants.FEED_AMOUNT):
|
||||
self.startLockPetMove(avatar.doId)
|
||||
self.brain.observe(PetObserve.PetActionObserve(PetObserve.Actions.FEED, avatar.doId))
|
||||
self.feedLogger.addEvent()
|
||||
|
||||
def scratch(self, avatar):
|
||||
self.startLockPetMove(avatar.doId)
|
||||
self.brain.observe(PetObserve.PetActionObserve(PetObserve.Actions.SCRATCH, avatar.doId))
|
||||
self.scratchLogger.addEvent()
|
||||
|
||||
def lockPet(self):
|
||||
DistributedPetAI.notify.debug('%s: lockPet' % self.doId)
|
||||
|
@ -982,7 +967,6 @@ class DistributedPetAI(DistributedSmoothNodeAI.DistributedSmoothNodeAI, PetLooke
|
|||
aptitude = self.getTrickAptitude(trickId)
|
||||
self.setTrickAptitude(trickId, aptitude + PetTricks.AptitudeIncrementDidTrick)
|
||||
self.addToMood('fatigue', lerp(PetTricks.MaxTrickFatigue, PetTricks.MinTrickFatigue, aptitude))
|
||||
self.trickLogger.addEvent(trickId)
|
||||
|
||||
def _handleGotPositiveTrickFeedback(self, trickId, magnitude):
|
||||
if trickId == PetTricks.Tricks.BALK:
|
||||
|
|
|
@ -404,7 +404,6 @@ class PetBrain(DirectObject.DirectObject):
|
|||
if avatar:
|
||||
if looked:
|
||||
if not self.pet._willDoTrick(trickId):
|
||||
self.pet.trickFailLogger.addEvent(trickId)
|
||||
trickId = PetTricks.Tricks.BALK
|
||||
self._doTrick(trickId, avatar)
|
||||
|
||||
|
|
Loading…
Reference in a new issue