-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
27 lines (20 loc) · 872 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import time
import re
from resources import generate_title, colors
def clear_screen(): os.system('cls' if os.name == 'nt' else 'clear')
def update_screen(board, cursor=[0, 0]):
clear_screen()
print(generate_title(), sep="")
for y_i, y in enumerate(reversed(board)):
for x_i, x in enumerate(y):
if x_i == 0:
print(" " * 14, colors[6], "|", colors[0], sep='', end="")
if(cursor[0] == (len(board)-y_i-1) and cursor[1] == x_i):
x = "\033[5m" + x.replace(" ", "[", 1) + "\033[0m"
elif(cursor[0] == (len(board)-y_i-1) and cursor[1] + 1 == x_i):
x = "\033[5m" + re.sub(r" [^ ]*$", "]", x) + "\033[0m"
print(x, sep='', end="")
if x_i == len(board[0])-1:
print(colors[6], "|", colors[0], sep='', end="")
print()