예제 #1
0
 def _connected(self):
     # Register our channel
     self.setConnectionName(self.districtName)
     AIRepository._connected(self)
     self.registerShardDownMessage(self.serverId)
     if self.districtType is not None:
         self.fsm.request("districtReset")
예제 #2
0
 def exitPlayGame(self):
     if ConfigVariableBool('game-server-tests', 0).getValue():
         self.testObject.requestDelete()
         del self.testObject
     self._zoneDataStore.destroy()
     del self._zoneDataStore
     taskMgr.remove(self.uniqueName("printPopulationTask"))
     AIRepository.exitPlayGame(self)
예제 #3
0
 def exitPlayGame(self):
     if simbase.config.GetBool('game-server-tests', 0):
         self.testObject.requestDelete()
         del self.testObject
     self._zoneDataStore.destroy()
     del self._zoneDataStore
     taskMgr.remove(self.uniqueName("printPopulationTask"))
     AIRepository.exitPlayGame(self)
예제 #4
0
 def _connected(self):
     """
     Callback for when we successfully connect to the otp_server cluster.
     """
     self.setConnectionName("UberDog")
     AIRepository._connected(self)
     # Listen for Account and Avatar online/offline messages
     self.registerForChannel(CHANNEL_PUPPET_ACTION)
     self.fsm.request("playGame")
예제 #5
0
    def enterPlayGame(self):
        self._zoneDataStore = AIZoneDataStore()
        AIRepository.enterPlayGame(self)
        if ConfigVariableBool('game-server-tests', 0).getValue():
            from otp.distributed import DistributedTestObjectAI
            self.testObject = DistributedTestObjectAI.DistributedTestObjectAI(self)
            self.testObject.generateOtpObject(self.getGameDoId(), 3)

        taskMgr.doMethodLater(300, self.printPopulationToLog, self.uniqueName("printPopulationTask"))
예제 #6
0
 def deleteObject(self, doId):
     """
     Ask for the object to be removed from the private
     distributed object cache.
     """
     assert False, 'JCW: Testing for obsolete functions. If this crashes, let Josh know'
     if self.doId2doCache.had_key(doId):
         self.unregisterForChannel(doId)
         #self.deleteObject(doId)
         del self.doId2doCache[doId]
     #HACK:
     self.unregisterForChannel(doId)
     AIRepository.deleteObject(self.doId)
예제 #7
0
    def __init__(self, mdip, mdport, esip, esport, dcFileNames, serverId,
                 minChannel, maxChannel):
        AIRepository.__init__(self,
                              mdip,
                              mdport,
                              esip,
                              esport,
                              dcFileNames,
                              serverId,
                              minChannel,
                              maxChannel,
                              dcSuffix='UD')

        # We're responsible for keeping track of who's online with which avatar
        self.onlineAccountDetails = {}
        self.onlineAvatars = {}
        self.onlinePlayers = {}

        self.pending = {}
        self.doId2doCache = {}

        if hasattr(self, 'setVerbose'):
            if self.config.GetBool('verbose-uberrepository'):
                self.setVerbose(1)

        # The AI State machine
        self.fsm = ClassicFSM(
            'UberDog',
            [
                State('off', self.enterOff, self.exitOff, ['connect']),
                State('connect', self.enterConnect, self.exitConnect, [
                    'noConnection',
                    'playGame',
                ]),
                State('playGame', self.enterPlayGame, self.exitPlayGame,
                      ['noConnection']),
                State('noConnection', self.enterNoConnection,
                      self.exitNoConnection, ['connect'])
            ],
            # initial state
            'off',
            # final state
            'off',
        )
        self.fsm.enterInitialState()
        self.fsm.request("connect")
예제 #8
0
    def readerPollUntilEmpty(self, task):
        # This overrides AIRepository.readerPollUntilEmpty()
        # to provide an additional debugging hook.

        while self._debugDisconnectIds:
            avId = self._debugDisconnectIds.pop()
            self._doDebugDisconnectAvatar(avId)

        try:
            return AIRepository.readerPollUntilEmpty(self, task)
        except Exception as e:
            appendStr(e, '\nSENDER ID: %s' % self.getAvatarIdFromSender())
            raise
예제 #9
0
    def __init__(
            self, mdip, mdport, esip, esport, dcFileNames,
            districtId, districtName, districtType, serverId,
            minChannel, maxChannel, dcSuffix = 'AI'):
        assert self.notify.debugStateCall(self)

        # Save the district Id (needed for calculations in AIRepository code)
        self.districtId = districtId
        self.districtName = districtName
        self.districtType = districtType

        AIRepository.__init__(
            self, mdip, mdport, esip, esport, dcFileNames,
            serverId,
            minChannel, maxChannel, dcSuffix)
        self.setClientDatagram(0)
        assert minChannel > districtId
        if hasattr(self, 'setVerbose'):
            if ConfigVariableBool('verbose-airepository', 0).getValue():
                self.setVerbose(1)

        # Save the state server id
        self.serverId = serverId

        # Record the reason each client leaves the shard, according to
        # the client.
        self._avatarDisconnectReasons = {}

        # A list of avIds to pretend to disconnect at the next poll
        # cycle, for debugging purposes only.
        self._debugDisconnectIds = []

        # player avatars will increment and decrement this count
        self._population = 0

        # The AI State machine
        self.fsm = ClassicFSM.ClassicFSM('AIDistrict',
                       [State.State('off',
                                    self.enterOff,
                                    self.exitOff,
                                    ['connect']),
                        State.State('connect',
                                    self.enterConnect,
                                    self.exitConnect,
                                    ['districtReset', 'noConnection',
                                     # I added this because Skyler removed the transition to
                                     # districtReset -- Joe
                                     'playGame',
                                     ]),
                        State.State('districtReset',
                                    self.enterDistrictReset,
                                    self.exitDistrictReset,
                                    ['playGame','noConnection']),
                        State.State('playGame',
                                    self.enterPlayGame,
                                    self.exitPlayGame,
                                    ['noConnection']),
                        State.State('noConnection',
                                    self.enterNoConnection,
                                    self.exitNoConnection,
                                    ['connect'])],
                       # initial state
                       'off',
                       # final state
                       'off',
                       )

        self.fsm.enterInitialState()

        self.fsm.request("connect")
예제 #10
0
 def writeServerEvent(self, eventType, who, description):
     AIRepository.writeServerEvent(self, eventType, who, description, serverId=self.districtId)