feat: add build_smelting_line blueprint action to ActionExecutor

This commit is contained in:
21in7
2026-03-27 00:01:59 +09:00
parent 2212dda22f
commit e92efc7bdf
2 changed files with 112 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ class ActionExecutor:
"place_entity": self.place_entity, "place_belt_line": self.place_belt_line,
"insert_to_entity": self.insert_to_entity, "set_recipe": self.set_recipe,
"start_research": self.start_research, "wait": self.wait,
"build_smelting_line": self.build_smelting_line,
}
handler = handlers.get(act)
if not handler:
@@ -454,6 +455,54 @@ p.mining_state = {{mining = true, position = {{x = {mine_x}, y = {mine_y}}}}}
return True, f"{ore} {total_mined}개 채굴 (목표 {count}개 중 일부)"
return False, f"{ore} 채굴 실패 - {len(failed_positions)}개 타일 접근 불가"
# ── 건설 자동화 (Blueprint) ───────────────────────────────────────
def build_smelting_line(
self,
ore: str = "iron-ore",
x: int = 0,
y: int = 0,
furnace_count: int = 4,
) -> tuple[bool, str]:
"""
석탄 제련 라인 자동 배치.
stone-furnace를 y축 방향으로 furnace_count개 일렬 배치하고
각각에 석탄 + 광석을 자동 투입한다.
"""
spacing = 3 # furnace 간격 (타일)
placed = 0
failed = 0
for i in range(furnace_count):
fy = y + i * spacing
ok, msg = self.move(x, fy)
if not ok:
print(f" [blueprint] ({x},{fy}) 이동 실패: {msg}")
failed += 1
continue
ok, msg = self.place_entity(name="stone-furnace", x=x, y=fy)
if not ok:
print(f" [blueprint] ({x},{fy}) 배치 실패: {msg}")
failed += 1
continue
# 실제 배치된 좌표 파싱 (REUSED 포함)
parsed = self._extract_coords_from_message(msg)
rx, ry = (parsed if parsed is not None else (x, fy))
boot_ok, boot_msg = self._auto_bootstrap_furnace(
furnace_name="stone-furnace",
x=int(rx),
y=int(ry),
reason=f"build_smelting_line: {ore}",
)
placed += 1
print(f" [blueprint] ({rx},{ry}) OK — bootstrap: {boot_msg}")
if placed == 0:
return False, f"build_smelting_line 실패: {failed}개 모두 배치 불가"
return True, f"build_smelting_line: {placed}개 배치 완료 ({failed}개 실패)"
# ── 제작/배치/삽입/레시피/연구/대기 ──────────────────────────────
def craft_item(self, item: str, count: int = 1) -> tuple[bool, str]:
result = self.rcon.lua(P + f"""