diff --git a/README.md b/README.md index 6ea8110..f3c1caf 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ # Chess game a chess game made with python to play the game run the main.py file - play using the terminal by typing the position of the piece you want to move - and the position you want to go to - example: 'C2 C4' + play using mouse + use left click to choose a piece you want to move and right click to choose the destination you want to move your piece to you win if you kill the other team's king - - -to stop the game enter '00 00' diff --git a/__pycache__/bishop.cpython-37.pyc b/__pycache__/bishop.cpython-37.pyc index 8ce52ec..b2453e8 100644 Binary files a/__pycache__/bishop.cpython-37.pyc and b/__pycache__/bishop.cpython-37.pyc differ diff --git a/__pycache__/game.cpython-37.pyc b/__pycache__/game.cpython-37.pyc index 3967579..de5477a 100644 Binary files a/__pycache__/game.cpython-37.pyc and b/__pycache__/game.cpython-37.pyc differ diff --git a/__pycache__/rook.cpython-37.pyc b/__pycache__/rook.cpython-37.pyc index a0df328..0f3a58e 100644 Binary files a/__pycache__/rook.cpython-37.pyc and b/__pycache__/rook.cpython-37.pyc differ diff --git a/bishop.py b/bishop.py index e5c2abd..40699b3 100644 --- a/bishop.py +++ b/bishop.py @@ -62,9 +62,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -75,9 +77,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -88,9 +92,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -101,9 +107,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position diff --git a/game.py b/game.py index f824d67..6bffd67 100644 --- a/game.py +++ b/game.py @@ -28,47 +28,3 @@ def play(self,window): self.turn = self.turn_switch[self.turn] except: print('impossible move') - - # while True: - # window.update() - # if self.winner != None: - # break - # ##white plays - # while True: - # from gui import left,right - # while left == None or right == None: - # print('sleeping') - # input() - # a = [left,right] - # left = None - # right = None - # if self.board[a[0]] == None or self.board[a[0]].team != 'white': - # print('you can only move white pieces!') - # continue - # r = self.board[a[0]].move(a[1]) - # if r == None: - # break - # print(r) - # - # window.update() - # if self.winner != None: - # break - # - # ##black plays - # while True: - # from gui import left,right - # while left == None or right == None: - # input() - # a = [left,right] - # left = None - # right = None - # if self.board[a[0]] == None or self.board[a[0]].team != 'black': - # print('you can only move black pieces!') - # continue - # r = self.board[a[0]].move(a[1]) - # if r == None: - # break - # print(r) - - # print("the winner is {}".format(self.winner)) - # time.sleep(5) diff --git a/main.py b/main.py index 8552c66..0c85edb 100644 --- a/main.py +++ b/main.py @@ -75,6 +75,9 @@ def rgetxy(event): except: print('error') game.play(guiw) + if game.winner != None: + print('the winner is {}'.format(game.winner)) + input() diff --git a/rook.py b/rook.py index 99dd987..4e6ea6a 100644 --- a/rook.py +++ b/rook.py @@ -57,16 +57,18 @@ def possible_moves(self): def possible_attacks(self): L=[] - temp=self.position + temp = self.position while True: try: temp=temp._get_right() if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -77,9 +79,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -90,9 +94,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position @@ -103,9 +109,11 @@ def possible_attacks(self): if temp._get_piece()==None: continue elif temp._get_piece().team==self.team: + temp = self.position break else: L+=[temp] + temp = self.position break except AssertionError : temp=self.position diff --git a/variables.py b/variables.py deleted file mode 100644 index c9bf616..0000000 --- a/variables.py +++ /dev/null @@ -1,3 +0,0 @@ -from main import game, guiw - -##these are the variables that are both used by main and by gui