当前位置: 首页>>代码示例>>Python>>正文


Python ai.ToonBarrier类代码示例

本文整理汇总了Python中toontown.ai.ToonBarrier的典型用法代码示例。如果您正苦于以下问题:Python ToonBarrier类的具体用法?Python ToonBarrier怎么用?Python ToonBarrier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ToonBarrier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enterWaitReadyCourse

    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)
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:25,代码来源:DistributedGolfCourseAI.py

示例2: enterWaitReadyHole

    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)
开发者ID:Toonerz,项目名称:Possible-Toontown-Online-Source,代码行数:27,代码来源:DistributedGolfCourseAI.py

示例3: enterWaitJoin

    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,
        )
开发者ID:Toonerz,项目名称:Possible-Toontown-Online-Source,代码行数:29,代码来源:DistributedGolfCourseAI.py

示例4: enterFrameworkWaitClientsReady

    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())
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:25,代码来源:DistributedMinigameAI.py

示例5: enterWaitForResults

 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
开发者ID:AdrianF98,项目名称:Toontown-Rewritten,代码行数:7,代码来源:DistributedPatternGameAI.py

示例6: enterWaitClientsReady

 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)
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:12,代码来源:DistributedPatternGameAI.py

示例7: enterPlay

    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)
开发者ID:CalmBit,项目名称:ToonboxSource,代码行数:14,代码来源:DistributedTwoDGameAI.py

示例8: enterFrameworkWaitClientsExit

    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)
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:16,代码来源:DistributedMinigameAI.py

示例9: enterFrameworkWaitClientsJoin

    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)
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:17,代码来源:DistributedMinigameAI.py

示例10: enterPlay

    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)
开发者ID:MasterLoopyBM,项目名称:c0d3,代码行数:19,代码来源:DistributedCatchGameAI.py

示例11: enterFrameworkWaitClientsReady

    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._DistributedMinigameAI__barrier = ToonBarrier('waitClientsReady', self.uniqueName('waitClientsReady'), self.avIdList, READY_TIMEOUT, allAvatarsReady, handleTimeout)
        for avId in self.stateDict.keys():
            if self.stateDict[avId] == READY:
                self._DistributedMinigameAI__barrier.clear(avId)
                continue
        
        self.notify.debug('  safezone: %s' % self.getSafezoneId())
        self.notify.debug('difficulty: %s' % self.getDifficulty())
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:20,代码来源:DistributedMinigameAI.py

示例12: DistributedMinigameAI


#.........这里部分代码省略.........
    
    def gameOver(self):
        self.notify.debug('BASE: gameOver')
        self.frameworkFSM.request('frameworkWaitClientsExit')

    
    def enterFrameworkOff(self):
        self.notify.debug('BASE: enterFrameworkOff')

    
    def exitFrameworkOff(self):
        pass

    
    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._DistributedMinigameAI__barrier = ToonBarrier('waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)

    
    def setAvatarJoined(self):
        if self.frameworkFSM.getCurrentState().getName() != 'frameworkWaitClientsJoin':
            self.notify.debug('BASE: Ignoring setAvatarJoined message')
            return None
        
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug('BASE: setAvatarJoined: avatar id joined: ' + str(avId))
        self.air.writeServerEvent('minigame_joined', avId, '%s|%s' % (self.minigameId, self.trolleyZone))
        self.stateDict[avId] = JOINED
        self.notify.debug('BASE: setAvatarJoined: new states: ' + str(self.stateDict))
        self._DistributedMinigameAI__barrier.clear(avId)

    
    def exitFrameworkWaitClientsJoin(self):
        self._DistributedMinigameAI__barrier.cleanup()
        del self._DistributedMinigameAI__barrier

    
    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()
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:66,代码来源:DistributedMinigameAI.py

示例13: enterWaitReward

    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)
开发者ID:AdrianF98,项目名称:Toontown-Rewritten,代码行数:90,代码来源:DistributedGolfCourseAI.py

示例14: DistributedPatternGameAI

class DistributedPatternGameAI(DistributedMinigameAI):
    def __init__(self, air, minigameId):
        try:
            self.DistributedPatternGameAI_initialized
        except:
            self.DistributedPatternGameAI_initialized = 1
            DistributedMinigameAI.__init__(self, air, minigameId)
            self.gameFSM = ClassicFSM.ClassicFSM(
                "DistributedPatternGameAI",
                [
                    State.State("off", self.enterInactive, self.exitInactive, ["waitClientsReady", "cleanup"]),
                    State.State(
                        "waitClientsReady",
                        self.enterWaitClientsReady,
                        self.exitWaitClientsReady,
                        ["generatePattern", "cleanup"],
                    ),
                    State.State(
                        "generatePattern",
                        self.enterGeneratePattern,
                        self.exitGeneratePattern,
                        ["waitForResults", "cleanup"],
                    ),
                    State.State(
                        "waitForResults",
                        self.enterWaitForResults,
                        self.exitWaitForResults,
                        ["waitClientsReady", "cleanup"],
                    ),
                    State.State("cleanup", self.enterCleanup, self.exitCleanup, []),
                ],
                "off",
                "cleanup",
            )
            self.addChildGameFSM(self.gameFSM)

    def delete(self):
        self.notify.debug("delete")
        del self.gameFSM
        DistributedMinigameAI.delete(self)

    def setGameReady(self):
        self.notify.debug("setGameReady")
        DistributedMinigameAI.setGameReady(self)
        self.__initGameVars()

    def setGameStart(self, timestamp):
        self.notify.debug("setGameStart")
        DistributedMinigameAI.setGameStart(self, timestamp)
        self.gameFSM.request("waitClientsReady")

    def setGameAbort(self):
        self.notify.debug("setGameAbort")
        if self.gameFSM.getCurrentState():
            self.gameFSM.request("cleanup")
        DistributedMinigameAI.setGameAbort(self)

    def gameOver(self):
        self.notify.debug("gameOver")
        self.gameFSM.request("cleanup")
        DistributedMinigameAI.gameOver(self)

    def enterInactive(self):
        self.notify.debug("enterInactive")

    def exitInactive(self):
        pass

    def __initGameVars(self):
        self.pattern = []
        self.round = 0
        self.perfectResults = {}
        for avId in self.avIdList:
            self.perfectResults[avId] = 1

        self.readyClients = []
        self.timeoutTaskName = self.uniqueName("PatternGameResultsTimeout")

    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 reportPlayerReady(self):
        if not self._inState("waitClientsReady"):
            return
        avId = self.air.getAvatarIdFromSender()
        if avId not in self.avIdList:
            self.notify.warning("Got reportPlayerReady from an avId: %s not in our list: %s" % (avId, self.avIdList))
        else:
            self.readyClients.append(avId)
            self.nextRoundBarrier.clear(avId)
#.........这里部分代码省略.........
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:101,代码来源:DistributedPatternGameAI.py

示例15: DistributedMinigameAI


#.........这里部分代码省略.........
        self.sendUpdate("setGameAbort", [])
        self.frameworkFSM.request("frameworkCleanup")

    def handleExitedAvatar(self, avId):
        self.notify.warning("BASE: handleExitedAvatar: avatar id exited: " + str(avId))
        self.stateDict[avId] = EXITED
        self.setGameAbort()

    def gameOver(self):
        self.frameworkFSM.request("frameworkWaitClientsExit")

    def enterFrameworkOff(self):
        self.notify.debug("BASE: enterFrameworkOff")

    def exitFrameworkOff(self):
        pass

    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 setAvatarJoined(self):
        if self.frameworkFSM.getCurrentState().getName() != "frameworkWaitClientsJoin":
            self.notify.debug("BASE: Ignoring setAvatarJoined message")
            return
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug("BASE: setAvatarJoined: avatar id joined: " + str(avId))
        self.air.writeServerEvent("minigame_joined", avId, "%s|%s" % (self.minigameId, self.trolleyZone))
        self.stateDict[avId] = JOINED
        self.notify.debug("BASE: setAvatarJoined: new states: " + str(self.stateDict))
        self.__barrier.clear(avId)

    def exitFrameworkWaitClientsJoin(self):
        self.__barrier.cleanup()
        del self.__barrier

    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)
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:67,代码来源:DistributedMinigameAI.py


注:本文中的toontown.ai.ToonBarrier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。