ThreeKingdomsSlingshot/Assets/Tests/PlayMode/ArenaScenarioTests.cs

233 lines
12 KiB
C#
Raw Normal View History

투기장 · 연의 전기 아트 화면 게임 반영 (PD 2026-11-18 「투기장 UI 완료」 · 「연의 전기 통과」 · 「모두 반영하고 푸시까지」) - 투기장(연무장 page 3) = ArenaLeague + 표 폴더 Resources/UI/League(긴 배경 1080×2340 · 자리 표 납품 그대로 · 설정 표 · 글자 키 · 부품 9 분할 import.json) · 아틀라스 UI_League · 층 Content/Art(Static) · Scene(Frame) · Info(Event + 레이캐스터) - 연의 전기(연무장 page 5) = ArenaScenario(ScenarioFit 화면 맞춤 · ScenarioOpenFx 펼침 6단계) + 표 폴더 Resources/UI/Scenario(탭 배경 5 · 납품 표 3 그대로 · 설정 표 · 글자 키 · 두루마리 8 + 상세 두루마리 9 분할 + 고름 빛) · 아틀라스 UI_Scenario · 상세 = 위 덮개 루트 · 뒤로 = 상세만 닫기 - 공용: ArenaScreen(아트 화면 켜기 · 제목 띠 공용 ViewHeader) · UnitArtImporter(UI/League · UI/Scenario 분기 · 하위 폴더 import.json · max 칸) · UICaptureDriver(LeagueShots · ScenarioShots) · ui_atlas.csv 2줄 · CLAUDE.md 2줄 - 테스트 ArenaLeagueTests · ArenaScenarioTests - 컴파일에 필요해 함께 넣은 다른 세션 파일 = OutGame/UI/UiText.cs · OutGame/Arena/ArenaHubView.cs(연무장 허브 세션 작성) — 허브 본체 · 보물 · 로비 변경은 넣지 않음(공용 파일은 이 작업 줄만) - 검증: 이 커밋 묶음만 둔 사본에서 컴파일 오류 0 · 두 테스트 2/2 통과 · 본체 에디터 콘솔 error 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:48:47 +00:00
using System.Collections;
using NUnit.Framework;
using TKS.OutGame;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
namespace TKS.Tests
{
/// <summary>
/// 연의 전기 아트 화면(PD 2026-11-18 「연의 전기 통과」 · ArenaScenario) — 탭 수 = scn_tabs.json · 두루마리 수 = 그 탭의 편 · 상태 표시(완료 별 · 새 편 · 잠김 자물쇠) = 세이브 ·
/// 빈 탭 = 안내 판 · 제목 띠 = 연의 전기 · 캔버스 층(P41) · 펼침 연출 → 상세(제목 · 조건 칩 · 편성) · 뒤로 = 상세 닫기 → 허브.
/// 기대값은 표·규칙에서 읽는다(C45).
/// </summary>
public class ArenaScenarioTests
{
[TearDown]
public void TearDown()
{
SaveStore.UseMemory(false);
}
static void AssertRate(Transform t, UiRate rate, string what)
{
var c = t.GetComponent<Canvas>();
Assert.IsNotNull(c, what + ": 캔버스 없음");
Assert.IsFalse(c.overrideSorting, what + ": overrideSorting 끔");
var tag = c.GetComponent<UiLayerInfo>();
Assert.IsNotNull(tag, what + ": 등급 표시 없음");
Assert.AreEqual(rate, tag.rate, what + ": 등급");
}
[UnityTest]
public IEnumerator Scenario_Tabs_States_Layers_OpenDetail_Back()
{
WorldProgress.Reset();
SaveStore.UseMemory(true);
SceneManager.LoadScene("Battle");
yield return null;
yield return null;
var og = OutGameRoot.Instance;
Assert.IsNotNull(og);
var s = og.Session;
var d = s.Save;
// 진행: 편 번호 1 의 해금 스테이지만 깸 + 1번 편 연의 승리 → 2번 편(같은 해금) = 새 편 · 해금 안 된 편 = 잠김
ContentRow first = null, second = null, locked = null;
foreach (var b in ScenarioModeRules.Battles())
{
int no = b.I("n_no");
if (no == 1) first = b;
else if (no > 1 && second == null && b.S("s_unlock_stage") == (first != null ? first.S("s_unlock_stage") : "")) second = b;
}
Assert.IsNotNull(first, "1번 편");
Assert.IsNotNull(second, "1번 편과 같이 열리는 편");
int ch, st;
Assert.IsTrue(ArenaRules.ParseStageKey(first.S("s_unlock_stage"), out ch, out st));
d.Stage(ch, st, true).clears = 1;
d.scenario.Get(first.S("s_id"), true).normal[0] = true;
foreach (var b in ScenarioModeRules.Battles())
if (b.I("n_no") > 0 && !ScenarioModeRules.Unlocked(d, b))
{
locked = b;
break;
}
Assert.IsNotNull(locked, "잠긴 편");
og.ShowLobby();
og.Show(og.Arena);
og.Arena.SetPage(ArenaScreen.ScenarioPage);
yield return null;
yield return null;
var sc = og.Arena.Scenario;
Assert.IsNotNull(sc, "연의 전기 표(Resources/UI/Scenario/scn_screen) 없음");
Assert.IsTrue(og.Arena.ScenarioVisible, "연의 전기 쪽 = 아트 화면");
// ① 탭 = scn_tabs.json · 처음 탭 = 새 편이 있는 탭 · 두루마리 = 그 탭의 편 수
var tabs = JsonUtility.FromJson<TabsProbe>(Resources.Load<TextAsset>(sc.S_("tabs")).text);
Assert.AreEqual(tabs.tabs.Length, sc.TabCount, "탭 수");
string newTab = null;
foreach (var t in tabs.tabs)
if (System.Array.IndexOf(t.ids, second.S("s_id")) >= 0) newTab = t.id;
Assert.AreEqual(newTab, sc.TabId, "처음 탭 = 새 편이 있는 탭");
Assert.AreEqual(ArenaScenario.RollState.New, sc.StateOf(second.S("s_id")), "새 편");
Assert.AreEqual(ArenaScenario.RollState.Done, sc.StateOf(first.S("s_id")), "완료");
Assert.AreEqual(ArenaScenario.RollState.Lock, sc.StateOf(locked.S("s_id")), "잠김");
int ids = 0;
foreach (var t in tabs.tabs)
if (t.id == sc.TabId) ids = t.ids.Length;
Assert.AreEqual(ids, sc.RollCount, "두루마리 수");
Assert.IsNotNull(sc.RollOf(second.S("s_id")).Find("New"), "새 편 표");
Assert.IsNotNull(sc.RollOf(first.S("s_id")).Find("Done"), "완료 별");
Assert.IsFalse(sc.TextOf("StarsText").Contains("{"), "모은 별 값 자리");
var header = og.Arena.Rt.Find("Header");
bool titled = false;
foreach (var t in header.GetComponentsInChildren<Text>(true))
if (t.text == UiText.T("scn_title")) titled = true;
Assert.IsTrue(titled, "제목 띠 = 연의 전기");
// ② 캔버스 층(P41)
AssertRate(sc.Content, UiRate.Static, "연의 전기 내용");
AssertRate(sc.Art, UiRate.Static, "연의 전기 배경");
AssertRate(sc.Rolls, UiRate.Event, "두루마리 층");
AssertRate(sc.Chrome, UiRate.Event, "별 칩 · 안내 층");
AssertRate(sc.Tabs, UiRate.Event, "탭 층");
Assert.IsNotNull(sc.Rolls.GetComponent<GraphicRaycaster>(), "두루마리 누름");
Assert.IsNotNull(sc.Tabs.GetComponent<GraphicRaycaster>(), "탭 누름");
Assert.IsNull(sc.Art.GetComponent<GraphicRaycaster>(), "배경 = 누름 없음");
// ③ 빈 탭 = 안내 판
string emptyTab = null;
foreach (var t in tabs.tabs)
if (t.ids.Length == 0) emptyTab = t.id;
if (emptyTab != null)
{
sc.SetTab(emptyTab);
Assert.AreEqual(0, sc.RollCount, "빈 탭 두루마리 0");
Assert.IsNotNull(sc.TextOf("EmptyTitle"), "빈 탭 안내 판");
sc.SetTab(newTab);
}
// ④ 펼침 연출 → 상세
sc.Open(second.S("s_id"));
Assert.IsTrue(sc.Animating, "연출 시작");
Assert.IsFalse(sc.RollOf(second.S("s_id")).gameObject.activeSelf, "줄의 두루마리 숨김");
float t0 = Time.realtimeSinceStartup;
while (sc.Animating && Time.realtimeSinceStartup - t0 < 6f) yield return null;
Assert.IsFalse(sc.Animating, "연출 끝");
yield return null;
Assert.IsTrue(sc.DetailOpen);
StringAssert.Contains(second.S("s_title_ko"), sc.TextOf("DetailTitle"), "상세 제목 = 편 이름");
Assert.AreEqual(second.S("s_win_cond_ko"), sc.TextOf("Win"), "승리 조건 = 기획 표");
Assert.AreEqual(second.S("l_fixed_hero_ko").Replace(";", " · "), sc.TextOf("TeamName"), "편성 = 주역");
Assert.IsNotNull(sc.TextOf("GoText"), "출전 버튼");
// ⑤ 뒤로 = 상세 닫기(줄의 두루마리 다시 보임) → 다시 뒤로 = 허브
Assert.IsTrue(og.Arena.OnBack());
Assert.IsFalse(sc.DetailOpen, "상세 닫힘");
Assert.IsTrue(sc.RollOf(second.S("s_id")).gameObject.activeSelf, "줄의 두루마리 다시 보임");
Assert.AreEqual(ArenaScreen.ScenarioPage, og.Arena.Page, "아직 연의 전기 쪽");
// 건너뛰기: 연출 중 누르면 바로 상세
sc.Open(first.S("s_id"));
yield return null;
Assert.IsTrue(sc.Animating);
og.Arena.OnBack();
Assert.IsFalse(sc.DetailOpen, "연출 중 뒤로 = 닫기");
Assert.IsTrue(og.Arena.OnBack());
yield return null;
Assert.AreEqual(0, og.Arena.Page, "허브로");
Assert.IsFalse(og.Arena.ScenarioVisible);
}
/// <summary>
/// 클리어 도장(2026-11-18 PD 「이미 클리어한 연의 전기 = 양피지 빈 영역에 옥새 컨셉의 클리어 도장이 찍히는 연출 후 항상 클리어 표식」) —
/// 안 깬 편 = 도장 없음 · 깬 편 처음 = 찍히는 연출 → 세이브 stamped · 다시 열면 = 연출 없이 찍힌 채. 화면 = Logs/scn_stamp/*.png.
/// </summary>
[UnityTest]
public IEnumerator Scenario_ClearStamp_PlaysOnce_ThenStays()
{
WorldProgress.Reset();
SaveStore.UseMemory(true);
SceneManager.LoadScene("Battle");
yield return null;
yield return null;
var og = OutGameRoot.Instance;
Assert.IsNotNull(og);
var d = og.Session.Save;
og.ShowLobby();
og.Show(og.Arena);
og.Arena.SetPage(ArenaScreen.ScenarioPage);
yield return null;
var sc = og.Arena.Scenario;
Assert.IsNotNull(sc);
sc.SetTab("p1_a");
// 안 깬 서장 = 도장 없음
d.scenario.episodes.RemoveAll(x => x.id == "taoyuan");
d.scenario.Get("taoyuan", true).acts = 1; // 막 버튼 ①②③ 모양 확인: 1막 이김 · 2막 열림 · 3막 잠김
sc.Open("taoyuan", true);
yield return null;
Assert.IsNull(sc.Stamp, "안 깬 편 = 도장 없음");
string dir0 = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "scn_stamp");
System.IO.Directory.CreateDirectory(dir0);
yield return CaptureUtil.Capture(og.Cam, 540, 960, System.IO.Path.Combine(dir0, "acts_progress.png"));
sc.CloseDetail();
// 깬 서장 처음 = 찍히는 연출
var e = d.scenario.Get("taoyuan", true);
e.normal[0] = true;
e.stamped = false;
string dir = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.dataPath), "Logs", "scn_stamp");
System.IO.Directory.CreateDirectory(dir);
var cam = og.Cam;
sc.Open("taoyuan", true);
yield return null;
Assert.IsNotNull(sc.Stamp, "깬 편 = 도장");
var fx = sc.Stamp.GetComponent<ScenarioStampFx>();
Assert.IsNotNull(fx, "처음 = 찍히는 연출");
Assert.IsTrue(e.stamped, "연출을 시작하면 본 것으로 저장");
for (int i = 0; i < 6; i++) // 기다림 → 내리꽂힘 → 찍힘 → 흔들림
{
yield return CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, "stamp_anim_" + i + ".png"));
yield return new WaitForSecondsRealtime(0.08f);
}
for (float t = 0f; t < 3f && fx != null && !fx.Finished; t += Time.unscaledDeltaTime) yield return null;
Assert.IsTrue(fx == null || fx.Finished, "연출 끝");
Assert.AreEqual(1f, sc.Stamp.localScale.x, 0.001f, "제자리 크기");
Assert.Greater(sc.Stamp.GetComponent<Image>().color.a, 0.5f, "찍힌 채 보임");
yield return CaptureUtil.Capture(cam, 540, 960, System.IO.Path.Combine(dir, "stamp_end.png"));
sc.CloseDetail();
// 다시 열면 = 연출 없이 찍힌 채
sc.Open("taoyuan", true);
yield return null;
Assert.IsNotNull(sc.Stamp, "다시 열어도 도장");
Assert.IsNull(sc.Stamp.GetComponent<ScenarioStampFx>(), "두 번째 = 연출 없음");
Assert.Greater(sc.Stamp.GetComponent<Image>().color.a, 0.5f);
sc.CloseDetail();
d.scenario.episodes.RemoveAll(x => x.id == "taoyuan");
}
투기장 · 연의 전기 아트 화면 게임 반영 (PD 2026-11-18 「투기장 UI 완료」 · 「연의 전기 통과」 · 「모두 반영하고 푸시까지」) - 투기장(연무장 page 3) = ArenaLeague + 표 폴더 Resources/UI/League(긴 배경 1080×2340 · 자리 표 납품 그대로 · 설정 표 · 글자 키 · 부품 9 분할 import.json) · 아틀라스 UI_League · 층 Content/Art(Static) · Scene(Frame) · Info(Event + 레이캐스터) - 연의 전기(연무장 page 5) = ArenaScenario(ScenarioFit 화면 맞춤 · ScenarioOpenFx 펼침 6단계) + 표 폴더 Resources/UI/Scenario(탭 배경 5 · 납품 표 3 그대로 · 설정 표 · 글자 키 · 두루마리 8 + 상세 두루마리 9 분할 + 고름 빛) · 아틀라스 UI_Scenario · 상세 = 위 덮개 루트 · 뒤로 = 상세만 닫기 - 공용: ArenaScreen(아트 화면 켜기 · 제목 띠 공용 ViewHeader) · UnitArtImporter(UI/League · UI/Scenario 분기 · 하위 폴더 import.json · max 칸) · UICaptureDriver(LeagueShots · ScenarioShots) · ui_atlas.csv 2줄 · CLAUDE.md 2줄 - 테스트 ArenaLeagueTests · ArenaScenarioTests - 컴파일에 필요해 함께 넣은 다른 세션 파일 = OutGame/UI/UiText.cs · OutGame/Arena/ArenaHubView.cs(연무장 허브 세션 작성) — 허브 본체 · 보물 · 로비 변경은 넣지 않음(공용 파일은 이 작업 줄만) - 검증: 이 커밋 묶음만 둔 사본에서 컴파일 오류 0 · 두 테스트 2/2 통과 · 본체 에디터 콘솔 error 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:48:47 +00:00
[System.Serializable]
class TabProbe
{
public string id = "";
public string[] ids = new string[0];
}
[System.Serializable]
class TabsProbe
{
public TabProbe[] tabs = new TabProbe[0];
}
}
}