using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TKS.OutGame
{
///
/// 보급전 화면(컨텐츠 모드 기획 10판 ① · 2026-11-17) — **더미 UI**(PD 지시 「UI 레이아웃은 변경 될 수 있으므로 더미 UI 리소스」 · 개발 요청서 §G):
/// 지금 패널 · 버튼 · 글자만 쓴다. 담는 정보와 흐름 = 던전 4곳(요일 · 남은 입장 · 규칙) → 단계 10(해금 · 최고 판정 · 도전 · 소탕) · 광고 추가 입장 · 그날 완료 · 주간 도장.
/// 풍경형 연무장(성 안 풍경 · 연병장 = 보급전) 그림이 오면 이 화면의 진입만 바꾼다(기능 = SupplyRules · SupplyBattle 그대로).
///
public partial class ArenaScreen
{
/// 단계 목록을 보는 던전(null = 던전 목록).
string supplyPick;
void BuildSupply()
{
ContentTables.Reload();
if (supplyPick != null) BuildSupplyTiers(supplyPick);
else BuildSupplyList();
}
void BuildSupplyList()
{
var db = S.Db;
var d = S.Save;
var now = S.Now;
Title("보급전");
var s = d.supply;
var dungeons = SupplyData.AllDungeons();
int open = 0, done = 0;
foreach (var dg in dungeons)
if (SupplyRules.OpenToday(dg, now))
{
open++;
if (s.doneDay == EconomyRules.DayKey(now) && s.doneIds.Contains(dg.id)) done++;
}
int stampNeed = ContentTables.Int(SupplyData.Mode, "weekly_stamp_need");
int stampDays = s.stampWeek == ArenaRules.WeekKey(now) ? s.stampDays.Count : 0;
string head = "오늘 = " + DayKo(SupplyRules.Weekday(now)) + "요일 · 오늘 완료 " + done + " / " + open + (s.doneBonus && s.doneDay == EconomyRules.DayKey(now) ? " (보너스 받음)" : "") +
" · 주간 도장 " + stampDays + " / " + stampNeed + (s.stampClaimed ? " (받음)" : "");
UiKit.Label(root, head, 30, UiKit.InkSoft, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -116f), new Vector2(1032f, 50f), false);
if (!SupplyRules.Unlocked(d))
UiKit.Label(root, ContentTables.Str(SupplyData.Mode, "unlock_stage") + " 클리어 뒤 열립니다", 34, UiKit.Red, TextAnchor.MiddleCenter, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -166f), new Vector2(1000f, 50f), false);
for (int i = 0; i < dungeons.Count; i++)
{
var dg = dungeons[i];
bool isOpen = SupplyRules.OpenToday(dg, now);
var box = Panel("Supply_" + dg.id, 220f + i * 300f, 284f);
box.GetComponent().color = isOpen ? UiKit.Paper : UiKit.Slot;
UiKit.Label(box, dg.nameKo + " 제한 " + dg.turnLimit + "턴", 48, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(28f, -12f), new Vector2(680f, 70f));
var days = new List();
string today = SupplyRules.Weekday(now);
foreach (var w in dg.weekdays) days.Add(w == today ? "" + DayKo(w) + "" : DayKo(w));
var rw = new List();
foreach (var k in dg.rewardKinds) rw.Add(RewardKo(k));
UiKit.Label(box, "요일 " + string.Join(" · ", days.ToArray()) + " 보상 " + string.Join(" · ", rw.ToArray()), 26, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(28f, -84f), new Vector2(700f, 44f), false);
UiKit.Label(box, dg.ruleKo, 24, UiKit.InkSoft, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(28f, -132f), new Vector2(680f, 140f), false);
int left = SupplyRules.Left(db, d, dg.id, now), limit = SupplyRules.Limit(db, d, dg.id, now);
string id = dg.id;
var b = UiKit.Btn("Go", box, isOpen ? "단계 선택\n남은 " + left + "/" + limit + "" : "닫힘", 38, isOpen ? UiKit.Red : UiKit.Disabled, UiKit.White, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-24f, 0f), new Vector2(280f, 170f), () =>
{
supplyPick = id;
Refresh();
});
b.interactable = isOpen && SupplyRules.Unlocked(d);
}
}
void BuildSupplyTiers(string id)
{
var db = S.Db;
var d = S.Save;
var now = S.Now;
var dg = SupplyData.GetDungeon(id);
if (dg == null)
{
supplyPick = null;
BuildSupplyList();
return;
}
Title("보급전 — " + dg.nameKo);
int left = SupplyRules.Left(db, d, id, now), limit = SupplyRules.Limit(db, d, id, now);
var top = Panel("Head", 120f, 130f);
UiKit.Label(top, "남은 입장 " + left + " / " + limit + " · 판정 " + dg.gradeRuleKo + " · 소탕 = " + SupplyRules.SweepNeed(dg), 28, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(24f, 0f), new Vector2(700f, 110f), false);
int adMax = ContentTables.Int(SupplyData.Mode, "ad_entries_per_day");
int adGot = SupplyRules.AdGot(db, d, id, now);
var ad = UiKit.Btn("Ad", top, "광고 +1\n(시험 · " + adGot + "/" + adMax + ")", 30, UiKit.Grain, UiKit.White, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-16f, 0f), new Vector2(240f, 108f), () =>
{
Root.Toast(S.SupplyAd(id) ?? "입장 +1 (광고 SDK 미연동 · 시험 지급)");
Refresh();
});
ad.interactable = adGot < adMax;
var tiers = SupplyData.AllTiers();
float w = 508f, h = 236f;
for (int i = 0; i < tiers.Count; i++)
{
var t = tiers[i];
int tier = t.tier;
float x = 24f + (i % 2) * (w + 16f);
float y = 266f + (i / 2) * (h + 12f);
var cell = UiKit.Box("Tier" + tier, root, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(x, -y), new Vector2(w, h), UiKit.Paper);
UiKit.Border(cell, UiKit.Line, 3f);
bool open = SupplyRules.TierOpen(d, t);
if (!open) cell.color = UiKit.Slot;
string best = d.supply.Best(id, tier);
string bestKo = best.Length == 0 ? "기록 없음" : dg.gradeBy == "star" ? "★" + best : best + " 등급";
UiKit.Label(cell.transform, tier + "단계 · " + bestKo, 32, UiKit.Ink, TextAnchor.MiddleLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(16f, -8f), new Vector2(w - 32f, 48f));
string info = open ? "" : t.unlockStage + " 클리어 뒤 열림";
if (id == SupplyData.Tactics)
{
var ts = SupplyData.GetTactics(tier);
if (ts != null)
info = (info.Length > 0 ? info + "\n" : "") + ts.themeKo + " · " + ts.boardKo + (ts.rule != "none" ? "\n조건 " + ts.ruleKo : "") +
"\n과제 " + SupplyData.TaskText(ts.task1, ts.n1) + " / " + SupplyData.TaskText(ts.task2, ts.n2);
}
UiKit.Label(cell.transform, info, 22, UiKit.InkSoft, TextAnchor.UpperLeft, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(16f, -56f), new Vector2(w - 32f, 110f), false);
var why = SupplyRules.Can(db, d, id, tier, now);
var go = UiKit.Btn("Go", cell.transform, "도전", 30, why == null ? UiKit.Red : UiKit.Disabled, UiKit.White, new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(16f, 12f), new Vector2(230f, 62f), () => SupplyGo(id, tier));
go.interactable = why == null;
bool canSweep = why == null && SupplyData.SweepGrade(dg, best) != null;
var sw = UiKit.Btn("Sweep", cell.transform, "소탕", 30, canSweep ? UiKit.Dark : UiKit.Disabled, UiKit.White, new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-16f, 12f), new Vector2(230f, 62f), () => SupplySweep(id, tier));
sw.interactable = canSweep;
}
}
void SupplyGo(string id, int tier)
{
BalanceConfig.StageDef stage;
string why;
var rules = SupplyBattle.Create(Root.Battle.Config, id, tier, out stage, out why);
if (rules == null)
{
Root.Toast(why ?? "준비 실패");
return;
}
var w = S.SupplyEnter(id, tier);
if (w != null)
{
Root.Toast(w);
return;
}
Root.StartMode(SupplyRules.Kind, id, tier, stage, rules.TurnLimit, 2, rules);
}
void SupplySweep(string id, int tier)
{
S.SupplySweep(id, tier, (m, why) =>
{
if (why != null)
{
Root.Toast(why);
return;
}
Root.Modal(m.title, string.Join("\n", m.lines.ToArray()), new OutGameRoot.ModalButton("확인", UiKit.Dark, null));
if (page == 2) Refresh();
});
}
}
}