• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ai.ToonBarrier类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: enterWaitReward


#.........这里部分代码省略.........
        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)
开发者ID:vincent15k,项目名称:Toontown-House,代码行数:101,代码来源:DistributedGolfCourseAI.py


示例17: DistributedGolfCourseAI


#.........这里部分代码省略.........
    def setCourseAbort(self):
        self.notify.debug('GOLF COURSE: setGameAbort')
        self.normalExit = 0
        self.sendUpdate('setCourseAbort', [0])
        self.safeDemand('Cleanup')

    def enterOff(self):
        self.notify.debug('GOLF COURSE: enterOff')

    def exitOff(self):
        self.notify.debug('GOLF COURSE: exitOff')

    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 exitWaitJoin(self):
        self.notify.debugStateCall(self)
        self.__barrier.cleanup()
        self.__barrier = None
        return

    def setAvatarJoined(self):
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug('GOLF COURSE: setAvatarJoined: avatar id joined: ' + str(avId))
        self.avStateDict[avId] = JOINED
        self.notify.debug('GOLF COURSE: setAvatarJoined: new states: ' + str(self.avStateDict))
        if hasattr(self, '_DistributedGolfCourseAI__barrier') and self.__barrier:
            self.__barrier.clear(avId)
        else:
            self.notify.warning('setAvatarJoined avId=%d but barrier is invalid' % avId)

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

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


示例18: DistributedGolfHoleAI


#.........这里部分代码省略.........
        if self.state == 'WaitPlayback' or self.state == 'WaitTee':
            self.notify.warning('performReadyAction requesting from %s to WaitPlayback' % self.state)
        self.request('WaitPlayback')
        self.sendUpdate('ballMovie2Client', [self.storeAction[1],
         avId,
         self.recording,
         self.aVRecording,
         self.ballInHoleFrame,
         self.ballTouchedHoleFrame,
         self.ballFirstTouchedHoleFrame,
         self.commonHoldData])
        self.ballPos[avId] = newPos
        self.trustedPlayerId = None
        return

    def postResult(self, cycleTime, avId, recording, aVRecording, ballInHoleFrame, ballTouchedHoleFrame, ballFirstTouchedHoleFrame):
        pass

    def enterWaitSwing(self):
        pass

    def exitWaitSwing(self):
        pass

    def enterWaitTee(self):
        pass

    def exitWaitTee(self):
        pass

    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 hasCurGolferReachedMaxSwing(self):
        strokes = self.golfCourse.getCurHoleScore(self.activeGolferId)
        maxSwing = self.holeInfo['maxSwing']
        retval = strokes >= maxSwing
        if retval:
            av = simbase.air.doId2do.get(self.activeGolferId)
            if av:
                if av.getUnlimitedSwing():
                    retval = False
        return retval

    def handleWaitPlaybackDone(self):
        if self.isCurBallInHole(self.activeGolferId) or self.hasCurGolferReachedMaxSwing():
            if self.activeGolferId:
                self.ballInHole(self.activeGolferId)
        else:
            self.selectNextGolfer()

    def isCurBallInHole(self, golferId):
        retval = False
        for holePos in self.holePositions:
            displacement = self.ballPos[golferId] - holePos
            length = displacement.length()
            self.notify.debug('hole %s length=%s' % (holePos, length))
            if length <= GolfGlobals.DistanceToBeInHole:
                retval = True
                break

        return retval

    def exitWaitPlayback(self):
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:67,代码来源:DistributedGolfHoleAI.py


示例19: DistributedTwoDGameAI


#.........这里部分代码省略.........
         self.sectionIndexList))
        self.notify.debug('minigame_twoD%s: %s|%s|%s|%s|%s|%s|%s|%s|%s' % (self.doId,
         ToontownGlobals.TwoDGameId,
         self.getSafezoneId(),
         self.avIdList,
         scoreList,
         finishedBonusList,
         timeLeftList,
         treasureCollectedList,
         playerErrorList,
         self.sectionIndexList))
        self.gameFSM.request('cleanup')
        DistributedMinigameAI.gameOver(self)

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

    def exitInactive(self):
        pass

    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 exitPlay(self):
        pass

    def enterCleanup(self):
        self.notify.debug('enterCleanup')
        self.doneBarrier.cleanup()
        del self.doneBarrier
        self.gameFSM.request('inactive')

    def exitCleanup(self):
        pass

    def claimTreasure(self, sectionIndex, treasureIndex):
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug('treasure %s-%s claimed by %s' % (sectionIndex, treasureIndex, avId))
        if sectionIndex < 0 or sectionIndex >= len(self.sectionsSelected):
            self.air.writeServerEventMessage('warning', sectionIndex, 'TwoDGameAI.claimTreasure sectionIndex out of range.')
            return
        if treasureIndex < 0 or treasureIndex >= len(self.treasureTakenTable[sectionIndex]):
            self.notify.warning('Treasure %s: TwoDGameAI.claimTreasure treasureIndex out of range.' % treasureIndex)
            self.air.writeServerEventMessage('warning', treasureIndex, 'TwoDGameAI.claimTreasure treasureIndex out of range.')
            return
        if self.treasureTakenTable[sectionIndex][treasureIndex]:
            return
        initialTreasureList = self.sectionsSelected[sectionIndex][2]
        if treasureIndex < len(initialTreasureList):
            treasureValue = initialTreasureList[treasureIndex][1]
        else:
            treasureValue = self.numPlayers
        self.treasureTakenTable[sectionIndex][treasureIndex] = treasureValue
        self.treasuresCollectedDict[avId][treasureValue - 1] += 1
开发者ID:CalmBit,项目名称:ToonboxSource,代码行数:67,代码来源:DistributedTwoDGameAI.py


示例20: DistributedCatchGameAI

class DistributedCatchGameAI(DistributedMinigameAI):
    
    def __init__(self, air, minigameId):
        
        try:
            pass
        except:
            self.DistributedCatchGameAI_initialized = 1
            DistributedMinigameAI.__init__(self, air, minigameId)
            self.gameFSM = ClassicFSM.ClassicFSM('DistributedCatchGameAI', [
                State.State('inactive', self.enterInactive, self.exitInactive, [
                    'play']),
                State.State('play', self.enterPlay, self.exitPlay, [
                    'cleanup']),
                State.State('cleanup', self.enterCleanup, self.exitCleanup, [
                    'inactive'])], 'inactive', 'inactive')
            self.addChildGameFSM(self.gameFSM)


    
    def generate(self):
        self.notify.debug('generate')
        DistributedMinigameAI.generate(self)

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

    
    def setGameReady(self):
        self.notify.debug('setGameReady')
        DistributedMinigameAI.setGameReady(self)

    
    def setGameStart(self, timestamp):
        self.notify.debug('setGameStart')
        DistributedMinigameAI.setGameStart(self, timestamp)
        self.gameFSM.request('play')

    
    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.notify.debug('fruits: %s, fruits caught: %s' % (self.numFruits, self.fruitsCaught))
        perfect = self.fruitsCaught >= self.numFruits
        for avId in self.avIdList:
            self.scoreDict[avId] = max(1, int(self.scoreDict[avId] / 2))
            if perfect:
                self.notify.debug('PERFECT GAME!')
                self.scoreDict[avId] += round(self.numFruits / 4.0)
                self.logAllPerfect()
                continue
        
        self.gameFSM.request('cleanup')
        DistributedMinigameAI.gameOver(self)

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

    
    def exitInactive(self):
        pass

    
    def enter 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python battle.BattleExperienceAI类代码示例发布时间:2022-05-27
下一篇:
Python utils.raises函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap