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")
Exemple #2
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")