using System.Collections;
using UnityEngine;
namespace TKS
{
///
/// 연의 전기 서장(편 n_no 0 · 도원결의) = 연의 모드 전투 n_acts 막(2026-11-18 PD 「연의 전기 스테이지와 일반 출정 스테이지는 별개 — 완전히 별개의 스테이지 개념으로」).
/// 지도(배치 · 기믹 · 학습 안내) = 출정 n_spec_chapter 장 학습 판 1 ~ n_acts 의 표를 빌려 씀(UsesTutorialPlan) — 진행 기록 · 보상 = 연의 세이브(ScenarioModeRules.Result) ·
/// 시나리오 연출 · 판 꾸밈 = s_battle_id + 막(출정 판에는 붙지 않음) · 막 승리 → 승리 연출 → 다음 막(결과 화면 없음) → 마지막 막 승리 = 결과.
/// 학습 안내는 서장에서 매번 보인다(TutorialRules.ForceFirstPlay · 출정 클리어 기록과 무관).
///
public class PrologueRules : ModeBattleRules
{
public string BattleId = "";
public string TitleKo = "";
public int Chapter = 1;
public int Act = 1;
public int Acts = 1;
public override bool UsesTutorialPlan
{
get { return true; }
}
public override string ScenarioBattleId
{
get { return BattleId; }
}
public override int ScenarioAct
{
get { return Act; }
}
/// 막 a 의 판 정의 = 출정 (chapter, a) 정의의 사본(연출·기믹·배치 표 열쇠는 그대로 · 제목만 연의) — 없으면 null.
public BalanceConfig.StageDef MakeStage(BalanceConfig cfg, int a)
{
if (cfg == null || cfg.stages == null) return null;
foreach (var s in cfg.stages)
{
if (s.chapter != Chapter || s.stage != a) continue;
var c = JsonUtility.FromJson(JsonUtility.ToJson(s));
c.title = TitleKo + " " + a + "/" + Acts + "막";
c.subtitle = "연의 전기";
c.bgTheme = ""; // 바닥 = 판 꾸밈 표(scenario_props `_bg`) — 출정 배경 테마와 연동하지 않음
return c;
}
return null;
}
public override void OnBegin()
{
ScenarioEvent.FaceFrontAll(Battle);
}
public override bool NextActOnWin()
{
if (Act >= Acts || Battle == null) return false;
var s = MakeStage(Battle.Config, Act + 1);
if (s == null) return false;
Act++;
Battle.StartCoroutine(Next(s));
return true;
}
IEnumerator Next(BalanceConfig.StageDef s)
{
Battle.ForcePhase(BattlePhase.Setup);
float wait = ScenarioData.EvCfg("act_transition_sec");
for (float t = 0f; t < wait; t += Time.unscaledDeltaTime) yield return null;
Battle.BeginActStage(s);
}
}
}