167 lines
7.3 KiB
C#
167 lines
7.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using NUnit.Framework;
|
|
using TKS.OutGame;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.TestTools;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TKS.Tests
|
|
{
|
|
/// <summary>
|
|
/// 영웅 「정보」 화면(2026-11-20 개발요청_영웅정보 §3) — 표 임포트 · 기본 + 성장 = 합계 = 지금 HeroRules 계산 · 전투 능력치 0 = 회색 · 바로가기 6 · 열전 있음 / 없음 · ◀ ▶.
|
|
/// </summary>
|
|
public class HeroInfoTests
|
|
{
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
SaveStore.UseMemory(false);
|
|
}
|
|
|
|
static IEnumerator Boot()
|
|
{
|
|
WorldProgress.Reset();
|
|
SaveStore.UseMemory(true);
|
|
SceneManager.LoadScene("Battle");
|
|
yield return null;
|
|
yield return null;
|
|
}
|
|
|
|
static Button Find(OutGameRoot og, string name)
|
|
{
|
|
foreach (var b in og.TopRoot.GetComponentsInChildren<Button>(true))
|
|
if (b.name == name) return b;
|
|
return null;
|
|
}
|
|
|
|
static Text FindText(OutGameRoot og, string parent, string name)
|
|
{
|
|
foreach (var t in og.TopRoot.GetComponentsInChildren<Text>(true))
|
|
if (t.name == name && t.transform.parent != null && t.transform.parent.name == parent) return t;
|
|
return null;
|
|
}
|
|
|
|
[Test]
|
|
public void Tables_Import()
|
|
{
|
|
var dir = Path.Combine(Application.dataPath, OutGameTables.Folder);
|
|
var texts = new string[OutGameTables.Files.Length];
|
|
for (int i = 0; i < texts.Length; i++) texts[i] = File.ReadAllText(Path.Combine(dir, OutGameTables.Files[i]), System.Text.Encoding.UTF8);
|
|
var r = OutGameTables.Parse(texts);
|
|
Assert.AreEqual(0, r.errors.Count, string.Join("\n", r.errors.ToArray()));
|
|
var db = OutGameData.Default.HeroInfo;
|
|
Assert.AreEqual(r.data.HeroInfo.stats.Count, db.stats.Count);
|
|
Assert.AreEqual(r.data.HeroInfo.sources.Count, db.sources.Count);
|
|
Assert.AreEqual(r.data.HeroInfo.chronicle.Count, db.chronicle.Count);
|
|
OutGameTables.Destroy(r);
|
|
}
|
|
|
|
[UnityTest]
|
|
public IEnumerator Stats_BasePlusGrowth_EqualsCompute_ZeroGray_Gotos_Bio_Arrows()
|
|
{
|
|
yield return Boot();
|
|
var og = OutGameRoot.Instance;
|
|
var s = og.Session;
|
|
var db = s.Db.HeroInfo;
|
|
var owned = s.Owned(false);
|
|
var h = owned[0];
|
|
foreach (var o in owned)
|
|
if (db.ChronicleOf(o.id).Count > 0) { h = o; break; }
|
|
og.ShowHero(h.id);
|
|
yield return null;
|
|
og.HeroDetail.OnMenu(0);
|
|
Assert.AreEqual("stats", HeroInfoWindow.Last, "정보 버튼 = 정보 창");
|
|
var st = s.StatsOf(h.id);
|
|
foreach (var key in new[] { "hp", "atk", "def" })
|
|
{
|
|
float bv, tot;
|
|
HeroInfoWindow.BaseTotal(st, key, out bv, out tot);
|
|
var t = FindText(og, "Base_" + key, "Total");
|
|
Assert.IsNotNull(t, key);
|
|
Assert.AreEqual(Mathf.RoundToInt(tot).ToString("N0"), t.text, key + " 합계 = HeroRules.Compute");
|
|
Assert.AreEqual(Mathf.RoundToInt(key == "hp" ? st.hp : key == "def" ? st.def : st.atk), Mathf.RoundToInt(tot));
|
|
}
|
|
Assert.AreEqual(st.power.ToString("N0"), FindText(og, "Base_power", "Total").text, "전투력");
|
|
// 전투 능력치 = 표의 Battle 줄 전부(0 이어도 보임 · 회색)
|
|
var vals = HeroInfoWindow.BattleStats(s, h, s.Save.Hero(h.id));
|
|
int battle = 0;
|
|
foreach (var r in db.stats)
|
|
{
|
|
if (r.section != "Battle") continue;
|
|
battle++;
|
|
var vt = FindText(og, "Battle_" + r.key, "Value");
|
|
Assert.IsNotNull(vt, r.key + " 보임");
|
|
if (Mathf.Abs(vals[r.key]) < 0.05f) Assert.AreNotEqual(UiKit.White, vt.color, r.key + " 0 = 회색");
|
|
}
|
|
Assert.Greater(battle, 0);
|
|
// 성장 내역 = 칸마다 기여 %(PD 2026-11-20 재설계 · 바로가기 폐지)
|
|
foreach (var r in db.sources)
|
|
{
|
|
Assert.IsNotNull(FindText(og, "Grow_" + r.key, "Value"), r.key + " 성장 칸");
|
|
Assert.IsNull(Find(og, "Go_" + r.key), r.key + " 바로가기 없음");
|
|
}
|
|
// 내역 창
|
|
Find(og, "Base_atk").onClick.Invoke();
|
|
Assert.AreEqual("breakdown", HeroInfoWindow.Last);
|
|
Find(og, "BdClose").onClick.Invoke();
|
|
Assert.AreEqual("stats", HeroInfoWindow.Last);
|
|
// 열전
|
|
Find(og, "TabBio").onClick.Invoke();
|
|
Assert.AreEqual("bio", HeroInfoWindow.Last);
|
|
Assert.AreEqual(db.ChronicleOf(h.id).Count > 0, Find(og, "Go_1") != null || FindText(og, "Ev_1", "Title") != null, "열전 카드");
|
|
// ◀ ▶ = 영웅 화면 순서 · 열전 없는 영웅 = 준비 중
|
|
Find(og, "Next").onClick.Invoke();
|
|
Assert.AreEqual(og.HeroDetail.HeroId, AwakenWindowsHeroOf(og), "넘김 = 영웅 화면도 같이");
|
|
HeroDb.Hero none = null;
|
|
foreach (var o in owned)
|
|
if (db.ChronicleOf(o.id).Count == 0) none = o;
|
|
if (none != null)
|
|
{
|
|
og.ShowHero(none.id);
|
|
yield return null;
|
|
HeroInfoWindow.Open(og, none.id);
|
|
Find(og, "TabBio").onClick.Invoke();
|
|
Assert.IsNotNull(FindText(og, "BioEmpty", "T"), "열전 준비 중");
|
|
}
|
|
og.CloseModal();
|
|
}
|
|
|
|
static string AwakenWindowsHeroOf(OutGameRoot og)
|
|
{
|
|
return og.HeroDetail.HeroId;
|
|
}
|
|
|
|
/// <summary>목업 대조 캡처(Logs/heroinfo_capture/ · 직접 실행) — 01 능력치 · 02 공격력 내역 · 03 열전(관우).</summary>
|
|
[UnityTest, Explicit]
|
|
public IEnumerator Capture_InfoScreens()
|
|
{
|
|
yield return Boot();
|
|
string dir = Path.Combine(Path.GetDirectoryName(Application.dataPath), "Logs", "heroinfo_capture");
|
|
Directory.CreateDirectory(dir);
|
|
var og = OutGameRoot.Instance;
|
|
var s = og.Session;
|
|
var cam = og.Cam != null ? og.Cam : Camera.main;
|
|
Func<string, IEnumerator> shot = name => CaptureUtil.Capture(cam, 1080, 1920, Path.Combine(dir, name + ".png"));
|
|
var h = s.Def("guanyu");
|
|
if (h == null || s.Save.Hero(h.id) == null) h = s.Owned(false)[0];
|
|
og.ShowHero(h.id);
|
|
yield return new WaitForSecondsRealtime(0.4f);
|
|
yield return shot("00_detail"); // 영웅 상세(메뉴 4 버튼 · 하단 탭 · PD 2026-11-20 재설계 확인)
|
|
HeroInfoWindow.Open(og, h.id);
|
|
yield return new WaitForSecondsRealtime(0.4f);
|
|
yield return shot("01_info_stats");
|
|
Find(og, "Base_atk").onClick.Invoke();
|
|
yield return new WaitForSecondsRealtime(0.3f);
|
|
yield return shot("02_info_tip");
|
|
Find(og, "BdClose").onClick.Invoke();
|
|
Find(og, "TabBio").onClick.Invoke();
|
|
yield return new WaitForSecondsRealtime(0.3f);
|
|
yield return shot("03_info_bio");
|
|
og.CloseModal();
|
|
}
|
|
}
|
|
}
|