extends Rule

static func ready(piece: Piece):
	piece.possible_movements = [
		Vector2i(0,1),
		Vector2i(0,2)
	]
	pass

static func select(piece: Piece, game: Game):
	var pos = piece.to_coord()
	piece.possible_movements = []
	
	var max_steps = 1
	if piece.to_coord() == piece.start_coord:
		max_steps = 2
	for y in range(1, max_steps+1, 1):
		var move = Vector2i(0,y)
		var other_piece = game.get_piece_at(move+pos)
		if other_piece:
			break
		piece.possible_movements.append(move)
		
	#Vector2i(piece.position.x / 2 + move.x, piece.position.z / 2 + move.y)
	var top_left_tile = Vector2i(piece.position.x / 2 + 1, piece.position.z / 2 +1)
	var top_right_tile = Vector2i(piece.position.x / 2 - 1, piece.position.z / 2 +1)
	for enemy in game.get_node("Pieces").get_children():
		if enemy.is_in_group("Enemy"):
			var enemy_coord = Vector2i(enemy.position.x / 2, enemy.position.z / 2)
			
			if enemy_coord == top_left_tile:
				piece.possible_movements.append(Vector2i(1,1))
			if enemy_coord == top_right_tile:
				piece.possible_movements.append(Vector2i(-1,1))
		
	pass

static func before_move(piece: Piece):
	pass
