Exemplo n.º 1
0
def main():
    board = Board()
    board.print()

    print()
    print('LETS PLAY CHESS IN TERMINAL')
    print('===')
    print('Передвинуть фигуру: move <x1> <y1> <x2> <y2>')
    print('Выйти из игры:      exit')

    while True:
        if board.current_color == Color.WHITE:
            print('Ход белых')
        else:
            print('Ход черных')

        command = input('Введите команду: ')
        if command == 'exit':
            return
        
        command = command.split()
        col, row, col_new, row_new = map(int, command[1:])
        
        if board.can_move(row, col, row_new, col_new):
            board.move(row, col, row_new, col_new)
            board.change_color()
            board.print()
Exemplo n.º 2
0
def test_cant_move_no_figure():
    board = Board()
    assert not board.can_move(5, 5, 5, 5)
Exemplo n.º 3
0
def test_cant_move_wrong_command():
    board = Board()
    assert not board.can_move(10, 10, 0, 0)
Exemplo n.º 4
0
def test_cant_move_same_place():
    board = Board()
    assert not board.can_move(0, 0, 0, 0)
Exemplo n.º 5
0
def test_cant_move_wrong_knight():
    board = Board()
    assert not board.can_move(0, 1, 2, 1)