using System.Collections; using System.Collections.Generic; using NUnit.Framework; using TKS.OutGame; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; namespace TKS.Tests { /// /// 시나리오 이벤트(2026-11-18 PD 「연의전기 시나리오 이벤트 · 1장 도원결의부터」) + 보스 등장 주고받기(boss_talk.csv) 확인. /// 연출은 메모리 세이브에서 꺼진다(ScenarioEvent.Mode Auto) — 여기서만 ForceOn(학습 판도 ForceOn). 값은 표에서 읽는다(C45). /// public class ScenarioEventTests { BattleManager bm; BalanceConfig cfg; [UnitySetUp] public IEnumerator SetUp() { WorldProgress.Reset(); SaveStore.UseMemory(true); SceneManager.LoadScene("Battle"); yield return null; yield return null; bm = BattleManager.Instance; Assert.IsNotNull(bm); cfg = bm.Config; TutorialRules.Mode = TutorialMode.ForceOn; ScenarioEvent.Mode = TutorialMode.ForceOn; Time.timeScale = 1f; } [UnityTearDown] public IEnumerator TearDown() { ScenarioEvent.Abort(); TutorialRules.Mode = TutorialMode.Auto; ScenarioEvent.Mode = TutorialMode.Auto; Time.timeScale = 1f; yield return null; } /// 연의 전기 서장(도원결의) n 막을 연의 모드 전투로 시작(2026-11-18 PD 「연의 전기와 출정은 별개」). PrologueRules StartPrologue(int act = 1) { var b = ContentTables.Find("scenario_battles", "s_id", "taoyuan"); Assert.IsNotNull(b, "scenario_battles taoyuan"); var rules = new PrologueRules { BattleId = "taoyuan", TitleKo = b.S("s_title_ko"), Chapter = b.I("n_spec_chapter"), Acts = Mathf.Max(1, b.I("n_acts")), Act = act }; var stage = rules.MakeStage(cfg, act); Assert.IsNotNull(stage, "서장 막 판 정의"); bm.StartMode(new BattleMode { kind = "scenario", stage = stage, maxTurns = 0, rules = rules }); return rules; } int Index(int chapter, int stage) { for (int i = 0; i < cfg.stages.Length; i++) if (cfg.stages[i].chapter == chapter && cfg.stages[i].stage == stage) return i; Assert.Fail(chapter + "-" + stage + " 없음"); return -1; } IEnumerator UntilEventEnds(float timeout) { for (float t = 0f; ScenarioEvent.Running && t < timeout; t += Time.unscaledDeltaTime) yield return null; Assert.IsFalse(ScenarioEvent.Running, "연출이 끝나지 않음"); } [Test] public void Tables_ReadWithoutErrors_TalkAlwaysHasSpeaker() { ScenarioData.Reload(); Assert.AreEqual(0, ScenarioData.Errors.Count, string.Join("\n", ScenarioData.Errors.ToArray())); Assert.Greater(ScenarioData.AllEvents.Count, 0, "scenario_event.csv 비어 있음"); // 주고받기: 같은 (판, 순서) 묶음의 마지막 줄 = ally 또는 그 판의 보스 → 언제나 누군가 말한다 var groups = new Dictionary>(); foreach (var t in ScenarioData.AllTalks) { string k = t.chapter + "-" + t.stage + ":" + t.order; if (!groups.ContainsKey(k)) groups[k] = new List(); groups[k].Add(t); } foreach (var kv in groups) { var last = kv.Value[kv.Value.Count - 1]; bool boss = false; foreach (var b in ScenarioData.Bosses(last.chapter, last.stage)) if (b.id == last.speaker) boss = true; Assert.IsTrue(last.speaker == "ally" || boss, kv.Key + " 마지막 화자 = " + last.speaker + "(ally·보스 아님)"); } // 보스가 있는 판은 모두 주고받기가 있다 foreach (var s in cfg.stages) if (ScenarioData.Bosses(s.chapter, s.stage).Count > 0) Assert.Greater(ScenarioData.Talks(s.chapter, s.stage).Count, 0, s.chapter + "-" + s.stage + " 주고받기 없음"); } /// 서장 1막 = 장비 조작 · 유비 기절(2026-11-18 PD 「장비를 조작해 유비를 구하는 스토리 · 유비는 스턴 · 턴이 바뀌어도 행동 종료 · 적은 유비를 통과해 장비만 공격」). [UnityTest] public IEnumerator Prologue1_Start_Skip_EndsAtLayoutWithLiubeiStunned() { StartPrologue(1); yield return null; Assert.IsTrue(ScenarioEvent.Running, "서장 1막 시작 연출"); Assert.AreEqual(BattlePhase.Setup, bm.Phase, "연출 동안 조작 잠금"); yield return new WaitForSecondsRealtime(0.3f); ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return null; Assert.AreEqual(BattlePhase.PlayerTurn, bm.Phase, "연출 뒤 아군 차례"); foreach (var r in bm.Tutorial.Layout) { var u = bm.Tutorial.UnitAt(r.slot); if (u == null) continue; Assert.Less(Vector2.Distance(u.Position, r.pos), 0.05f, "슬롯 " + r.slot + " 시작 자리"); Assert.IsTrue(u.View.gameObject.activeSelf, "슬롯 " + r.slot + " 보임"); } var zf = bm.Tutorial.UnitAt(1); var lb = bm.Tutorial.UnitAt(3); Assert.IsNotNull(zf); Assert.IsNotNull(lb); Assert.AreEqual("zhangfei", zf.HeroId, "조작 유닛 = 장비(scenario_layout 덮어쓰기)"); Assert.IsFalse(zf.Npc); Assert.AreEqual("liubei", lb.HeroId, "구출 대상 = 유비"); Assert.IsTrue(lb.Npc && lb.Downed, "유비 = 기절한 구출 대상"); Assert.IsTrue(SkillStatus.Stunned(lb), "유비 기절 표시(stun)"); Assert.IsTrue(lb.ActedThisTurn, "유비 = 행동 마침"); // 적은 유비를 지나침 · 표적 = 장비 var e4 = bm.Tutorial.UnitAt(4); Assert.IsNotNull(e4); float hd; Vector2 dir = (lb.Position - e4.Position).normalized; var first = Combat.FirstEnemyOnPath(e4, e4.Position, dir, Vector2.Distance(e4.Position, lb.Position) + 1f, out hd); Assert.AreNotEqual(lb, first, "적의 경로에 기절한 유비 = 통과"); Assert.AreEqual(zf, bm.Mode.rules.EnemyTarget(e4), "적 표적 = 장비"); // 턴이 바뀌어도 유비는 행동 마침 · 기절 유지 lb.ResetForNewTurn(); Assert.IsTrue(lb.ActedThisTurn, "다음 턴에도 행동 마침"); } /// 막 승리 = 결과(다음 막으로 자동으로 넘어가지 않음 · 2026-11-18 PD 「버튼 형태로 이벤트를 감상」) · 1막 승리 연출 = 유비가 깨어남. [UnityTest] public IEnumerator Prologue_EachActWin_EndsWithResult_NoAutoNextAct() { var rules = StartPrologue(1); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); var lb = bm.Tutorial.UnitAt(3); foreach (var e in bm.AliveUnits(Faction.Enemy)) e.TakeDamage(e.MaxHp * 10); bm.CheckBattleEnd(); yield return null; Assert.IsTrue(ScenarioEvent.Running, "1막 승리 연출"); Assert.AreEqual(BattlePhase.Setup, bm.Phase, "승리 연출 동안 결과 대기"); yield return new WaitForSecondsRealtime(0.3f); ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return null; Assert.IsFalse(SkillStatus.Stunned(lb), "유비 깨어남(wake)"); Assert.IsFalse(lb.Downed); Assert.AreEqual(BattlePhase.StageClear, bm.Phase, "1막 승리 = 결과(2막 자동 시작 없음)"); Assert.AreEqual(1, rules.Act); // 3막도 그 막만 StartPrologue(3); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); foreach (var e in bm.AliveUnits(Faction.Enemy)) e.TakeDamage(e.MaxHp * 10); bm.CheckBattleEnd(); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return null; Assert.AreEqual(BattlePhase.StageClear, bm.Phase, "3막 승리 = 결과"); } /// 전투 포기(2026-11-18 PD 「우측 상단에 언제든 전투를 포기 · 버튼 → 팝업 → 포기」) — 연의 전투 = 버튼 · 계속하기 = 그대로 · 포기 = 패배 · 출정 = 버튼 없음. [UnityTest] public IEnumerator GiveUp_Popup_EndsAsDefeat_OnlyInScenarioModes() { StartPrologue(1); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return null; var hud = Object.FindFirstObjectByType(FindObjectsInactive.Include); Assert.IsNotNull(hud); Assert.AreEqual(BattlePhase.PlayerTurn, bm.Phase); Assert.IsTrue(hud.GiveUpVisible, "연의 전투 = 포기 버튼"); hud.OpenGiveUp(); Assert.IsTrue(hud.GiveUpOpen, "확인 팝업"); hud.CloseGiveUp(); // 계속하기 Assert.IsFalse(hud.GiveUpOpen); Assert.AreEqual(BattlePhase.PlayerTurn, bm.Phase, "계속하기 = 전투 그대로"); hud.OpenGiveUp(); hud.ConfirmGiveUp(); Assert.AreEqual(BattlePhase.Defeat, bm.Phase, "포기 = 패배"); Assert.IsFalse(hud.GiveUpOpen, "팝업 닫힘"); Assert.IsFalse(hud.GiveUpVisible, "끝난 전투 = 버튼 없음"); yield return null; bm.StartStage(Index(1, 1)); yield return null; Assert.IsFalse(hud.GiveUpVisible, "출정 = 포기 버튼 없음"); } /// 배치 설계용 측정(Explicit) → Logs/prologue_probe.txt — 막 유닛의 슬링 최대 거리 · 자리. [UnityTest, Explicit] public IEnumerator Probe_PrologueReach() { var sb = new System.Text.StringBuilder(); for (int act = 1; act <= 2; act++) { StartPrologue(act); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return null; foreach (var u in bm.Units) if (u != null && u.IsAlive) sb.AppendLine(act + "막 slot" + bm.Tutorial.SlotOf(u) + " " + u.DisplayName + " " + u.Type + " pos " + u.Position + " r " + u.Radius.ToString("0.00") + " slingMax " + SkillMods.SlingMax(u).ToString("0.00") + " hp " + u.Hp + "/" + u.MaxHp + " atk " + u.Atk + (u.Npc ? " npc" : "")); } System.IO.File.WriteAllText(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "prologue_probe.txt"), sb.ToString()); } /// 연출은 건너뛰고 안내 카드는 눌러 닫으며 아군 차례(안정 3프레임) · 끝까지 진행. IEnumerator Drive(float timeout) { int calm = 0; for (float t = 0f; t < timeout; t += Time.unscaledDeltaTime) { var d = TutorialDirector.Current; if (ScenarioEvent.Running) { ScenarioEvent.SkipForTest(); calm = 0; } else if (d != null && d.BlocksInput && d.ActiveStep != null && (d.ActiveStep.mode == GuideMode.Popup || d.ActiveStep.mode == GuideMode.Highlight)) { d.TapForTest(); calm = 0; } else if (bm.Phase == BattlePhase.StageClear || bm.Phase == BattlePhase.Defeat) yield break; else if (bm.Phase == BattlePhase.PlayerTurn && ++calm >= 4) yield break; yield return null; } } IEnumerator Act(Unit u, Vector2 target) { Assert.IsTrue(bm.RequestPlayerAction(u, target), u.DisplayName + " 행동 시작"); yield return null; for (float t = 0f; t < 30f && bm.Phase == BattlePhase.Resolving && !ScenarioEvent.Running; t += Time.unscaledDeltaTime) yield return null; } /// /// 1막 흐름(2026-11-19 PD 다시 짬 「반격 학습을 빼고 한번에 처치 · 다른 황건적이 공격한 후 사망 = 반격 학습 · 남은 한명이 도와달라고 하면 한명 더 · 두명 모두 돌진」) — /// 장비 첫 돌진 = 우두머리 처치 → 적 턴 건달 A 가 덤볐다가 반격에 쓰러짐 → 2턴 시작 연출 = 건달 B 가 도움을 부르고 숨어 있던 지원 건달 C 등장 · 한 줄 → /// 장비 관통 둘 → 승리 · 1막 = 액티브 스킬 잠김. 세기 0.6 · 1.0. /// [UnityTest] public IEnumerator Act1_Flow_OneShot_Counter_Reinforce_Pierce([Values(0.6f, 1f)] float pull) { StartPrologue(1); yield return null; yield return Drive(20f); var zf = bm.Tutorial.UnitAt(1); var leader = bm.Tutorial.UnitAt(2); var lb = bm.Tutorial.UnitAt(3); var a = bm.Tutorial.UnitAt(4); var b = bm.Tutorial.UnitAt(5); var c = bm.Tutorial.UnitAt(6); Assert.IsNotNull(c, "지원 건달(슬롯 6)"); Assert.IsFalse(c.View.gameObject.activeSelf, "지원 건달 = 시작 연출 뒤에도 숨김"); Assert.Less(Vector2.Distance(lb.Position, new Vector2(0.7f, 3.9f)), 0.05f, "유비 = PD 지정 자리"); Assert.IsNotNull(bm.Mode.rules.SkillBlocked(zf), "1막 = 액티브 스킬 잠김"); var d = TutorialDirector.Current; float max = SkillMods.SlingMax(zf); Vector2 aim = zf.Position + (leader.Position - zf.Position).normalized * max * pull; Assert.IsTrue(d.AllowShot(zf, aim)); yield return Act(zf, aim); Assert.IsFalse(leader.IsAlive, "첫 돌진 = 우두머리 처치(한 번에 닿음)"); Assert.IsTrue(a.IsAlive && b.IsAlive && c.IsAlive, "건달 A · B · 지원 C 는 남음"); // 반격 카드 = 적 턴 1 에 건달 A 가 덤비기 전에 뜸(2턴에 뜨면 안 됨) float wait = 0f; while (wait < 15f && !(bm.Phase == BattlePhase.EnemyTurn && d.BlocksInput && d.ActiveStep != null && d.ActiveStep.mode == GuideMode.Popup)) { if (ScenarioEvent.Running) ScenarioEvent.SkipForTest(); // 적 턴 연출(건달 A 「이.. 이놈이!?」) 뒤에 카드 wait += Time.unscaledDeltaTime; yield return null; } Assert.AreEqual(BattlePhase.EnemyTurn, bm.Phase, "반격 카드 = 적 턴 1"); Assert.AreEqual(1, bm.TurnNumber); Assert.IsTrue(a.IsAlive, "카드가 뜬 때 = 건달 A 가 아직 덤비기 전"); yield return Drive(60f); // 적 턴(반격 카드 → 건달 A 가 덤빔 → 반격) → 2턴 시작 연출(도움 요청 · 지원 등장) Assert.IsFalse(a.IsAlive, "건달 A = 장비 반격에 쓰러짐(반격 학습)"); Assert.IsTrue(zf.IsAlive); Assert.AreEqual(2, bm.TurnNumber); Assert.IsTrue(c.View.gameObject.activeSelf, "지원 건달 등장"); // 장비 = 반격한 자리 그대로 · 두 건달이 장비 기준 한 줄(line 명령 · 2026-11-19 PD) Vector2 tb = b.Position - zf.Position, tc = c.Position - zf.Position; Assert.Less(Vector2.Angle(tb, tc), 3f, "장비 → 건달 B → 지원 건달 = 한 줄"); Assert.Greater(tc.magnitude, tb.magnitude, "지원 건달이 B 뒤"); Assert.IsTrue(SkillStatus.Stunned(lb) && lb.Downed, "유비 기절 그대로"); Vector2 aim2 = zf.Position + (c.Position - zf.Position).normalized * max * pull; Assert.IsTrue(d.AllowShot(zf, aim2)); yield return Act(zf, aim2); yield return Drive(30f); Assert.IsFalse(b.IsAlive, "관통 1"); Assert.IsFalse(c.IsAlive, "관통 2"); Assert.AreEqual(BattlePhase.StageClear, bm.Phase); } /// 1장 2막까지 장수 액티브 스킬 잠김 · 3막 = 열림(2026-11-19 PD · content_modes_config scenario.prologue_skill_lock_act). [UnityTest] public IEnumerator Prologue_SkillLocked_UntilAct2() { foreach (int act in new[] { 1, 2, 3 }) { StartPrologue(act); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); foreach (var u in bm.AliveUnits(Faction.Player)) { if (u.Npc) continue; string why = bm.Mode.rules.SkillBlocked(u); if (act <= 2) Assert.IsNotNull(why, act + "막 " + u.DisplayName + " = 잠김"); else Assert.IsNull(why, "3막 " + u.DisplayName + " = 열림"); } } } /// /// 2막 흐름(2026-11-19 PD 다시 짬) — 시작 연출(지나가던 관우 · 바위 굴림 · 기병 2기 · 뒤에서 기습) 뒤 바위 = 관우가 굴린 자리 · 관우 = 출혈 · 체력 30 % → /// 유비 snap 튕김 = 창병 둘 → 장비 snap = 유비 · 관우(아군)를 지나 뒤편 보병 관통 → 2턴 시작 연출 = 잔당이 장비 사거리 밖으로 달아남 → /// 유비가 장비를 쳐서 밀어 보냄(민 뒤 = 사거리 안) → 장비가 잔당 처치 → 승리. 세기 0.6 · 1.0(각 단계 최소 당김보다 작으면 최소 당김) · 수치 → Logs/act2_flow.txt. /// [UnityTest] public IEnumerator Act2_Flow_LiubeiBounce_ZhangfeiPierce_AllyPush([Values(0.6f, 1f)] float pull) { string logPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "act2_flow.txt"); System.Action log = line => System.IO.File.AppendAllText(logPath, line + "\n"); log("pull " + pull); StartPrologue(2); yield return null; yield return Drive(30f); var lb = bm.Tutorial.UnitAt(1); var zf = bm.Tutorial.UnitAt(2); var gy = bm.Tutorial.UnitAt(3); var a = bm.Tutorial.UnitAt(4); var b = bm.Tutorial.UnitAt(5); var i1 = bm.Tutorial.UnitAt(6); var rem = bm.Tutorial.UnitAt(7); Assert.IsNotNull(rem, "잔당(슬롯 7)"); Assert.LessOrEqual(gy.Hp, Mathf.CeilToInt(gy.MaxHp * 0.31f), "관우 체력 크게 감소"); Assert.IsTrue(SkillStatus.Bleeding(gy), "관우 출혈"); GimmickInstance rock = null; foreach (var g in bm.Gimmicks.Items) if (g.Id == "boulder") rock = g; if (rock == null) { var dbg = "gimmicks " + bm.Gimmicks.Items.Count + " errs " + string.Join(" | ", ContentTables.Errors.ToArray()); foreach (var u in bm.Units) if (u != null) dbg += "\n " + bm.Tutorial.SlotOf(u) + " " + u.DisplayName + " " + u.Position.ToString("0.00"); log(dbg); } Assert.IsNotNull(rock, "바위"); Assert.Less(Vector2.Distance(rock.Shape.Center, new Vector2(-3.6f, -0.8f)), 0.05f, "바위 = 관우가 굴린 자리(roll · 건너뛰어도)"); var d = TutorialDirector.Current; // 1턴 유비 — 어느 쪽으로 끌어도 정해진 방향 → 창병 둘 Vector2 any = lb.Position + Vector2.left * SkillMods.SlingMax(lb) * pull; Vector2 t1 = d.SnapAim(lb, any); Assert.AreNotEqual(any, t1, "snap = 정해진 방향"); Assert.IsTrue(d.AllowShot(lb, t1)); yield return Act(lb, t1); yield return Drive(30f); log("liubei end " + lb.Position.ToString("0.00") + " guanyu " + gy.Position.ToString("0.00")); Assert.IsFalse(a.IsAlive, "창병 1"); Assert.IsFalse(b.IsAlive, "창병 2(튕김)"); Assert.IsTrue(i1.IsAlive && rem.IsAlive, "보병 · 잔당은 남음"); // 1턴 장비 — 유비 · 관우(아군)를 지나 뒤편 보병 관통 float zp = Mathf.Max(pull, 0.8f); Vector2 any2 = zf.Position + Vector2.right * SkillMods.SlingMax(zf) * zp; Vector2 t2 = d.SnapAim(zf, any2); Assert.AreNotEqual(any2, t2, "장비 snap = 뒤편 보병 쪽"); Assert.IsTrue(d.AllowShot(zf, t2)); yield return Act(zf, t2); log("zhangfei end " + zf.Position.ToString("0.00") + " i1 " + (i1.IsAlive ? "alive" : "dead") + " gap to guanyu " + Vector2.Distance(zf.Position, gy.Position).ToString("0.00")); Assert.IsFalse(i1.IsAlive, "관통 = 뒤편 보병"); Assert.GreaterOrEqual(Vector2.Distance(zf.Position, gy.Position), zf.Radius + gy.Radius - 0.02f, "관통 뒤 장비가 관우와 겹치지 않음"); yield return Drive(60f); // 적 턴(잔당 hold) → 2턴 시작 연출(잔당 도주) → 아군 밀치기 카드 Assert.AreEqual(2, bm.TurnNumber); Assert.IsTrue(gy.IsAlive, "관우 버팀"); float reach = SkillMods.SlingMax(zf) + zf.Radius + rem.Radius; float before = Vector2.Distance(zf.Position, rem.Position); log("t2 zf " + zf.Position.ToString("0.00") + " lb " + lb.Position.ToString("0.00") + " rem " + rem.Position.ToString("0.00") + " dist " + before.ToString("0.00") + " reach " + reach.ToString("0.00")); Assert.Greater(before, reach, "밀기 전 = 장비 사거리 밖"); // 2턴 유비 — 장비를 쳐서 밀어 보냄 float lp = Mathf.Max(pull, 0.8f); Vector2 any3 = lb.Position + Vector2.down * SkillMods.SlingMax(lb) * lp; Vector2 t3 = d.SnapAim(lb, any3); Assert.AreNotEqual(any3, t3, "유비 snap = 장비 쪽"); Assert.IsTrue(d.AllowShot(lb, t3)); Vector2 z0 = zf.Position; yield return Act(lb, t3); yield return Drive(30f); float after = Vector2.Distance(zf.Position, rem.Position); log("push " + Vector2.Distance(z0, zf.Position).ToString("0.00") + " zf " + zf.Position.ToString("0.00") + " lb " + lb.Position.ToString("0.00") + " dist " + after.ToString("0.00") + " need pull " + ((after - zf.Radius - rem.Radius) / SkillMods.SlingMax(zf)).ToString("0.000")); Assert.IsTrue(rem.IsAlive, "민 장비가 잔당에 닿지 않음(장비가 직접 처치)"); Assert.Less(after, reach, "민 뒤 = 장비 사거리 안"); // 2턴 장비 — 끝까지 당겨 잔당 처치 Vector2 t4 = d.SnapAim(zf, zf.Position + Vector2.left * SkillMods.SlingMax(zf)); Assert.IsTrue(d.AllowShot(zf, t4), "장비 = 잔당 쪽 · 끝까지"); yield return Act(zf, t4); yield return Drive(30f); Assert.IsFalse(rem.IsAlive, "장비가 잔당 처치"); Assert.AreEqual(BattlePhase.StageClear, bm.Phase); } IEnumerator UntilSettled(float timeout) { for (float t = 0f; t < timeout; t += Time.unscaledDeltaTime) { if (ScenarioEvent.Running) ScenarioEvent.SkipForTest(); else if (bm.Phase == BattlePhase.PlayerTurn || bm.Phase == BattlePhase.StageClear || bm.Phase == BattlePhase.Defeat) yield break; yield return null; } } /// 2막 배치 설계 측정(Explicit) → Logs/prologue_probe2.txt — 유비 snap 세기별 창병 처치 · 끝 자리 · 이어서 장비 snap 세기별 관통(2026-11-19 PD 2막 다시 짬). [UnityTest, Explicit, Timeout(1500000)] public IEnumerator Probe_Act2Shots() { var sb = new System.Text.StringBuilder(); Time.timeScale = 4f; foreach (float pull in new[] { 0.4f, 0.7f, 1f }) foreach (float zpull in new[] { 0.6f, 0.7f, 0.8f, 1f }) { StartPrologue(2); yield return null; yield return UntilSettled(10f); var d = TutorialDirector.Current; yield return Drive(10f); var lb = bm.Tutorial.UnitAt(1); var zf = bm.Tutorial.UnitAt(2); var gy = bm.Tutorial.UnitAt(3); Vector2 gy0 = gy.Position; var t1 = lb.Position + (new Vector2(3.25f, 1.39f) - lb.Position).normalized * SkillMods.SlingMax(lb) * pull; // = 안내 4단계 snap 방향(최소 당김 무시) bm.RequestPlayerAction(lb, t1, false, false); yield return null; yield return Drive(15f); string lbs = "liubei pull " + pull + " → A " + (bm.Tutorial.UnitAt(4).IsAlive ? "alive" : "dead") + " B " + (bm.Tutorial.UnitAt(5).IsAlive ? "alive" : "dead") + " guanyu moved " + Vector2.Distance(gy0, gy.Position).ToString("0.00") + " lb end " + lb.Position.ToString("0.00"); var t2 = zf.Position + (bm.Tutorial.UnitAt(6).Position - zf.Position).normalized * SkillMods.SlingMax(zf) * zpull; // = 안내 6단계 snap 방향 bm.RequestPlayerAction(zf, t2, false, false); yield return null; for (float t = 0f; t < 15f && bm.Phase == BattlePhase.Resolving; t += Time.unscaledDeltaTime) yield return null; sb.AppendLine(lbs + " | zf pull " + zpull + " → I1 " + (bm.Tutorial.UnitAt(6).IsAlive ? "alive" : "dead") + " zf end " + zf.Position.ToString("0.00") + " gap to guanyu " + Vector2.Distance(zf.Position, gy.Position).ToString("0.00")); } Time.timeScale = 1f; System.IO.File.WriteAllText(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "prologue_probe2.txt"), sb.ToString()); } /// /// 빠른 반영(2026-11-19 PD 「수정 요청한 항목만 바로바로 반영하고 확인」 · Explicit · 표 파일을 잠시 고쳤다 되돌림) — 실제 입장 길(연의 전기 상세 1막 버튼) · /// 1막 시작 = 유비가 오른쪽 술상 앞에서 밝게 · Play 중 scenario_guide 를 고치고 F5(OutGameRoot.RestartPrologueAct · 연출 도중) → 고친 문구가 바로 나옴 → Logs/quickloop/. /// [UnityTest, Explicit] public IEnumerator QuickLoop_Act1Start_F5ReloadsEditedTable() { string dir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "quickloop"); System.IO.Directory.CreateDirectory(dir); var cam = Camera.main; System.Func shot = name => CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, name + ".png")); var og = OutGameRoot.Instance; Assert.IsNotNull(og); og.ShowLobby(); og.Show(og.Arena); og.Arena.SetPage(ArenaScreen.ScenarioPage); yield return null; og.Arena.Scenario.SetTab("p1_a"); og.Arena.Scenario.Open("taoyuan", true); yield return null; og.Arena.Scenario.GoAct("taoyuan", 1); yield return new WaitForSecondsRealtime(0.5f); Assert.IsTrue(ScenarioEvent.Running, "1막 시작 연출"); var lb = bm.Tutorial.UnitAt(3); Assert.Less(Vector2.Distance(lb.Position, new Vector2(2.4f, 5.3f)), 0.05f, "유비 = 오른쪽 술상 앞에서 시작"); Assert.AreEqual(Color.white, lb.View.Anim.Renderer.color, "기절 전 유비 = 밝게"); yield return Follow(new[] { 16, 24, 43, 46 }, "1-1_quick", shot); // 43 = 장비를 따라가는 카메라 · 46 = 우두머리 대사(2026-11-19) Assert.IsTrue(SkillStatus.Stunned(lb), "연출 끝 = 기절"); for (float t = 0f; t < 5f && bm.Phase != BattlePhase.PlayerTurn; t += Time.unscaledDeltaTime) yield return null; yield return new WaitForSecondsRealtime(0.3f); Assert.IsTrue(lb.ActedThisTurn, "기절한 유비 = 행동 마침"); Assert.AreNotEqual(Color.white, lb.View.Anim.Renderer.color, "기절 뒤 = 흐리게(행동 마침)"); // Play 중 표 고침 → F5(연출 도중) → 고친 문구 string path = System.IO.Path.Combine(Application.dataPath, "Resources", "Scenario", "scenario_guide.csv"); byte[] keep = System.IO.File.ReadAllBytes(path); try { string txt = System.Text.Encoding.UTF8.GetString(keep); const string mark = " [F5 시험]"; string first = "기절했다! 장비로 건달을 물리치자."; Assert.IsTrue(txt.Contains(first), "1막 1단계 문구"); System.IO.File.WriteAllBytes(path, System.Text.Encoding.UTF8.GetBytes(txt.Replace(first, first + mark))); Assert.IsTrue(og.RestartPrologueAct(), "F5 = 서장 막 다시 시작"); yield return new WaitForSecondsRealtime(1f); Assert.IsTrue(ScenarioEvent.Running, "다시 시작 = 처음 연출부터"); Assert.IsTrue(og.RestartPrologueAct(), "연출 도중 F5"); yield return new WaitForSecondsRealtime(0.3f); ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return new WaitForSecondsRealtime(0.5f); var d = TutorialDirector.Current; Assert.IsNotNull(d.ActiveStep, "안내 1단계"); StringAssert.Contains(mark, d.ActiveStep.textKo, "고친 표가 다시 시작에 바로 반영"); Assert.Less(Vector2.Distance(bm.Tutorial.UnitAt(3).Position, new Vector2(0.7f, 3.9f)), 0.05f, "다시 시작 뒤 배치 자리"); yield return shot("1-1_quick_f5_edited_guide"); } finally { System.IO.File.WriteAllBytes(path, keep); } } /// 포기 버튼 · 팝업 화면 캡처(Explicit) → Logs/giveup_capture/. [UnityTest, Explicit] public IEnumerator Capture_GiveUp() { string dir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "giveup_capture"); System.IO.Directory.CreateDirectory(dir); var og = OutGameRoot.Instance; Assert.IsNotNull(og); // 실제 입장 길 = 연의 전기 상세의 1막 버튼(세션 모드 기록 → 결과 창 내용까지) og.ShowLobby(); og.Show(og.Arena); og.Arena.SetPage(ArenaScreen.ScenarioPage); yield return null; og.Arena.Scenario.SetTab("p1_a"); og.Arena.Scenario.Open("taoyuan", true); yield return null; og.Arena.Scenario.GoAct("taoyuan", 1); var hud = Object.FindFirstObjectByType(FindObjectsInactive.Include); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); yield return new WaitForSecondsRealtime(2.5f); // 안내 카드 var cam = Camera.main; yield return CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, "giveup_btn.png")); hud.OpenGiveUp(); yield return null; yield return CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, "giveup_popup.png")); hud.ConfirmGiveUp(); yield return new WaitForSecondsRealtime(0.8f); yield return CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, "giveup_result.png")); } /// 연의 전기 = 군량 없이 도전(2026-11-18 PD · content_modes_config scenario.stamina_cost 0) — 군량 0 이어도 입장 · 줄지 않음 · 져도 환급 줄 없음. [Test] public void Entry_CostsNoStamina() { var s = OutGameRoot.Instance != null ? OutGameRoot.Instance.Session : null; Assert.IsNotNull(s, "본영 세션"); Assert.AreEqual(0, ContentTables.Int("scenario", "stamina_cost"), "표 = 군량 없음"); var d = s.Save; int keep = d.stamina; d.stamina = 0; EconomyRules.TickStamina(s.Db, d, s.Now); // 시간 회복분은 먼저 반영 int before = d.stamina; Assert.IsNull(ScenarioModeRules.Enter(s.Db, d, "taoyuan", false, s.Now), "군량이 없어도 입장"); Assert.AreEqual(before, d.stamina, "군량이 줄지 않음"); var r = ScenarioModeRules.Result(s.Db, d, "taoyuan", false, false, null, new List(), s.Now, new System.Random(1)); Assert.AreEqual(before, d.stamina, "져도 환급 없음"); Assert.IsFalse(r.lines.Exists(x => x.Contains("환급")), "환급 줄 없음"); d.stamina = keep; } /// 막 진행 기록 — 1막만 열림 → 이긴 막 다음이 열림 · 중간 막 = 보상 없음 · 마지막 막 = 편 완료(2026-11-18 PD). [Test] public void ActProgress_OpensNextAct_LastActCompletesEpisode() { var s = OutGameRoot.Instance != null ? OutGameRoot.Instance.Session : null; Assert.IsNotNull(s, "본영 세션"); var d = s.Save; d.scenario.episodes.RemoveAll(x => x.id == "taoyuan"); Assert.IsTrue(ScenarioModeRules.ActOpen(d, "taoyuan", 1)); Assert.IsFalse(ScenarioModeRules.ActOpen(d, "taoyuan", 2), "2막 = 1막을 이겨야"); Assert.AreEqual(1, ScenarioModeRules.NextAct(d, "taoyuan", 3)); int gem = d.gem; var r1 = ScenarioModeRules.ActResult(s.Db, d, "taoyuan", 1, 3, true, new List(), s.Now, new System.Random(1)); Assert.IsTrue(r1.win); Assert.AreEqual(gem, d.gem, "중간 막 = 보상 없음"); Assert.IsFalse(d.scenario.Get("taoyuan", false).normal[0], "중간 막 = 편 완료 아님"); Assert.IsTrue(ScenarioModeRules.ActOpen(d, "taoyuan", 2)); Assert.IsFalse(ScenarioModeRules.ActOpen(d, "taoyuan", 3)); Assert.AreEqual(2, ScenarioModeRules.NextAct(d, "taoyuan", 3)); ScenarioModeRules.ActResult(s.Db, d, "taoyuan", 2, 3, true, new List(), s.Now, new System.Random(1)); ScenarioModeRules.ActResult(s.Db, d, "taoyuan", 3, 3, true, new List(), s.Now, new System.Random(1)); Assert.IsTrue(d.scenario.Get("taoyuan", false).normal[0], "마지막 막 = 편 완료"); Assert.AreEqual(1, ScenarioModeRules.NextAct(d, "taoyuan", 3), "모두 이김 = 출전은 1막부터"); d.scenario.episodes.RemoveAll(x => x.id == "taoyuan"); } [UnityTest] public IEnumerator Chuljeong1_1_HasNoScenarioStaging() { bm.StartStage(Index(1, 1)); yield return null; Assert.IsFalse(ScenarioEvent.Running, "출정 1-1 = 연의 연출 없음"); Assert.IsFalse(bm.Board.EventArtOn, "출정 1-1 = 연의 바닥 없음"); Assert.AreEqual(0, ScenarioProps.Count, "출정 1-1 = 연의 소품 없음"); } /// /// 연출 화면 캡처(Explicit) → Logs/scenario_capture/ — 1-1 시작(말다툼 · 기습 · 기절 · 유비 등장) · 1-1 승리(관우 등장) · 1-3 승리(맹세) · 1-5 보스 주고받기. /// 화면 누름은 0.3 초마다 자동(말풍선 = 다 찍히면 다음). /// [UnityTest, Explicit] public IEnumerator Capture_EventScreens() { string dir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "scenario_capture"); System.IO.Directory.CreateDirectory(dir); var cam = Camera.main; System.Func shot = name => CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, name + ".png")); // 실제 흐름처럼 본영 화면을 끈다(출정 = 월드맵이 본영을 끄고 → 전투 시작 때 월드맵을 닫음) var og = OutGameRoot.Instance; if (og != null) { og.OpenWorldMap(); if (og.Map != null) og.Map.Hide(); } var hud = Object.FindFirstObjectByType(FindObjectsInactive.Include); if (hud != null) hud.gameObject.SetActive(true); // 서장 1막 시작 StartPrologue(1); yield return null; var want = new[] { 16, 24, 26, 32, 37, 41, 46, 51 }; // 2026-11-19: 유비 = 오른쪽 술상 앞에서 시작 → 23 = 옆 술상으로 와서 항의 yield return Follow(want, "1-1_start", shot); yield return new WaitForSecondsRealtime(0.8f); yield return shot("1-1_start_end_battle"); // 1-1 1턴(우두머리 처치 · 적 턴 반격) → 2턴 시작 연출(도움 요청 · 지원 건달) — 2026-11-19 yield return Drive(20f); var zf1 = bm.Tutorial.UnitAt(1); var ld1 = bm.Tutorial.UnitAt(2); yield return Act(zf1, zf1.Position + (ld1.Position - zf1.Position).normalized * SkillMods.SlingMax(zf1)); yield return shot("1-1_t1_oneshot"); bool cardShot = false; for (float t = 0f; t < 40f && !ScenarioEvent.Running; t += Time.unscaledDeltaTime) { var gd = TutorialDirector.Current; if (gd != null && gd.BlocksInput && gd.ActiveStep != null && gd.ActiveStep.mode == GuideMode.Popup && t > 1f) { if (!cardShot && bm.Phase == BattlePhase.EnemyTurn) { cardShot = true; yield return shot("1-1_t1_counter_card"); // 반격 카드 = 적 턴 1(건달 A 가 덤비기 전) } gd.TapForTest(); } yield return null; } yield return Follow(new[] { 3, 6, 7, 9 }, "1-1_reinforce", shot); yield return new WaitForSecondsRealtime(0.8f); yield return shot("1-1_t2_drag"); // 1-1 승리 foreach (var e in bm.AliveUnits(Faction.Enemy)) e.TakeDamage(e.MaxHp * 10); bm.CheckBattleEnd(); yield return Follow(new[] { 3, 6, 9, 16, 23 }, "1-1_win", shot); // 서장 2막(2026-11-19 PD 다시 짬) — 시작 연출 · 1턴(유비 튕김 → 기병 카드 → 장비 관통) · 2턴 시작 연출(잔당 도주) · 아군 밀치기 → 장비 처치 StartPrologue(2); yield return null; yield return Follow(new[] { 16, 20, 24, 26, 32, 40, 47, 56, 60, 66 }, "1-2_start", shot); yield return new WaitForSecondsRealtime(0.8f); yield return shot("1-2_start_end_battle"); yield return Drive(20f); var d2 = TutorialDirector.Current; var lb2 = bm.Tutorial.UnitAt(1); var zf2 = bm.Tutorial.UnitAt(2); yield return Act(lb2, d2.SnapAim(lb2, lb2.Position + Vector2.left * SkillMods.SlingMax(lb2))); yield return new WaitForSecondsRealtime(0.8f); yield return shot("1-2_t1_cav_card"); yield return Drive(20f); yield return shot("1-2_t1_zf_drag"); yield return Act(zf2, d2.SnapAim(zf2, zf2.Position + Vector2.right * SkillMods.SlingMax(zf2))); for (float t = 0f; t < 30f && !ScenarioEvent.Running; t += Time.unscaledDeltaTime) yield return null; // 적 턴 → 2턴 시작 연출 yield return Follow(new[] { 1, 4, 6, 8 }, "1-2_flee", shot); yield return new WaitForSecondsRealtime(0.8f); yield return shot("1-2_t2_push_card"); yield return Drive(20f); yield return shot("1-2_t2_push_drag"); yield return Act(lb2, d2.SnapAim(lb2, lb2.Position + Vector2.down * SkillMods.SlingMax(lb2))); yield return new WaitForSecondsRealtime(0.5f); yield return shot("1-2_t2_pushed"); yield return Act(zf2, d2.SnapAim(zf2, zf2.Position + Vector2.left * SkillMods.SlingMax(zf2))); yield return Drive(30f); // 서장 3막 승리(맹세) StartPrologue(3); yield return null; ScenarioEvent.SkipForTest(); yield return UntilEventEnds(5f); foreach (var e in bm.AliveUnits(Faction.Enemy)) e.TakeDamage(e.MaxHp * 10); bm.CheckBattleEnd(); yield return Follow(new[] { 10, 14, 19 }, "1-3_win", shot); // 1-5 보스 등장 + 주고받기 bm.StartStage(Index(1, 5)); for (float t = 0f; t < 20f && bm.Phase == BattlePhase.Setup; t += 0.5f) { yield return new WaitForSecondsRealtime(0.5f); if (t > 2.4f && t < 9f && Mathf.Abs(t % 1.5f) < 0.01f) yield return shot("1-5_boss_" + t.ToString("0.0")); } } /// 연출을 자동 누름으로 진행하며 want 의 n_order 줄에 닿으면 찍는다(말풍선이 다 찍힐 시간을 둠). IEnumerator Follow(int[] want, string prefix, System.Func shot) { int next = 0; for (float t = 0f; ScenarioEvent.Running && t < 120f; t += 0.3f) { if (next < want.Length && ScenarioEvent.CurrentOrder >= want[next]) { yield return new WaitForSecondsRealtime(0.9f); yield return shot(prefix + "_" + want[next].ToString("00")); next++; continue; } yield return new WaitForSecondsRealtime(0.3f); ScenarioEvent.TapForTest(); } } } }