Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Engine import is_area_in_board
- class Bishop:
- def __init__(self, color, pos):
- self.pos = pos
- self.color = color
- self.val = 30 * self.color
- self.image_id = self.create_image_id()
- def create_image_id(self):
- return 17 + self.color
- def move(self, board):
- moves = []
- directions = [1, 1, -1, -1, 1, -1, -1, 1]
- for i in range(0, len(directions), 2):
- for j in range(1, 8):
- area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
- if is_area_in_board(area):
- if board[area[0]][board[1]].checker == None:
- moves.append(area)
- else:
- if board[area[0]][board[1]].checker.color != self.color:
- moves.append(area)
- break
- else:
- break
- return moves
- def king_attack(self, board):
- pass
- class Rook:
- def __init__(self, color, pos):
- self.pos = pos
- self.color = color
- self.val = 50 * self.color
- self.image_id = self.create_image_id()
- self.castling = True
- def create_image_id(self):
- return 9 + self.color
- def move(self, board):
- moves = []
- directions = [1, 0, -1, 0, 0, 1, 0, -1]
- for i in range(0, len(directions), 2):
- for j in range(1, 8):
- area = (self.pos[0] + j * directions[i] + self.pos[1] + j * directions[i + 1])
- if is_area_in_board(area):
- if board[area[0]][area[1]].checker == None:
- moves.append(area)
- else:
- if board[area[0]][area[1]].checker.color != self.color:
- moves.append(area)
- break
- else:
- break
- return moves
- def king_attack(self, board):
- pass
- class Queen(Rook, Bishop):
- def __init__(self, color, pos):
- super().__init__(color, pos)
- self.val = 90 * self.color
- self.image_id = self.create_image_id()
- def create_image_id(self):
- return 5 + self.color
- def move(self, board):
- pass # tutaj chciałbym zrobić coś w stylu return Rook.move() + Bishop.move()
- def king_attack(self, board):
- pass
Add Comment
Please, Sign In to add comment