From 3d0137c8d6f4ce828ee5faeda3f2b942a40d8d57 Mon Sep 17 00:00:00 2001 From: ILYASS AZIRAR <52070629+zurakin@users.noreply.github.com> Date: Tue, 27 Aug 2019 16:54:41 +0100 Subject: [PATCH] fixed an issue in the bishop and rook classes updated readme deleted unused code from game.py --- README.md | 8 ++---- __pycache__/bishop.cpython-37.pyc | Bin 2206 -> 2272 bytes __pycache__/game.cpython-37.pyc | Bin 1112 -> 1112 bytes __pycache__/rook.cpython-37.pyc | Bin 2139 -> 2205 bytes bishop.py | 8 ++++++ game.py | 44 ------------------------------ main.py | 3 ++ rook.py | 10 ++++++- variables.py | 3 -- 9 files changed, 22 insertions(+), 54 deletions(-) delete mode 100644 variables.py 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 8ce52ec5e17558b440a350302af241463852b55c..b2453e8fbba428ee68c0e2bccfc051dd7ca9a986 100644 GIT binary patch delta 565 zcmbOy_&|`)iI4C}dY~qX|lm9XKPCmjW$5=l3G24v#GEhu0vM{nSG65k6BM*=*0OYYSaREs- iMm`|sAyQ5VNgv1zm_Cph=yH6FRpL&W#gkvLZvg<43wI#^ delta 494 zcmaDLI8TtziIxL=|fvN)-!WjyASQtuJvbl;N{Rf)LjPFhnvG=0pH-I73AO*nBoL^PiQUftX*9 zYyn0VCN7`|9}x49 SATEHU9;8v;R%UHvZ#Zb#skyYtY!?b{LA&?EE znHDmnFk~|osg?8O=|K2d%s`dQKrsi1jsS){p&G^-rgTPgxG4b);S7a5EDR+q*<3{h zj0_+MQymGEi2&ko2C!ZAObb}iESpqbfnnJin06eNRX{DfgJD?((6S1kWqFleKo78? z+4Zl!{7If3s?R1c7D*AX?g_*?ph_PM3!eZjd;+wvq|y&)E<37)KpjOB7|TQ8cA7$i z6DZM#-_krexTOasE3k<(hD^3#%Vw;cyo7C9eHkcL8Ce+F7@2^OgOLZw769^Cn7Du> j8zUbO^AIT~grpB-223Bw40Jg@#wyXE{QSu)**5_Ib}xWq delta 531 zcmbO$cw2zaiI(P9024cYk#v(NgE6xC|I0LjIqtXc&7VM~20Co6GU@X_mQ$h_Vpm-9d zNAl#L_DC}p^`Tpo#}vUZfw53;au!=QW8vg$Y|}i`K(WTi!pO$R1cV%nJV3SpBMTE3 XP=pVNd59ICe2`s~8K`gaUG@V2MIm*E 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