class move update
This commit is contained in:
parent
6f53b72324
commit
381eee3eb2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12
board.py
12
board.py
@ -44,7 +44,6 @@ class Board:
|
|||||||
|
|
||||||
def calc_moves(self, piece, row, column):
|
def calc_moves(self, piece, row, column):
|
||||||
def knight_moves():
|
def knight_moves():
|
||||||
#piece.delete_moves()
|
|
||||||
self.possible_moves = [
|
self.possible_moves = [
|
||||||
(row + 2, column - 1),
|
(row + 2, column - 1),
|
||||||
(row + 2, column + 1),
|
(row + 2, column + 1),
|
||||||
@ -62,7 +61,6 @@ class Board:
|
|||||||
self.final = (self.possible_row, self.possible_column)
|
self.final = (self.possible_row, self.possible_column)
|
||||||
piece.add_moves(self.final)
|
piece.add_moves(self.final)
|
||||||
def pawn_moves():
|
def pawn_moves():
|
||||||
#piece.delete_moves()
|
|
||||||
if piece.moved == True:
|
if piece.moved == True:
|
||||||
self.steps = 1
|
self.steps = 1
|
||||||
else:
|
else:
|
||||||
@ -77,15 +75,10 @@ class Board:
|
|||||||
piece.add_moves((self.final, column))
|
piece.add_moves((self.final, column))
|
||||||
self.steps = 1
|
self.steps = 1
|
||||||
self.final = row + (piece.pawn_direction * (self.steps))
|
self.final = row + (piece.pawn_direction * (self.steps))
|
||||||
#problem z wierszem
|
|
||||||
#if self.final>7 or self.final<0 or column>7 or column <0:
|
|
||||||
#print(piece.name)
|
|
||||||
#print(self.final, column)
|
|
||||||
if Square.on_board(self.final, column) is True and self.boardlist[self.final][column].has_piece() is False:
|
if Square.on_board(self.final, column) is True and self.boardlist[self.final][column].has_piece() is False:
|
||||||
piece.add_moves((self.final, column))
|
piece.add_moves((self.final, column))
|
||||||
|
|
||||||
#diagonal
|
#diagonal
|
||||||
#czy wychodzi poza tablice i czy stoi rywal
|
|
||||||
self.possible_row = row + piece.pawn_direction
|
self.possible_row = row + piece.pawn_direction
|
||||||
self.possible_columns = []
|
self.possible_columns = []
|
||||||
self.possible_columns = [column-1, column+1]
|
self.possible_columns = [column-1, column+1]
|
||||||
@ -125,7 +118,6 @@ class Board:
|
|||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
def king_moves():
|
def king_moves():
|
||||||
#piece.delete_moves()
|
|
||||||
self.direction = [
|
self.direction = [
|
||||||
(0, 1),
|
(0, 1),
|
||||||
(0, -1),
|
(0, -1),
|
||||||
@ -145,19 +137,17 @@ class Board:
|
|||||||
piece.add_moves((self.possible_row, self.possible_column))
|
piece.add_moves((self.possible_row, self.possible_column))
|
||||||
elif self.boardlist[self.possible_row][self.possible_column].is_rival(piece.color) is True:
|
elif self.boardlist[self.possible_row][self.possible_column].is_rival(piece.color) is True:
|
||||||
piece.add_moves((self.possible_row, self.possible_column))
|
piece.add_moves((self.possible_row, self.possible_column))
|
||||||
|
|
||||||
#calculate possible moves for specific piece
|
#calculate possible moves for specific piece
|
||||||
if piece.name == 'rook':
|
if piece.name == 'rook':
|
||||||
#piece.delete_moves()
|
|
||||||
straightline_moves(True)
|
straightline_moves(True)
|
||||||
elif piece.name == 'pawn':
|
elif piece.name == 'pawn':
|
||||||
pawn_moves()
|
pawn_moves()
|
||||||
elif piece.name == 'knight':
|
elif piece.name == 'knight':
|
||||||
knight_moves()
|
knight_moves()
|
||||||
elif piece.name == 'bishop':
|
elif piece.name == 'bishop':
|
||||||
#piece.delete_moves()
|
|
||||||
straightline_moves(False)
|
straightline_moves(False)
|
||||||
elif piece.name == 'queen':
|
elif piece.name == 'queen':
|
||||||
#piece.delete_moves()
|
|
||||||
straightline_moves(True)
|
straightline_moves(True)
|
||||||
straightline_moves(False)
|
straightline_moves(False)
|
||||||
elif piece.name == 'king':
|
elif piece.name == 'king':
|
||||||
|
1
game.py
1
game.py
@ -74,7 +74,6 @@ class Game:
|
|||||||
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
|
self.board.calc_moves(self.board.boardlist[row][column].piece, row, column)
|
||||||
def nextMove(self, ruch):
|
def nextMove(self, ruch):
|
||||||
self.currently_available_moves()
|
self.currently_available_moves()
|
||||||
|
|
||||||
if ruch == None:
|
if ruch == None:
|
||||||
return Move.move_boot(self, 'black')
|
return Move.move_boot(self, 'black')
|
||||||
else:
|
else:
|
||||||
|
6
move.py
6
move.py
@ -60,9 +60,6 @@ class Move:
|
|||||||
|
|
||||||
#pawn promotion
|
#pawn promotion
|
||||||
Move.pawn_promotion(self, self.x, self.final_row, self.final_column)
|
Move.pawn_promotion(self, self.x, self.final_row, self.final_column)
|
||||||
#if isinstance(self.x, Pawn):
|
|
||||||
# if (self.final_row==0) or (self.final_row==7):
|
|
||||||
# self.board.boardlist[self.final_row][self.final_column].piece = Queen(self.x.color)
|
|
||||||
|
|
||||||
self.board.boardlist[self.final_row][self.final_column].piece.moved = True
|
self.board.boardlist[self.final_row][self.final_column].piece.moved = True
|
||||||
self.board.boardlist[self.final_row][self.final_column].piece.delete_moves()
|
self.board.boardlist[self.final_row][self.final_column].piece.delete_moves()
|
||||||
@ -72,11 +69,12 @@ class Move:
|
|||||||
|
|
||||||
self.ruch = str(self.initial_column) + str(self.initial_row) + ' ' + str(self.final_column) + str(self.final_row)
|
self.ruch = str(self.initial_column) + str(self.initial_row) + ' ' + str(self.final_column) + str(self.final_row)
|
||||||
return self.ruch
|
return self.ruch
|
||||||
|
|
||||||
def pawn_promotion(self, x, final_row, final_column):
|
def pawn_promotion(self, x, final_row, final_column):
|
||||||
if isinstance(x, Pawn):
|
if isinstance(x, Pawn):
|
||||||
if (final_row==0) or (final_row==7):
|
if (final_row==0) or (final_row==7):
|
||||||
self.board.boardlist[final_row][final_column].piece = Queen(x.color)
|
self.board.boardlist[final_row][final_column].piece = Queen(x.color)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def numbers_to_letters(number):
|
def numbers_to_letters(number):
|
||||||
if number == 0:
|
if number == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user