extends Rule

static func ready(piece: Piece):
	pass

static func select(piece: Piece, game: Game):
	
	var pos = piece.to_coord()
	var board_size = game.get_node("Board").board_size
	print("Board Size: ", board_size)
	print("Bishop Pos:", pos)
	#piece.possible_movements = []
	
	var tiles_to_left: int = board_size.x-1 - pos.x
	print("tiles to left: ", tiles_to_left)
	var tiles_to_right: int = (board_size.x-1) - ((board_size.x-1) - pos.x)
	print("tiles to right: ", tiles_to_right)
	var tiles_to_top: int = board_size.y-1 - pos.y
	print("tiles to top: ", tiles_to_top)
	var tiles_to_bottom: int = (board_size.y-1) - ((board_size.y-1) - pos.y)
	print("tiles to bottom: ", tiles_to_bottom)
	
	#left down
	for x in range(pos.x+1, board_size.x, 1):
		var move = Vector2i(x - pos.x, -(x - pos.x) )
		var other_piece = game.get_piece_at(move+pos)
		if other_piece:
			if other_piece.is_in_group("Enemy"):
				piece.possible_movements.append(move)
			break
		piece.possible_movements.append(move)
	
	#right down
	for x in range(pos.x-1, -1, -1):
		var move = Vector2i(x -pos.x, x-pos.x)
		var other_piece = game.get_piece_at(move+pos)
		if pos.x + move.x < 0:
			continue
		if pos.y + move.y < 0:
			continue
		if other_piece:
			if other_piece.is_in_group("Enemy"):
				piece.possible_movements.append(move)
			break
		piece.possible_movements.append(move)
		
	#left up
	for x in range(pos.x+1, board_size.x, 1):
		var move = Vector2i(x - pos.x, (x - pos.x) )
		var other_piece = game.get_piece_at(move+pos)
		if other_piece:
			if other_piece.is_in_group("Enemy"):
				piece.possible_movements.append(move)
			break
		piece.possible_movements.append(move)

	#right up
	for x in range(pos.x-1, -1, -1):
		var move = Vector2i(x -pos.x,  -(x - pos.x))
		var other_piece = game.get_piece_at(move+pos)
		if pos.x + move.x < 0:
			continue
		if pos.y + move.y < 0:
			continue
		if other_piece:
			if other_piece.is_in_group("Enemy"):
				piece.possible_movements.append(move)
			break
		piece.possible_movements.append(move)
	
	for move in piece.possible_movements:
		pass
		
	pass

static func before_move(piece: Piece):
	pass
