Ejemplo n.º 1
0
    def __init__(self, host, port, debug):
        Logger.__init__(self, "server")
        self.config = Config()
        self.host = host
        self.port = port
        self.debug_mode = debug

        self.network_server = AsyncServer(self, host, port)

        # address => Client object
        self.clients = {}

        # name (unicode) => Player object
        self.players = DictWithID(MAX_PLAYER_ID)

        # identifier (unicode) => Game objet
        self.games = DictWithID(MAX_GAME_ID)

        # ip => IPStatistics object
        self.ip_stats = {}

        self.services = {}
        for attrname in dir(self):
            attr = getattr(self, attrname)
            if not is_service(attr):
                continue
            func = attr
            name = func.__name__
            self.services[name] = func

        self.game_classes = {
            u'awale': Awale,
            u'chess': Chess,
            u'1000 bornes': MilleBornes,
        }
Ejemplo n.º 2
0
 def __init__(self, server, handler, address):
     Logger.__init__(self, "client %s:%s" % (address[0], address[1]))
     self.server = server
     self.handler = handler
     self.address = address
     self.players = {}
     self.connected = True
     self.support_async = False
Ejemplo n.º 3
0
    def __init__(self, username, password, host, port):
        Logger.__init__(self, "server")
        JabberBot.__init__(self, username, password)
        self.client = AsyncClient()
        self.client.connect(host, port)

        self.players = {} # identifier => JabberPlayer object
        self._jid2player = {} # jid => JabberPlayer object
Ejemplo n.º 4
0
 def __init__(self, server, identifier, player, label):
     Logger.__init__(self, 'game #%s' % identifier)
     self.server = server
     self.identifier = identifier
     self.label = label
     self.owner = player
     self.players = []
     self.observers = []
     self._player2index = {}
     self.state = WAITING
     self.min_players = 1
     self.max_players = 1
     self.addPlayer(player)
     self.error('%s created the game "%s".' % (player, label))