-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsquare.py
72 lines (64 loc) · 2.4 KB
/
square.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
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
import pieces
import platform
import globVar
import colors
# a_block = colors.A_BLOCK_STD
# u_block = u'\u2588\u2588'
class Square:
"""
The Square class contains a piece and data such as color,
position, and several boolean values.
"""
def __init__(self, pieceStatus, color, piece, row, col):
self.pieceStatus = pieceStatus
self.color = color
self.piece = piece
self.row = row
self.col = col
self.des = False
self.option = 0
def __str__(self):
a_block = colors.BLOCK_STD
u_block = " "
out = ""
if self.des:
if globVar.unicode or globVar.limited_unicode:
out += colors.BRIGHT_GREEN_FG
if self.pieceStatus and self.option < 10:
out += str(self.piece)
if globVar.unicode or globVar.limited_unicode:
out += colors.BRIGHT_MAGENTA_FG
elif self.pieceStatus and (globVar.unicode or globVar.limited_unicode): # clean this up
out += colors.BRIGHT_MAGENTA_FG
elif self.option < 10:
out += " "
out += str(self.option)
elif self.pieceStatus:
out += str(self.piece)
if self.piece.selected:
if globVar.unicode:
out += colors.SELECTED_UNICODE
out = colors.blink_ansi(out)
else:
out += colors.SELECTED_STD
else:
if self.piece.color == "W":
out += colors.UP_UNICODE if globVar.unicode else colors.UP_STD
elif self.piece.color == "b":
out += colors.DOWN_UNICODE if globVar.unicode else colors.DOWN_STD
else:
out += " "
if not globVar.unicode and self.color == "black" and not globVar.limited_unicode:
out = a_block
if globVar.unicode:
if self.color == "black":
out = colors.color_bg_only(colors.Brown, out)
else:
out = colors.color_bg_only(colors.Tan, out)
elif globVar.limited_unicode:
temp_out = ""
if self.color == "black":
out = colors.BLOCK_BLACK_LIM + out
else:
out = colors.BLOCK_WHITE_LIM + out
return out