Ejemplo n.º 1
0
def readingFileLoop(mainWindow):
    # time.sleep(1)
    global blackPlayer
    global whitePlayer
    global moovesTotal

    pieceComeBack = ""
    read = readFile()
    player = ""

    if read.find("[END]") != -1:
        popUpEnd(read, mainWindow)
        return
    if blackPlayer == 2:
        blackPlayer = 3
        writeFile("[TURN] WHITE")
        drawBoard.playerToPlay = "WHITE"
    elif read == "START":
        option.players += 1
        if whitePlayer == 0:
            writeFile("[NEW] WHITE")
            whitePlayer = 1
        elif blackPlayer == 0:
            writeFile("[NEW] BLACK")
            blackPlayer = 2
    elif read.find("[PLAY]") != -1:
        if debug == 1:
            input("Press key")
        if read.find("[PLAY] WHITE") != -1:
            player = "WHITE"
        elif read.find("[PLAY] BLACK") != -1:
            player = "BLACK"
        read2 = read.split()
        lastMoove = read2[2][0] + read2[2][1] + read2[2][2] + read2[2][3]

        if len(read2[2]) > 4:
            end = modifyGameBoard(
                gab.getArrayNumber(int(read2[2][1])) - 1,
                gab.getArrayLetter(read2[2][0]),
                gab.getArrayNumber(int(read2[2][3])) - 1,
                gab.getArrayLetter(read2[2][2]), player, read2[2][4])
            pieceComeBack = read2[2][4]
        else:
            end = modifyGameBoard(
                gab.getArrayNumber(int(read2[2][1])) - 1,
                gab.getArrayLetter(read2[2][0]),
                gab.getArrayNumber(int(read2[2][3])) - 1,
                gab.getArrayLetter(read2[2][2]), player)
        option.board = gameBoard
        turnManager(pieceComeBack, end, read, lastMoove)
Ejemplo n.º 2
0
def getPathOfPiece(i, board):
    piece = board[getArrayBoard.getArrayNumber(int(i[1])) -
                  1][getArrayBoard.getArrayLetter(i[0])]
    if piece == "c" or piece == "C" or piece == "r" or piece == "R":
        return []
    letterCounter = 0
    numberCounter = 0
    arrayPath = []
    if i[0] < i[3]:
        letterCounter = 1
    elif i[0] > i[3]:
        letterCounter = -1

    if int(i[1]) < int(i[4]):
        numberCounter = 1
    elif int(i[1]) > int(i[4]):
        numberCounter = -1
    end = i[3] + i[4]
    path = i[0] + i[1]
    while path != end:
        tmp = path
        path = chr(ord(tmp[0]) + letterCounter)
        path += str(int(tmp[1]) + numberCounter)
        arrayPath.append(path)
    arrayPath.pop()
    return arrayPath
Ejemplo n.º 3
0
def getPiece(board, x, y):
    return board[getArrayBoard.getArrayNumber(y) - 1][x - 1]