def enterFrameworkWaitClientsJoin(self): """ This state waits for all of the clients to join. see setAvatarJoined """ self.notify.debug("BASE: enterFrameworkWaitClientsJoin") for avId in self.avIdList: self.stateDict[avId] = EXPECTED self.scoreDict[avId] = DEFAULT_POINTS # listen for this avatar's exit event self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs=[avId]) def allAvatarsJoined(self=self): self.notify.debug("BASE: all avatars joined") # Everybody is here, wait for them to read the rules self.b_setGameReady() # wait for clients to be ready self.frameworkFSM.request('frameworkWaitClientsReady') def handleTimeout(avIds, self=self): self.notify.debug("BASE: timed out waiting for clients %s " "to join" % avIds) self.setGameAbort() self.__barrier = ToonBarrier( 'waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)
def enterFrameworkWaitClientsReady(self): """ This state waits for all of the clients to be ready. see setAvatarReady """ self.notify.debug("BASE: enterFrameworkWaitClientsReady") def allAvatarsReady(self=self): self.notify.debug("BASE: all avatars ready") # Everybody is here, start the game self.frameworkFSM.request('frameworkGame') def handleTimeout(avIds, self=self): self.notify.debug("BASE: timed out waiting for clients %s " "to report 'ready'" % avIds) self.setGameAbort() self.__barrier = ToonBarrier( 'waitClientsReady', self.uniqueName('waitClientsReady'), self.avIdList, READY_TIMEOUT, allAvatarsReady, handleTimeout) # some clients may already be ready for avId in list(self.stateDict.keys()): if self.stateDict[avId] == READY: self.__barrier.clear(avId) self.notify.debug(" safezone: %s" % self.getSafezoneId()) self.notify.debug("difficulty: %s" % self.getDifficulty())
def enterWaitForResults(self): self.notify.debug('enterWaitForResults') self.results = [None] * self.numPlayers self.fastestTime = PatternGameGlobals.InputTime * 2 self.fastestAvId = 0 self.resultsBarrier = ToonBarrier('results', self.uniqueName('results'), self.avIdList, PatternGameGlobals.InputTimeout + 1.0 * self.round, self.__gotAllPatterns, self.__resultsTimeout) return
def enterWaitReadyCourse(self): self.notify.debug('GOLF COURSE: enterWaitReadyCourse') def allAvatarsInCourse(self=self): self.notify.debug('GOLF COURSE: all avatars ready course') for avId in self.avIdList: blankScoreList = [0] * self.numHoles self.scores[avId] = blankScoreList self.aimTimes[avId] = 0 self.notify.debug('self.scores = %s' % self.scores) self.startNextHole() def handleTimeout(avIds, self=self): self.notify.debug( "GOLF COURSE: Course timed out waiting for clients %s to report 'ready'" % avIds) if self.haveAllGolfersExited(): self.setCourseAbort() else: allAvatarsInCourse() self.__barrier = ToonBarrier('WaitReadyCourse', self.uniqueName('WaitReadyCourse'), self.avIdList, READY_TIMEOUT, allAvatarsInCourse, handleTimeout) for avId in self.avStateDict.keys(): if self.avStateDict[avId] == READY: self.__barrier.clear(avId)
def enterWaitJoin(self): self.notify.debug('GOLF COURSE: enterWaitJoin') for avId in self.avIdList: self.avStateDict[avId] = EXPECTED self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs=[avId]) def allAvatarsJoined(self=self): self.notify.debug('GOLF COURSE: all avatars joined') self.load() def handleTimeout(avIds, self=self): self.notify.debug( 'GOLF COURSE: timed out waiting for clients %s to join' % avIds) for avId in self.avStateDict: if not self.avStateDict[avId] == JOINED: self.handleExitedAvatar(avId) if self.haveAllGolfersExited(): self.setCourseAbort() else: self.load() self.__barrier = ToonBarrier('waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)
def enterWaitReadyHole(self): self.notify.debug('GOLF COURSE: enterWaitReadyHole') def allAvatarsInHole(self=self): self.notify.debug('GOLF COURSE: all avatars ready hole') if self.safeDemand('PlayHole'): self.d_setPlayHole() def handleTimeout(avIds, self=self): self.notify.debug( "GOLF COURSE: Hole timed out waiting for clients %s to report 'ready'" % avIds) if self.haveAllGolfersExited(): self.setCourseAbort() elif self.safeDemand('PlayHole'): self.d_setPlayHole() stillPlaying = self.getStillPlayingAvIds() self.__barrier = ToonBarrier('WaitReadyHole', self.uniqueName('WaitReadyHole'), stillPlaying, READY_TIMEOUT, allAvatarsInHole, handleTimeout) for avId in self.avStateDict.keys(): if self.avStateDict[avId] == ONHOLE: self.__barrier.clear(avId)
def enterWaitPlayback(self): self.notify.debug('enterWaitPlayback') stillPlayingList = self.golfCourse.getStillPlayingAvIds() self.barrierPlayback = ToonBarrier( 'waitClientsPlayback', self.uniqueName('waitClientsPlayback'), stillPlayingList, 120, self.handleWaitPlaybackDone, self.handlePlaybackTimeout)
def enterPlay(self): self.notify.debug("enterPlay") self.caughtList = [0] * 100 # get the number of fruits that will be dropped table = CatchGameGlobals.NumFruits[self.numPlayers - 1] self.numFruits = table[self.getSafezoneId()] self.notify.debug('numFruits: %s' % self.numFruits) # and keep track of how many are caught self.fruitsCaught = 0 # set up a barrier to wait for the 'game done' msgs def allToonsDone(self=self): self.notify.debug('allToonsDone') self.sendUpdate('setEveryoneDone') if not CatchGameGlobals.EndlessGame: self.gameOver() def handleTimeout(avIds, self=self): self.notify.debug( 'handleTimeout: avatars %s did not report "done"' % avIds) self.setGameAbort() self.doneBarrier = ToonBarrier( 'waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, CatchGameGlobals.GameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)
def enterFrameworkWaitClientsExit(self): """ this state waits for all of the clients to report that they have exited the minigame """ self.notify.debug("BASE: enterFrameworkWaitClientsExit") # tell the clients to leave self.b_setGameExit() def allAvatarsExited(self=self): self.notify.debug("BASE: all avatars exited") # go to the cleanup state self.frameworkFSM.request('frameworkCleanup') def handleTimeout(avIds, self=self): """ Well, we did not hear from all the clients that they exited, but it has been long enough. Go ahead and get out of here """ self.notify.debug("BASE: timed out waiting for clients %s " "to exit" % avIds) self.frameworkFSM.request('frameworkCleanup') # time out on waiting for clients to exit - then abort self.__barrier = ToonBarrier( 'waitClientsExit', self.uniqueName('waitClientsExit'), self.avIdList, EXIT_TIMEOUT, allAvatarsExited, handleTimeout) # process any toons that have already exited for avId in list(self.stateDict.keys()): if self.stateDict[avId] == EXITED: self.__barrier.clear(avId)
def beginBarrier(self, name, avIds, timeout, callback): # Begins waiting for a set of avatars. When all avatars in # the list have reported back in or the callback has expired, # calls the indicated callback with the list of toons that # made it through. There may be multiple barriers waiting # simultaneously on different lists of avatars, although they # should have different names. from toontown.ai import ToonBarrier context = self.__nextBarrierContext # We assume the context number is passed as a uint16. self.__nextBarrierContext = (self.__nextBarrierContext + 1) & 0xffff assert(self.notify.debug('beginBarrier(%s, %s, %s, %s)' % (context, name, avIds, timeout))) if avIds: barrier = ToonBarrier.ToonBarrier( self.uniqueName(name), avIds, timeout, doneFunc = PythonUtil.Functor(self.__barrierCallback, context, callback)) self.__barriers[context] = barrier # Send the context number to each involved client. self.sendUpdate("setBarrierData", [self.__getBarrierData()]) else: # No avatars; just call the callback immediately. callback(avIds) return context
def enterBarrelRoomIntro(self): if not self._wantBarrelRoom: pass if self._wantBarrelRoom and not self.isBossFloor(self.currentFloor): self.barrelRoom.setScore(1.0) self.brBarrier = ToonBarrier.ToonBarrier('waitBrIntroDone', self.uniqueName('waitBrIntroDone'), self.toons, CogdoBarrelRoomConsts.BarrelRoomIntroTimeout, doneFunc = self.__brIntroDone) else: self.__brIntroDone()
def enterWaitClientsReady(self): self.notify.debug('enterWaitClientsReady') self.nextRoundBarrier = ToonBarrier( 'nextRoundReady', self.uniqueName('nextRoundReady'), self.avIdList, PatternGameGlobals.ClientsReadyTimeout, self.__allPlayersReady, self.__clientsReadyTimeout) for avId in self.readyClients: self.nextRoundBarrier.clear(avId)
def enterBarrelRoomReward(self): if self._wantBarrelRoom and not self.isBossFloor(self.currentFloor): self.sendUpdate('setBarrelRoomReward', self.barrelRoom.results) self.brBarrier = ToonBarrier.ToonBarrier( 'waitBrRewardDone', self.uniqueName('waitBrRewardDone'), self.toons, CogdoBarrelRoomConsts.RewardUiTime + 5.0, doneFunc=self.__brRewardDone) else: self.__brRewardDone()
def enterWaitForResults(self): self.notify.debug("enterWaitForResults") self.results = [None] * self.numPlayers self.fastestTime = PatternGameGlobals.InputTime*2 self.fastestAvId = 0 # allow some additional time to show the pattern to the players self.resultsBarrier = ToonBarrier( 'results', self.uniqueName('results'), self.avIdList, PatternGameGlobals.InputTimeout + (1. * self.round), self.__gotAllPatterns, self.__resultsTimeout)
def enterPlay(self): self.notify.debug('enterPlay') def allToonsDone(self = self): self.notify.debug('allToonsDone') self.sendUpdate('setEveryoneDone') if not ToonBlitzGlobals.EndlessGame: self.gameOver() def handleTimeout(avIds, self = self): self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds) self.setGameAbort() self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, ToonBlitzGlobals.GameDuration[self.getSafezoneId()] + ToonBlitzGlobals.ShowScoresDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)
def enterFrameworkWaitClientsExit(self): self.notify.debug('BASE: enterFrameworkWaitClientsExit') self.b_setGameExit() def allAvatarsExited(self = self): self.notify.debug('BASE: all avatars exited') self.frameworkFSM.request('frameworkCleanup') def handleTimeout(avIds, self = self): self.notify.debug('BASE: timed out waiting for clients %s to exit' % avIds) self.frameworkFSM.request('frameworkCleanup') self.__barrier = ToonBarrier('waitClientsExit', self.uniqueName('waitClientsExit'), self.avIdList, EXIT_TIMEOUT, allAvatarsExited, handleTimeout) for avId in self.stateDict.keys(): if self.stateDict[avId] == EXITED: self.__barrier.clear(avId)
def enterFrameworkWaitClientsJoin(self): self.notify.debug('BASE: enterFrameworkWaitClientsJoin') for avId in self.avIdList: self.stateDict[avId] = EXPECTED self.scoreDict[avId] = DEFAULT_POINTS self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs=[avId]) def allAvatarsJoined(self = self): self.notify.debug('BASE: all avatars joined') self.b_setGameReady() self.frameworkFSM.request('frameworkWaitClientsReady') def handleTimeout(avIds, self = self): self.notify.debug('BASE: timed out waiting for clients %s to join' % avIds) self.setGameAbort() self.__barrier = ToonBarrier('waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)
def enterFrameworkWaitClientsReady(self): self.notify.debug('BASE: enterFrameworkWaitClientsReady') def allAvatarsReady(self = self): self.notify.debug('BASE: all avatars ready') self.frameworkFSM.request('frameworkGame') def handleTimeout(avIds, self = self): self.notify.debug("BASE: timed out waiting for clients %s to report 'ready'" % avIds) self.setGameAbort() self.__barrier = ToonBarrier('waitClientsReady', self.uniqueName('waitClientsReady'), self.avIdList, READY_TIMEOUT, allAvatarsReady, handleTimeout) for avId in self.stateDict.keys(): if self.stateDict[avId] == READY: self.__barrier.clear(avId) self.notify.debug(' safezone: %s' % self.getSafezoneId()) self.notify.debug('difficulty: %s' % self.getDifficulty())
def enterPlay(self): self.notify.debug('enterPlay') self.caughtList = [0] * 100 table = CatchGameGlobals.NumFruits[self.numPlayers - 1] self.numFruits = table[self.getSafezoneId()] self.notify.debug('numFruits: %s' % self.numFruits) self.fruitsCaught = 0 def allToonsDone(self = self): self.notify.debug('allToonsDone') self.sendUpdate('setEveryoneDone') if not CatchGameGlobals.EndlessGame: self.gameOver() def handleTimeout(avIds, self = self): self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds) self.setGameAbort() self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, CatchGameGlobals.GameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)
def enterWaitJoin(self): """ This state waits for all of the clients to join. see setAvatarJoined """ self.notify.debug("GOLF COURSE: enterWaitJoin") for avId in self.avIdList: self.avStateDict[avId] = EXPECTED # listen for this avatar's exit event self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs=[avId]) def allAvatarsJoined(self=self): self.notify.debug("GOLF COURSE: all avatars joined") # Everybody is here, wait for them to ready the course # wait for clients to be ready self.load() def handleTimeout(avIds, self=self): self.notify.debug("GOLF COURSE: timed out waiting for clients %s " "to join" % avIds) for avId in self.avStateDict: if not self.avStateDict[avId] == JOINED: #kick player self.handleExitedAvatar(avId) if self.haveAllGolfersExited(): self.setCourseAbort() else: self.load() self.__barrier = ToonBarrier('waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)
def enterWaitReadyCourse(self): """ This state waits for all of the clients to be ready. see setAvatarReady """ self.notify.debug("GOLF COURSE: enterWaitReadyCourse") def allAvatarsInCourse(self=self): self.notify.debug("GOLF COURSE: all avatars ready course") # Everybody is here, start the game # prepopulate the scores with zeros for avId in self.avIdList: blankScoreList = [0] * self.numHoles self.scores[avId] = blankScoreList self.aimTimes[avId] = 0 self.notify.debug('self.scores = %s' % self.scores) self.startNextHole() def handleTimeout(avIds, self=self): self.notify.debug( "GOLF COURSE: Course timed out waiting for clients %s " "to report 'ready'" % avIds) if self.haveAllGolfersExited(): self.setCourseAbort() else: allAvatarsInCourse() self.__barrier = ToonBarrier('WaitReadyCourse', self.uniqueName('WaitReadyCourse'), self.avIdList, READY_TIMEOUT, allAvatarsInCourse, handleTimeout) # some clients may already be ready for avId in self.avStateDict.keys(): if self.avStateDict[avId] == READY: self.__barrier.clear(avId)
def enterWaitReward(self): self.updateHistoryForCourseComplete() self.awardTrophies() self.awardCups() self.awardHoleBest() self.awardCourseBest() self.recordHoleInOne() self.recordCourseUnderPar() trophiesList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newTrophies: oneTrophyList = map(int, self.newTrophies[avId]) trophiesList.append(oneTrophyList) continue trophiesList.append([]) while len(trophiesList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: trophiesList.append([]) holeBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newHoleBest: oneTrophyList = map(int, self.newHoleBest[avId]) holeBestList.append(oneTrophyList) continue holeBestList.append([]) while len(holeBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: holeBestList.append([]) courseBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCourseBest: oneTrophyList = map(int, self.newCourseBest[avId]) courseBestList.append(oneTrophyList) continue courseBestList.append([]) while len(courseBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: courseBestList.append([]) cupList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCups: oneCupList = map(int, self.newCups[avId]) cupList.append(oneCupList) self.cupListLen = self.cupListLen + 1 continue cupList.append([]) while len(cupList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: cupList.append([]) REWARD_TIMEOUT = (self.trophyListLen + self.holeBestListLen + self.courseBestListLen + self.cupListLen) * 5 + 19 aimTimesList = [0] * 4 aimIndex = 0 stillPlaying = self.getStillPlayingAvIds() for avId in self.avIdList: if avId in stillPlaying: aimTime = 0 if avId in self.aimTimes: aimTime = self.aimTimes[avId] aimTimesList[aimIndex] = aimTime aimIndex += 1 dg = PyDatagram() for list in trophiesList: dg.addUint8(len(list)) for item in list: dg.addUint8(item) dg.addUint8(len(self.rankings)) for item in self.rankings: dg.addInt8(item) for list in holeBestList: dg.addUint8(len(list)) for item in list: dg.addUint8(item) for list in courseBestList: dg.addUint8(len(list)) for item in list: dg.addUint8(item) for list in cupList: dg.addUint8(len(list)) for item in list: dg.addUint8(item) dg.addUint32(self.winnerByTieBreak) for at in aimTimesList: dg.addUint32(int(at * 100)) self.sendUpdate('setReward', [dg.getMessage()]) def allAvatarsRewarded(self=self): self.notify.debug('GOLF COURSE: all avatars rewarded') self.rewardDone() def handleRewardTimeout(avIds, self=self): self.notify.debug( 'GOLF COURSE: timed out waiting for clients %s to finish reward' % avIds) self.rewardDone() stillPlaying = self.getStillPlayingAvIds() self.rewardBarrier = ToonBarrier('waitReward', self.uniqueName('waitReward'), stillPlaying, REWARD_TIMEOUT, allAvatarsRewarded, handleRewardTimeout)
def enterWaitReward(self): self.updateHistoryForCourseComplete() self.awardTrophies() self.awardCups() self.awardHoleBest() self.awardCourseBest() self.recordHoleInOne() self.recordCourseUnderPar() trophiesList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newTrophies: oneTrophyList = self.newTrophies[avId] trophiesList.append(oneTrophyList) else: trophiesList.append([]) while len(trophiesList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: trophiesList.append([]) holeBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newHoleBest: oneTrophyList = self.newHoleBest[avId] holeBestList.append(oneTrophyList) else: holeBestList.append([]) while len(holeBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: holeBestList.append([]) courseBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCourseBest: oneTrophyList = self.newCourseBest[avId] courseBestList.append(oneTrophyList) else: courseBestList.append([]) while len(courseBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: courseBestList.append([]) cupList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCups: oneCupList = self.newCups[avId] cupList.append(oneCupList) self.cupListLen = self.cupListLen + 1 else: cupList.append([]) while len(cupList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: cupList.append([]) REWARD_TIMEOUT = (self.trophyListLen + self.holeBestListLen + self.courseBestListLen + self.cupListLen) * 5 + 19 aimTimesList = [0] * 4 aimIndex = 0 stillPlaying = self.getStillPlayingAvIds() for avId in self.avIdList: if avId in stillPlaying: aimTime = 0 if avId in self.aimTimes: aimTime = self.aimTimes[avId] aimTimesList[aimIndex] = aimTime aimIndex += 1 self.sendUpdate('setReward', [ trophiesList, self.rankings, holeBestList, courseBestList, cupList, self.winnerByTieBreak, aimTimesList[0], aimTimesList[1], aimTimesList[2], aimTimesList[3] ]) def allAvatarsRewarded(self=self): self.notify.debug('GOLF COURSE: all avatars rewarded') self.rewardDone() def handleRewardTimeout(avIds, self=self): self.notify.debug( 'GOLF COURSE: timed out waiting for clients %s to finish reward' % avIds) self.rewardDone() stillPlaying = self.getStillPlayingAvIds() self.rewardBarrier = ToonBarrier('waitReward', self.uniqueName('waitReward'), stillPlaying, REWARD_TIMEOUT, allAvatarsRewarded, handleRewardTimeout)
def enterWaitReward(self): """Done playing all the holes, display a reward movie on the client.""" # TODO calculate any trophy rewards, send those to the client self.updateHistoryForCourseComplete() self.awardTrophies() self.awardCups() self.awardHoleBest() self.awardCourseBest() self.recordHoleInOne() self.recordCourseUnderPar() trophiesList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newTrophies: oneTrophyList = self.newTrophies[avId] trophiesList.append(oneTrophyList) else: # probably a disconnected player, just us an empty list trophiesList.append([]) while len(trophiesList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: # toon.dc expects 4 lists trophiesList.append([]) holeBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newHoleBest: oneTrophyList = self.newHoleBest[avId] holeBestList.append(oneTrophyList) else: # probably a disconnected player, just us an empty list holeBestList.append([]) while len(holeBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: # toon.dc expects 4 lists holeBestList.append([]) courseBestList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCourseBest: oneTrophyList = self.newCourseBest[avId] courseBestList.append(oneTrophyList) else: # probably a disconnected player, just us an empty list courseBestList.append([]) while len(courseBestList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: # toon.dc expects 4 lists courseBestList.append([]) cupList = [] for index in xrange(len(self.avIdList)): avId = self.avIdList[index] if avId in self.newCups: oneCupList = self.newCups[avId] cupList.append(oneCupList) self.cupListLen = self.cupListLen + 1 else: # probably a disconnected player, just us an empty list cupList.append([]) while len(cupList) < GolfGlobals.MAX_PLAYERS_PER_HOLE: # toon.dc expects 4 lists cupList.append([]) REWARD_TIMEOUT = (self.trophyListLen + self.holeBestListLen + self.courseBestListLen + self.cupListLen) * 5 + 19 # the extra 15 seconds are for: 8 seconds of rankings and 7 as a buffer # send total aim times too aimTimesList = [0] * 4 aimIndex = 0 stillPlaying = self.getStillPlayingAvIds() for avId in self.avIdList: if avId in stillPlaying: aimTime = 0 if avId in self.aimTimes: aimTime = self.aimTimes[avId] aimTimesList[aimIndex] = aimTime aimIndex += 1 self.sendUpdate('setReward', [trophiesList, self.rankings, \ holeBestList, courseBestList, cupList, self.winnerByTieBreak, aimTimesList[0], aimTimesList[1], aimTimesList[2], aimTimesList[3]] ) def allAvatarsRewarded(self=self): self.notify.debug("GOLF COURSE: all avatars rewarded") # Everybody is here, leave the golf course #self.safeDemand('WaitLeaveCourse') self.rewardDone() def handleRewardTimeout(avIds, self=self): self.notify.debug("GOLF COURSE: timed out waiting for clients %s " "to finish reward" % avIds) # self.setCourseAbort() #self.safeDemand('WaitLeaveCourse') self.rewardDone() stillPlaying = self.getStillPlayingAvIds() self.rewardBarrier = ToonBarrier('waitReward', self.uniqueName('waitReward'), stillPlaying, REWARD_TIMEOUT, allAvatarsRewarded, handleRewardTimeout)