-
Notifications
You must be signed in to change notification settings - Fork 1
/
BoardCell.py
51 lines (33 loc) · 1.06 KB
/
BoardCell.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
from Constants import *
from Piece import *
class BoardCell:
def __init__(self, x, y):
self.x = x
self.y = y
self.piece = None
self.movable = False
self.attackable = False
self.visited = False
self.selected = False
def placePiece(self, piece):
temp = self.piece
self.piece = piece
self.piece.x = self.x
self.piece.y = self.y
return temp
def unmark(self):
self.movable = False
self.attackable = False
self.selected = False
def show(self):
if self.attackable:
fill(*CELLATTACKABLE)
elif self.movable:
fill(*CELLMOVABLE)
elif self.selected:
fill(*CELLSELECTED)
else:
fill(*CELL)
rect(self.x*CELLDIM+MARGIN,self.y*CELLDIM+MARGIN,CELLDIM,CELLDIM)
if self.piece!=None and not self.piece.selected:
self.piece.show()