-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgame.py
51 lines (36 loc) · 1.21 KB
/
game.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 ctypes import wstring_at
import sys
from PyQt5.QtWidgets import QMainWindow
from board import Board
from player import Player
from sidebar import Sidebar
class Game(QMainWindow):
def __init__(self, w, h, x, y):
super().__init__()
self.x = x
self.y = y
self.w = w
self.h = h
self.setWindowTitle('Chess')
self.setGeometry(self.x, self.y, self.w, self.h)
self.player1 = Player(self, 'Tyson', 1, 'l')
self.player2 = Player(self, 'Whelan', 2, 'd')
self.players = [self.player1, self.player2]
self.currentPlayer = self.player1
self.board = Board(self, self.w, self.h, self.h//8)
self.sidebar = Sidebar(self, self.w-self.h, self.h, self.h)
self.turn = 0
self.show()
def getPlayers(self):
pass
def checkGameState(self):
for player in self.players:
if any([p.piece == 'k' for p in player.capturedPieces]):
player.wins()
def registerMove(self, move):
self.sidebar.moveTable.addMove(move)
def nextTurn(self):
self.turn += 1
self.turn %= 2
self.currentPlayer = self.players[self.turn]
self.sidebar.update()