Ejemplo n.º 1
0
    def makeReady(self):
        signal.signal(signal.SIGINT, Gtk.main_quit)

        PyChess.makeReady(self)

        self.connection = FICSMainConnection("freechess.org", self.ports,
                                             self.username, self.password)
        self.connection.connect("connectingMsg", self.__showConnectLog)
        self.connection._connect()

        self.connection.glm.connect("addPlayer", self.__onAddPlayer)
        self.connection.glm.connect("removePlayer", self.__onRemovePlayer)
        self.connection.cm.connect("privateMessage", self.__onTell)
        self.connection.alm.connect("logOut", self.__onLogOut)
        self.connection.bm.connect("playGameCreated", self.__onGameCreated)
        self.connection.bm.connect("curGameEnded", self.__onGameEnded)
        self.connection.bm.connect("boardUpdate", self.__onBoardUpdate)
        self.connection.om.connect("onChallengeAdd", self.__onChallengeAdd)
        self.connection.om.connect("onOfferAdd", self.__onOfferAdd)
        self.connection.adm.connect("onAdjournmentsList",
                                    self.__onAdjournmentsList)
        self.connection.em.connect("onAmbiguousMove", self.__onAmbiguousMove)
        self.connection.em.connect("onIllegalMove", self.__onAmbiguousMove)

        self.connection.adm.queryAdjournments()
        self.connection.lvm.setVariable("autoflag", 1)

        self.connection.fm.setFingerNote(
            1, "PyChess is the chess engine bundled with the PyChess %s " %
            pychess.VERSION +
            "chess client. This instance is owned by %s, but acts " %
            self.owner + "quite autonomously.")

        self.connection.fm.setFingerNote(
            2,
            "PyChess is 100% Python code and is released under the terms of " +
            "the GPL. The evalution function is largely equal to the one of" +
            "GnuChess, but it plays quite differently.")

        self.connection.fm.setFingerNote(
            3,
            "PyChess runs on an elderly AMD Sempron(tm) Processor 3200+, 512 "
            +
            "MB DDR2 Ram, but is built to take use of 64bit calculating when "
            + "accessible, through the gpm library.")

        self.connection.fm.setFingerNote(
            4,
            "PyChess uses a small 500 KB openingbook based solely on Kasparov "
            +
            "games. The engine doesn't have much endgame knowledge, but might "
            + "in some cases access an online endgamedatabase.")

        self.connection.fm.setFingerNote(
            5,
            "PyChess will allow any pause/resume and adjourn wishes, but will "
            + "deny takebacks. Draw, abort and switch offers are accepted, " +
            "if they are found to be an advance. Flag is auto called, but " +
            "PyChess never resigns. We don't want you to forget your basic " +
            "mating skills.")
Ejemplo n.º 2
0
    def onConnectClicked(self, button):
        self.canceled = False
        self.widgets["messagePanel"].hide()

        if self.widgets["logOnAsGuest"].get_active():
            username = self.widgets["nameEntry"].get_text()
            password = ""
        else:
            username = self.widgets["nameEntry"].get_text()
            password = self.widgets["passEntry"].get_text()

        if port:
            ports = (port, )
        else:
            ports = self.widgets["portsEntry"].get_text()
            ports = list(map(int, re.findall("\d+", ports)))
            if 5000 not in ports:
                ports.append(5000)
            if 23 not in ports:
                ports.append(23)
        alternate_host = self.widgets["hostEntry"].get_text()

        timeseal = self.widgets["timesealCheck"].get_active()

        self.showConnecting()
        self.host = (host if host is not None else
                     alternate_host if alternate_host else "freechess.org")
        self.connection = FICSMainConnection(self.host, ports, timeseal,
                                             username, password)
        for signal, callback in (
            ("connected", self.onConnected),
            ("error", self.onConnectionError),
            ("connectingMsg", self.showMessage),
        ):
            self.cids[self.connection].append(
                self.connection.connect(signal, callback))
        self.main_connected_event = asyncio.Event()
        self.connection_task = create_task(self.connection.start())

        # guest users are rather limited on ICC (helper connection is useless)
        if self.host not in ("localhost", "127.0.0.1", "chessclub.com"):
            self.helperconn = FICSHelperConnection(self.connection, self.host,
                                                   ports, timeseal)
            self.helperconn.connect("error", self.onHelperConnectionError)

            @asyncio.coroutine
            def coro():
                yield from self.main_connected_event.wait()
                yield from self.helperconn.start()

            self.helperconn_task = create_task(coro())