Exemple #1
0
    def startClicked(self, button):
        color = self.widgets["colorDock"].get_child().active
        if color == 2:
            color = random.choice([WHITE, BLACK])
        opponent = self.widgets["opponentDock"].get_child().active
        difficulty = int(self.widgets["skillSlider"].get_value())

        gamemodel = GameModel(TimeModel(5 * 60, 0))

        name = conf.get("firstName", _("You"))
        player0tup = (LOCAL, Human, (color, name), name)
        if opponent == 0:
            name = conf.get("secondName", _("Guest"))
            player1tup = (LOCAL, Human, (1 - color, name), name)
        else:
            engine = discoverer.getEngineN(opponent - 1)
            name = discoverer.getName(engine)
            player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, 1 - color, difficulty,
                           variants[NORMALCHESS], 5 * 60, 0), name)

        if color == WHITE:
            ionest.generalStart(gamemodel, player0tup, player1tup)
        else:
            ionest.generalStart(gamemodel, player1tup, player0tup)
    def startClicked(self, button):
        color = self.widgets["colorDock"].get_child().active
        if color == 2:
            color = random.choice([WHITE, BLACK])
        opponent = self.widgets["opponentDock"].get_child().active
        difficulty = int(self.widgets["skillSlider"].get_value())

        gamemodel = GameModel(TimeModel(5 * 60, 0))

        name = conf.get("firstName", _("You"))
        player0tup = (LOCAL, Human, (color, name), name)
        if opponent == 0:
            name = conf.get("secondName", _("Guest"))
            player1tup = (LOCAL, Human, (1 - color, name), name)
        else:
            engine = discoverer.getEngineN(opponent - 1)
            name = discoverer.getName(engine)
            player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, 1 - color, difficulty,
                           variants[NORMALCHESS], 5 * 60, 0), name)

        if color == WHITE:
            ionest.generalStart(gamemodel, player0tup, player1tup)
        else:
            ionest.generalStart(gamemodel, player1tup, player0tup)
Exemple #3
0
def createRematch (gamemodel):
    """ If gamemodel contains only LOCAL or ARTIFICIAL players, this starts a
        new game, based on the info in gamemodel """

    if gamemodel.timed:
        secs = gamemodel.timemodel.intervals[0][WHITE]
        gain = gamemodel.timemodel.gain
    else:
        secs = 0
        gain = 0
    newgamemodel = GameModel(TimeModel(secs, gain), variant=gamemodel.variant)

    wp = gamemodel.players[WHITE]
    bp = gamemodel.players[BLACK]

    if wp.__type__ == LOCAL:
        player1tup = (wp.__type__, wp.__class__, (BLACK, repr(wp)), repr(wp))
        if bp.__type__ == LOCAL:
            player0tup = (bp.__type__, bp.__class__, (WHITE, repr(wp)), repr(bp))
        else:
            engine = discoverer.getEngineByMd5(bp.md5)
            player0tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, WHITE, bp.strength, gamemodel.variant,
                           secs, gain), repr(bp))
    else:
        player0tup = (bp.__type__, bp.__class__, (WHITE, repr(bp)), repr(bp))
        engine = discoverer.getEngineByMd5(wp.md5)
        player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                      (engine, BLACK, wp.strength, gamemodel.variant,
                       secs, gain), repr(wp))

    ionest.generalStart(newgamemodel, player0tup, player1tup)
Exemple #4
0
def createRematch(gamemodel):
    """ If gamemodel contains only LOCAL or ARTIFICIAL players, this starts a
        new game, based on the info in gamemodel """

    if gamemodel.timed:
        secs = gamemodel.timemodel.intervals[0][WHITE]
        gain = gamemodel.timemodel.gain
    else:
        secs = 0
        gain = 0
    newgamemodel = GameModel(TimeModel(secs, gain), variant=gamemodel.variant)

    wp = gamemodel.players[WHITE]
    bp = gamemodel.players[BLACK]

    if wp.__type__ == LOCAL:
        player1tup = (wp.__type__, wp.__class__, (BLACK, repr(wp)), repr(wp))
        if bp.__type__ == LOCAL:
            player0tup = (bp.__type__, bp.__class__, (WHITE, repr(wp)),
                          repr(bp))
        else:
            engine = discoverer.getEngineByMd5(bp.md5)
            player0tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (engine, WHITE, bp.strength, gamemodel.variant, secs,
                           gain), repr(bp))
    else:
        player0tup = (bp.__type__, bp.__class__, (WHITE, repr(bp)), repr(bp))
        engine = discoverer.getEngineByMd5(wp.md5)
        player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                      (engine, BLACK, wp.strength, gamemodel.variant, secs,
                       gain), repr(wp))

    ionest.generalStart(newgamemodel, player0tup, player1tup)
Exemple #5
0
 def _callback (gamemodel, p0, p1):
     if not cls.loadSidePanel.isEmpty():
         uri =  cls.loadSidePanel.get_filename()
         loader = ionest.enddir[uri[uri.rfind(".")+1:]]
         position = cls.loadSidePanel.getPosition()
         gameno = cls.loadSidePanel.getGameno()
         ionest.generalStart(gamemodel, p0, p1, (uri, loader, gameno, position))
     else:
         ionest.generalStart(gamemodel, p0, p1)
Exemple #6
0
 def _callback (gamemodel, p0, p1):
     if not cls.loadSidePanel.is_empty():
         uri =  cls.loadSidePanel.get_filename()
         loader = ionest.enddir[uri[uri.rfind(".")+1:]]
         position = cls.loadSidePanel.get_position()
         gameno = cls.loadSidePanel.get_gameno()
         ionest.generalStart(gamemodel, p0, p1, (uri, loader, gameno, position))
     else:
         ionest.generalStart(gamemodel, p0, p1)
Exemple #7
0
def loadFilesAndRun(uris):
    for uri in uris:
        loader = ionest.enddir[uri[uri.rfind(".") + 1:]]
        timemodel = TimeModel(0, 0)
        gamemodel = GameModel(timemodel)
        white_name = _("White")
        black_name = _("Black")
        p0 = (LOCAL, Human, (WHITE, white_name), white_name)
        p1 = (LOCAL, Human, (BLACK, black_name), black_name)
        ionest.generalStart(gamemodel, p0, p1, (uri, loader, 0, -1))
Exemple #8
0
def loadFilesAndRun(uris):
    for uri in uris:
        uri = splitUri(uri)[1]
        loader = ionest.enddir[uri[uri.rfind(".") + 1:]]
        timemodel = TimeModel(0, 0)
        gamemodel = GameModel(timemodel)
        white_name = _("White")
        black_name = _("Black")
        p0 = (LOCAL, Human, (WHITE, white_name), white_name)
        p1 = (LOCAL, Human, (BLACK, black_name), black_name)
        ionest.generalStart(gamemodel, p0, p1, (uri, loader, 0, -1))
Exemple #9
0
        def _callback (gamemodel, p0, p1):
            text = cls.sourcebuffer.get_text(
                cls.sourcebuffer.get_start_iter(), cls.sourcebuffer.get_end_iter())

            # Test if the ImageButton has two layers and is set on the local language
            if len(cls.ib.surfaces) == 2 and cls.ib.current == 0:
                # 2 step used to avoid backtranslating
                # (local and english piece letters can overlap)
                for i, sign in enumerate(localReprSign[1:]):
                    if sign.strip():
                        text = text.replace(sign, FAN_PIECES[0][i+1])
                for i, sign in enumerate(FAN_PIECES[0][1:7]):
                    text = text.replace(sign, reprSign[i+1])
                text = str(text)

            ionest.generalStart(gamemodel, p0, p1, (StringIO(text), pgn, 0, -1))
Exemple #10
0
    def row_activated (self, widget, path, col):
        print(self.modelsort.convert_path_to_child_path(path)[0])
        game_id = self.liststore[self.modelsort.convert_path_to_child_path(path)[0]][0]
        print("game_id=%s" % game_id)
        gameno = self.id_list.index(game_id)
        print("gameno=%s" % gameno)
        position = -1

        gamemodel = GameModel()
        wp, bp = self.chessfile.get_player_names(gameno)
        p0 = (LOCAL, Human, (WHITE, wp), wp)
        p1 = (LOCAL, Human, (BLACK, bp), bp)
        self.chessfile.loadToModel(gameno, -1, gamemodel)

        gamemodel.status = WAITING_TO_START
        ionest.generalStart(gamemodel, p0, p1)
Exemple #11
0
    def row_activated(self, widget, path, col):
        print(self.modelsort.convert_path_to_child_path(path)[0])
        game_id = self.liststore[self.modelsort.convert_path_to_child_path(
            path)[0]][0]
        print("game_id=%s" % game_id)
        gameno = self.id_list.index(game_id)
        print("gameno=%s" % gameno)

        gamemodel = GameModel()
        wp, bp = self.chessfile.get_player_names(gameno)
        p0 = (LOCAL, Human, (WHITE, wp), wp)
        p1 = (LOCAL, Human, (BLACK, bp), bp)
        self.chessfile.loadToModel(gameno, -1, gamemodel)

        gamemodel.status = WAITING_TO_START
        ionest.generalStart(gamemodel, p0, p1)
Exemple #12
0
def createRematch (gamemodel):
    if gamemodel.timemodel:
        secs = gamemodel.timemodel.intervals[0][WHITE]
        gain = gamemodel.timemodel.gain
        newgamemodel = GameModel(TimeModel(secs, gain), gamemodel.variant)
    else:
        secs = 0
        gain = 0
        newgamemodel = GameModel(variant=gamemodel.variant)

    wp = gamemodel.players[WHITE]
    bp = gamemodel.players[BLACK]

    if wp.__type__ == LOCAL:
        player1tup = (wp.__type__, wp.__class__, (BLACK, ""), repr(wp))
        if bp.__type__ == LOCAL:
            player0tup = (bp.__type__, bp.__class__, (WHITE, ""), repr(bp))
        else:
            binname = bp.engine.path.split("/")[-1]
            if binname == "python":
                binname = bp.engine.args[1].split("/")[-1]
            xmlengine = discoverer.getEngines()[binname]
            player0tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                          (xmlengine, WHITE, bp.strength, gamemodel.variant,
                           secs, gain), repr(bp))
    else:
        player0tup = (bp.__type__, bp.__class__, (WHITE, ""), repr(bp))
        binname = wp.engine.path.split("/")[-1]
        if binname == "python":
            binname = wp.engine.args[1].split("/")[-1]
        xmlengine = discoverer.getEngines()[binname]
        player1tup = (ARTIFICIAL, discoverer.initPlayerEngine,
                      (xmlengine, BLACK, wp.strength, gamemodel.variant,
                       secs, gain), repr(wp))

    ionest.generalStart(newgamemodel, player0tup, player1tup)
Exemple #13
0
 def _callback (gamemodel, p0, p1):
     text, loadType = _get_text()
     ionest.generalStart(gamemodel, p0, p1, (StringIO(text), loadType, 0, -1))
Exemple #14
0
 def _callback (gamemodel, p0, p1):
     text = cls.get_fen()
     ionest.generalStart(gamemodel, p0, p1, (StringIO(text), fen, 0, -1))
Exemple #15
0
 def _callback(gamemodel, p0, p1):
     text, loadType = _get_text()
     ionest.generalStart(gamemodel, p0, p1,
                         (StringIO(text), loadType, 0, -1))
Exemple #16
0
 def _callback(gamemodel, p0, p1):
     text = cls.get_fen()
     ionest.generalStart(gamemodel, p0, p1,
                         (StringIO(text), fen, 0, -1))