コード例 #1
0
ファイル: main.py プロジェクト: forcella/crazyoldlaygame
def up_and_down_check(board, position: Position):
    y = position.col - 1
    x = position.line - 1
    try:
        first_position: Position = board[(x - 1) - len(board)][y]
        second_position: Position = board[(x - 2) - len(board)][y]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass
    try:
        first_position: Position = board[x + 1][y]
        second_position: Position = board[x + 2][y]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass
    return False
コード例 #2
0
ファイル: main.py プロジェクト: forcella/crazyoldlaygame
def plus_sing_check(board, position: Position):
    y = position.col - 1
    x = position.line - 1
    try:
        first_position: Position = board[x + 1][y]
        second_position: Position = board[(x - 1) - len(board)][y]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass
    try:
        first_position: Position = board[x][(y - 1) - len(board)]
        second_position: Position = board[x][y + 1]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass
    return False
コード例 #3
0
ファイル: main.py プロジェクト: forcella/crazyoldlaygame
def vertical_check(board, position: Position):
    y = position.col - 1
    x = position.line - 1
    # vertical down right
    try:
        first_position: Position = board[x + 1][y + 1]
        second_position: Position = board[x + 2][y + 2]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    # vertical down left
    try:
        first_position: Position = board[x + 1][(y - 1) - len(board)]
        second_position: Position = board[x + 2][(y - 2) - len(board)]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    # vertical up left
    try:
        first_position: Position = board[(x - 1) - len(board)][(y - 1) -
                                                               len(board)]
        second_position: Position = board[(x - 2 - len(board))][(y - 2) -
                                                                len(board)]

        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    # Vertical up right
    try:
        first_position: Position = board[(x - 1) - len(board)][y + 1]
        second_position: Position = board[(x - 2) - len(board)][y + 2]

        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    return False
コード例 #4
0
ファイル: main.py プロジェクト: forcella/crazyoldlaygame
def right_and_left_check(board, position: Position):
    y = position.col - 1
    x = position.line - 1

    try:
        first_position: Position = board[x][y + 1]
        second_position: Position = board[x][y + 2]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    try:
        first_position: Position = board[x][(y - 1) - len(board)]
        second_position: Position = board[x][(y - 2) - len(board)]
        if position.check_player_eq(first_position, second_position):
            return True
    except IndexError:
        pass

    return False