Guest User

Untitled

a guest
May 11th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.44 KB | None | 0 0
  1. from Engine import is_area_in_board
  2.  
  3.  
  4. class Bishop:
  5.     def __init__(self, color, pos):
  6.         self.pos = pos
  7.         self.color = color
  8.         self.val = 30 * self.color
  9.         self.image_id = self.create_image_id()
  10.  
  11.     def create_image_id(self):
  12.         return 17 + self.color
  13.  
  14.     def move(self, board):
  15.         moves = []
  16.         directions = [1, 1, -1, -1, 1, -1, -1, 1]
  17.         for i in range(0, len(directions), 2):
  18.             for j in range(1, 8):
  19.                 area = (self.pos[0] + j * directions[i], self.pos[1] + j * directions[i + 1])
  20.                 if is_area_in_board(area):
  21.                     if board[area[0]][board[1]].checker == None:
  22.                         moves.append(area)
  23.                     else:
  24.                         if board[area[0]][board[1]].checker.color != self.color:
  25.                             moves.append(area)
  26.                             break
  27.                 else:
  28.                     break
  29.  
  30.         return moves
  31.  
  32.     def king_attack(self, board):
  33.         pass
  34.  
  35. class Rook:
  36.     def __init__(self, color, pos):
  37.         self.pos = pos
  38.         self.color = color
  39.         self.val = 50 * self.color
  40.         self.image_id = self.create_image_id()
  41.         self.castling = True
  42.  
  43.     def create_image_id(self):
  44.         return 9 + self.color
  45.  
  46.     def move(self, board):
  47.         moves = []
  48.         directions = [1, 0, -1, 0, 0, 1, 0, -1]
  49.         for i in range(0, len(directions), 2):
  50.             for j in range(1, 8):
  51.                 area = (self.pos[0] + j * directions[i] + self.pos[1] + j * directions[i + 1])
  52.                 if is_area_in_board(area):
  53.                     if board[area[0]][area[1]].checker == None:
  54.                         moves.append(area)
  55.                     else:
  56.                         if board[area[0]][area[1]].checker.color != self.color:
  57.                             moves.append(area)
  58.                             break
  59.                 else:
  60.                     break
  61.  
  62.         return moves
  63.  
  64.     def king_attack(self, board):
  65.         pass
  66.  
  67. class Queen(Rook, Bishop):
  68.     def __init__(self, color, pos):
  69.         super().__init__(color, pos)
  70.         self.val = 90 * self.color
  71.         self.image_id = self.create_image_id()
  72.  
  73.     def create_image_id(self):
  74.         return 5 + self.color
  75.  
  76.     def move(self, board):
  77.         pass  # tutaj chciałbym zrobić coś w stylu return Rook.move() + Bishop.move()
  78.  
  79.     def king_attack(self, board):
  80.         pass
Add Comment
Please, Sign In to add comment