Skip to content

Commit e1c428a

Browse files
author
muj-programmer
committed
refactored code
1 parent 9456ba9 commit e1c428a

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

main.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
from time import sleep
55
from utils.cursor import Cursor
66
from utils.input import print_dummy_board, clear, validate
7-
from utils.board import print_board, print_input_line, update_board, place_knight
7+
from utils.board import print_board, update_board
88

99

10-
def visualize(stdscr, pos: Tuple[int]) -> None:
10+
def visualize(stdscr, pos: Tuple[int, int]) -> None:
1111
# clear the window
1212
stdscr.clear()
1313

@@ -32,19 +32,11 @@ def visualize(stdscr, pos: Tuple[int]) -> None:
3232
# initialize the cursor
3333
cursor: Cursor = Cursor(max_x, max_y)
3434

35-
# print the chess board
36-
print_board(stdscr, cursor, board, sleep_value=0.0)
37-
38-
# print input line
39-
input: str = print_input_line(stdscr, cursor)
40-
4135
# place the knight on the board
42-
place_knight(input, board)
36+
board[pos[0]][pos[1]] = 2
4337

44-
cursor.reset_x()
45-
cursor.reset_y()
46-
47-
print_board(stdscr, cursor, board, sleep_value=1.0, progress=True)
38+
# print the chess board
39+
print_board(stdscr, cursor, board, sleep_value=1.0)
4840

4941
for row in range(8):
5042
for col in range(8):
@@ -58,7 +50,6 @@ def main() -> None:
5850
init(autoreset=True)
5951

6052
while True:
61-
# clears the console
6253
clear()
6354

6455
# print dummy chess board to help user decide knight's position
@@ -73,8 +64,10 @@ def main() -> None:
7364
print(Fore.RED + 'Invalid, Try Again.')
7465
sleep(1)
7566

76-
# start visualization
77-
curses.wrapper(visualize, tuple(map(int, pos.split(','))))
67+
# start visualization
68+
curses.wrapper(visualize, tuple(map(int, pos.split(','))))
69+
70+
clear()
7871

7972

8073
if __name__ == '__main__':

0 commit comments

Comments
 (0)