using System;
using System.Collections.Generic;
using UnityEngine;
namespace TKS.OutGame
{
///
/// 컨텐츠별 재화 배치 표 4장(PD 2026-11-24 · 개발 요청서 「재화배치」 §1) — chest_drop(수급처 × 구간별 보물 상자 등급 가중치) ·
/// chest_loot(상자 등급별 내용 줄 · 열면 그 가운데 하나) · hard_mode(장별 출정 하드 난이도) · hero_unlock(태생 ★ → 영입 조각).
/// 임포트 = TKS/Import OutGame Data(OutGameTables.Goods.cs · 참조 오류가 있으면 자산 불변) · 규칙 = GoodsRules.
///
public class GoodsDb : ScriptableObject
{
/// 상자가 나왔을 때의 등급 가중치 한 줄(s_source · n_from~n_to 구간 · f_<상자 id> 칸).
[Serializable]
public class ChestDrop
{
public string source = "";
public int from;
public int to;
public string[] chests = new string[0];
public float[] weights = new float[0];
}
///
/// 상자 내용 한 줄(확률 % · 수량 범위) — 상자 1개를 열면 그 상자의 줄 가운데 하나만(상자마다 f_pct 합 100 · PD 2026-11-24 「한 번에 하나」).
/// item = 보상 낱말(gold · iron · blueprint · gem · tome_t<등급> …) 또는 treasure_<등급>(그 등급 보물 1개).
///
[Serializable]
public class ChestLoot
{
public string chest = "";
public string item = "";
public float pct;
public int min;
public int max;
}
/// 출정 하드 난이도 한 장(등급 가중치 · 군량 · 스테이지당 하루 횟수 · 적 능력치 배율 · 골드 · 경험 배율 · 보스 조각 % · 보물 상자 %).
[Serializable]
public class HardMode
{
public int chapter;
public string[] grades = new string[0];
public float[] weights = new float[0];
public int stamina;
public int staminaBoss;
public int dailyPerStage;
public float enemyMult = 1f;
public float goldExpMult = 1f;
public float bossShardPct;
public float chestPct;
}
[Serializable]
public class HeroUnlock
{
public int rarity;
public int shards;
}
public const string SourceStage = "stage_normal";
public const string SourceHard = "stage_hard";
public const string SourcePatrol = "patrol";
public const string SourceBandit = "bandit";
/// 공방 채굴(묻힌 상자 · 금강석 · 깊이 보상 · 구간 = 깊이 m · PD 2026-11-24).
public const string SourceMine = "mine";
public static readonly string[] Sources = { SourceStage, SourceHard, SourcePatrol, SourceBandit, SourceMine };
public List chestDrops = new List();
public List chestLoots = new List();
public List hardModes = new List();
public List heroUnlocks = new List();
/// 그 수급처 · 구간(장 또는 단계)의 등급 줄 — 구간 밖이면 가장 가까운 줄(표 끝을 넘는 장 = 마지막 구간) · 수급처가 없으면 null.
public ChestDrop DropFor(string source, int band)
{
ChestDrop best = null;
int bestGap = int.MaxValue;
foreach (var c in chestDrops)
{
if (c.source != source) continue;
int gap = band < c.from ? c.from - band : band > c.to ? band - c.to : 0;
if (gap < bestGap)
{
bestGap = gap;
best = c;
}
}
return best;
}
public List LootOf(string chest)
{
var res = new List();
foreach (var l in chestLoots)
if (l.chest == chest) res.Add(l);
return res;
}
/// 그 장의 하드 난이도 줄(없으면 null = 하드 없음).
public HardMode HardFor(int chapter)
{
foreach (var h in hardModes)
if (h.chapter == chapter) return h;
return null;
}
/// 태생 ★ 영웅을 조각으로 영입하는 데 드는 조각(표에 없으면 0 = 영입 불가).
public int UnlockShards(int rarity)
{
foreach (var u in heroUnlocks)
if (u.rarity == rarity) return u.shards;
return 0;
}
}
}