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 knight_moves():
|
||||
#piece.delete_moves()
|
||||
self.possible_moves = [
|
||||
(row + 2, column - 1),
|
||||
(row + 2, column + 1),
|
||||
@ -62,7 +61,6 @@ class Board:
|
||||
self.final = (self.possible_row, self.possible_column)
|
||||
piece.add_moves(self.final)
|
||||
def pawn_moves():
|
||||
#piece.delete_moves()
|
||||
if piece.moved == True:
|
||||
self.steps = 1
|
||||
else:
|
||||
@ -77,15 +75,10 @@ class Board:
|
||||
piece.add_moves((self.final, column))
|
||||
self.steps = 1
|
||||
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:
|
||||
piece.add_moves((self.final, column))
|
||||
|
||||
#diagonal
|
||||
#czy wychodzi poza tablice i czy stoi rywal
|
||||
self.possible_row = row + piece.pawn_direction
|
||||
self.possible_columns = []
|
||||
self.possible_columns = [column-1, column+1]
|
||||
@ -125,7 +118,6 @@ class Board:
|
||||
else:
|
||||
break
|
||||
def king_moves():
|
||||
#piece.delete_moves()
|
||||
self.direction = [
|
||||
(0, 1),
|
||||
(0, -1),
|
||||
@ -145,19 +137,17 @@ class Board:
|
||||
piece.add_moves((self.possible_row, self.possible_column))
|
||||
elif self.boardlist[self.possible_row][self.possible_column].is_rival(piece.color) is True:
|
||||
piece.add_moves((self.possible_row, self.possible_column))
|
||||
|
||||
#calculate possible moves for specific piece
|
||||
if piece.name == 'rook':
|
||||
#piece.delete_moves()
|
||||
straightline_moves(True)
|
||||
elif piece.name == 'pawn':
|
||||
pawn_moves()
|
||||
elif piece.name == 'knight':
|
||||
knight_moves()
|
||||
elif piece.name == 'bishop':
|
||||
#piece.delete_moves()
|
||||
straightline_moves(False)
|
||||
elif piece.name == 'queen':
|
||||
#piece.delete_moves()
|
||||
straightline_moves(True)
|
||||
straightline_moves(False)
|
||||
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)
|
||||
def nextMove(self, ruch):
|
||||
self.currently_available_moves()
|
||||
|
||||
if ruch == None:
|
||||
return Move.move_boot(self, 'black')
|
||||
else:
|
||||
|
6
move.py
6
move.py
@ -60,9 +60,6 @@ class Move:
|
||||
|
||||
#pawn promotion
|
||||
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.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)
|
||||
return self.ruch
|
||||
|
||||
def pawn_promotion(self, x, final_row, final_column):
|
||||
if isinstance(x, Pawn):
|
||||
if (final_row==0) or (final_row==7):
|
||||
self.board.boardlist[final_row][final_column].piece = Queen(x.color)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def numbers_to_letters(number):
|
||||
if number == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user