-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboard.py
35 lines (27 loc) · 950 Bytes
/
board.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
from PyQt5.QtWidgets import QWidget
from piece import Piece
from tile import Tile
import util
class Board(QWidget):
def __init__(self, parent, width, height, tile_length):
super().__init__(parent)
self.setGeometry(0, 0, width, height)
self.tiles = []
for char in 'abcdefgh':
row = []
for num in '12345678':
tile = Tile(self, char, num, tile_length)
piece, color = self.getStartingPiece(char, num)
tile.setPiece(Piece(tile, color, piece))
row.append(tile)
self.tiles.append(row)
self.show()
def getStartingPiece(self, char, num):
piece = util.startingPieces.get(char+num, None)
if piece:
return piece[0], piece[1]
return (None, None)
def unhighlightAll(self):
for row in self.tiles:
for tile in row:
tile.unhighlight()