function mat
This commit is contained in:
parent
381eee3eb2
commit
c50e466595
Binary file not shown.
41
move.py
41
move.py
@ -11,25 +11,21 @@ import random
|
||||
class Move:
|
||||
|
||||
def move_rival(self, ruch):
|
||||
self.from_column = ruch[0]
|
||||
self.from_column = Move.letters_to__numbers(ruch[0])
|
||||
self.from_row = int(ruch[1])
|
||||
self.to_column = ruch[3]
|
||||
self.to_column = Move.letters_to__numbers(ruch[3])
|
||||
self.to_row = int(ruch[4])
|
||||
|
||||
self.to_column = Move.letters_to__numbers(self.to_column)
|
||||
self.from_column = Move.letters_to__numbers(self.from_column)
|
||||
|
||||
#update
|
||||
#update board
|
||||
self.x = self.board.boardlist[self.from_row][self.from_column].piece
|
||||
self.board.boardlist[self.from_row][self.from_column].piece = None
|
||||
if (self.board.boardlist[self.to_row][self.to_column].has_piece()):
|
||||
if (self.board.boardlist[self.to_row][self.to_column].piece.name == 'king'):
|
||||
self.board.boardlist[self.to_row][self.to_column].piece = self.x
|
||||
exit(0)
|
||||
Move.mat(self, self.x, self.to_row, self.to_column)
|
||||
self.board.boardlist[self.to_row][self.to_column].piece = self.x
|
||||
Move.pawn_promotion(self, self.x, self.to_row, self.to_column)
|
||||
self.board.boardlist[self.to_row][self.to_column].piece.moved = True
|
||||
self.board.boardlist[self.to_row][self.to_column].piece.delete_moves()
|
||||
return self.board.boardlist[self.to_row][self.to_column].piece.color
|
||||
|
||||
def move_boot(self, color):
|
||||
self.boot_piece = []
|
||||
self.piece_row_column = []
|
||||
@ -52,10 +48,8 @@ class Move:
|
||||
self.final_column = self.final[1]
|
||||
self.x = self.board.boardlist[self.initial_row][self.initial_column].piece
|
||||
self.board.boardlist[self.initial_row][self.initial_column].piece = None
|
||||
if (self.board.boardlist[self.final_row][self.final_column].has_piece()):
|
||||
if (self.board.boardlist[self.final_row][self.final_column].piece.name== 'king'):
|
||||
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
||||
exit(0)
|
||||
#mat
|
||||
Move.mat(self, self.x, self.final_row, self.final_column)
|
||||
self.board.boardlist[self.final_row][self.final_column].piece = self.x
|
||||
|
||||
#pawn promotion
|
||||
@ -74,7 +68,24 @@ class Move:
|
||||
if isinstance(x, Pawn):
|
||||
if (final_row==0) or (final_row==7):
|
||||
self.board.boardlist[final_row][final_column].piece = Queen(x.color)
|
||||
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print(final_column, final_row)
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
print("promotion")
|
||||
def mat(self, x, final_row, final_column):
|
||||
if self.board.boardlist[final_row][final_column].has_piece():
|
||||
if self.board.boardlist[final_row][final_column].piece.name == 'king':
|
||||
print(final_column, final_row)
|
||||
print(x)
|
||||
#self.board.boardlist[final_row][final_column].piece = x
|
||||
exit(0)
|
||||
@staticmethod
|
||||
def numbers_to_letters(number):
|
||||
if number == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user