-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
80 lines (71 loc) · 2.15 KB
/
utils.py
File metadata and controls
80 lines (71 loc) · 2.15 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
__doc__ = ''' Utilildades de uso común.
- Limpiar pantalla.
- Colorear pantalla.
- Mensaje de bienvenida.
- Testeo de Colorama.
'''
import os
from colorama import init, deinit, Fore, Back, Style
def clrscr():
''' Limpiar pantalla, testeado en Windows & Linux '''
# for mac and linux(here, os.name is 'posix')
if os.name == 'posix':
_ = os.system('clear')
else:
# for windows platfrom
_ = os.system('cls')
def pintar(color='', fondo='', texto=''):
'''
pintar los elementos
'''
colores = {'AZUL':Fore.BLUE}
fondos = {'AZUL':Back.BLUE}
if color and fondo:
print(colores[color] + fondos[fondo] + texto)
elif color and not fondo:
print(colores[color] + texto)
elif not color and fondo:
print(fondos[fondo] + texto)
else:
print(texto)
def paint(fore='', back='', text='', style=''):
''' Esto nunca se usó '''
print(fore+back+text+style)
def welcomeMsg():
''' Mensaje de bienvenida y explicación del juego '''
clrscr()
msg = ['¡Welcome to \x1b[31m\x1b[40mCLI Ball Sort\x1b[0m,',
'the game of sorting items!\n',
' ◆ ◇ -\n'*3+
' — — —',
' 1° 2° 3°\n',
'\x1b[21mHow to play\x1b[0m',
'You must move the elements at the top of the columns over other matching elements or over empty columns.',
'Note that columns have a maximum number of elements.',
'\x1b[6m •- - ↴ \x1b[0m',
' ◇ . .',
' ◆ ◇ .',
' ◆ ◇ .',
' — — —',
' 1° 2° 3°',
'Sort each column with a unique element to win.',
'That\'s all so let\'s start!\n',
'\x1b[6mPress ENTER to start.\x1b[0m\n'
]
input('\n'.join(msg))
def coloramatest():
for i in range(120):
if i%10:
text = f'{i}) \x1b[{i}mtext '
text = text.rjust(10)
print(text, end='')
else:
print(f'{i}) \x1b[{i}mtext '.rjust(10))
def ttychars():
print(chr(402))
for i in range(500):
print(f'{i} {chr(i)} ',end='')
if i % 20 == 0:
print('')
input('\n\n')
init(autoreset=True)