174 lines
11 KiB
C#
174 lines
11 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Globalization;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace TKS.OutGame
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 컨텐츠별 재화 배치 표 4장 해석·검증(PD 2026-11-24 · 개발 요청서 「재화배치」 §1 · §3) — chest_drop · chest_loot · hard_mode · hero_unlock → GoodsDb.
|
||
|
|
/// 검증 = 필수 칸 · 수급처 낱말 · 상자 id(chests) · 내용 낱말(GoodsRules.Known = 재화 · 비서 · 장비 등급) · 장비 등급(gear_grades) · 하드 줄 = 스테이지 드랍 장 전부 ·
|
||
|
|
/// 하드 보스 조각 영웅(stage_drop l_hard_shard_hero → heroes) · 영입 조각 = 영웅 태생 ★ 전부.
|
||
|
|
/// </summary>
|
||
|
|
public static partial class OutGameTables
|
||
|
|
{
|
||
|
|
public static readonly string[] GoodsFiles = { "chest_drop.csv", "chest_loot.csv", "hard_mode.csv", "hero_unlock.csv" };
|
||
|
|
|
||
|
|
static GoodsDb ParseGoods(Dictionary<string, List<Dictionary<string, string>>> rows, OutGameData d, List<string> e)
|
||
|
|
{
|
||
|
|
var t = ScriptableObject.CreateInstance<GoodsDb>();
|
||
|
|
|
||
|
|
const string fd = "chest_drop.csv";
|
||
|
|
if (Cols(rows[fd], fd, e, "s_source", "n_from", "n_to"))
|
||
|
|
{
|
||
|
|
// 등급 칸 = f_<상자 id>(chests 표 순서) — 표에 있는 칸만 읽는다
|
||
|
|
var chestCols = new List<string>();
|
||
|
|
if (d.Chests != null && rows[fd].Count > 0)
|
||
|
|
foreach (var c in d.Chests.chests)
|
||
|
|
if (rows[fd][0].ContainsKey("f_" + c.id)) chestCols.Add(c.id);
|
||
|
|
if (chestCols.Count == 0) e.Add(fd + ": 상자 등급 칸(f_<상자 id>)이 하나도 없음");
|
||
|
|
foreach (var key in rows[fd].Count > 0 ? new List<string>(rows[fd][0].Keys) : new List<string>())
|
||
|
|
if (key.StartsWith("f_", StringComparison.Ordinal) && !chestCols.Contains(key.Substring(2))) e.Add(fd + ": 칸 「" + key + "」 의 상자가 chests.csv 에 없음");
|
||
|
|
foreach (var r in rows[fd])
|
||
|
|
{
|
||
|
|
var c = new GoodsDb.ChestDrop { source = Get(r, "s_source"), from = Int(r, "n_from", fd, e), to = Int(r, "n_to", fd, e), chests = chestCols.ToArray(), weights = new float[chestCols.Count] };
|
||
|
|
string at = fd + " 행 " + Get(r, "#") + " " + c.source + " " + c.from + "~" + c.to;
|
||
|
|
if (Array.IndexOf(GoodsDb.Sources, c.source) < 0) e.Add(at + ": s_source = " + string.Join(" · ", GoodsDb.Sources) + " 가 아님");
|
||
|
|
if (c.from > c.to) e.Add(at + ": n_from > n_to");
|
||
|
|
float sum = 0f;
|
||
|
|
for (int i = 0; i < chestCols.Count; i++)
|
||
|
|
{
|
||
|
|
c.weights[i] = Float(r, "f_" + chestCols[i], fd, e);
|
||
|
|
if (c.weights[i] < 0f) e.Add(at + ": f_" + chestCols[i] + " 음수");
|
||
|
|
sum += c.weights[i];
|
||
|
|
}
|
||
|
|
if (sum <= 0f) e.Add(at + ": 가중치 합 0");
|
||
|
|
foreach (var o in t.chestDrops)
|
||
|
|
if (o.source == c.source && c.from <= o.to && o.from <= c.to) e.Add(at + ": 구간이 " + o.from + "~" + o.to + " 와 겹침");
|
||
|
|
t.chestDrops.Add(c);
|
||
|
|
}
|
||
|
|
foreach (var src in GoodsDb.Sources)
|
||
|
|
if (t.DropFor(src, 1) == null) e.Add(fd + ": 수급처 「" + src + "」 줄 없음");
|
||
|
|
}
|
||
|
|
|
||
|
|
const string fl = "chest_loot.csv";
|
||
|
|
if (Cols(rows[fl], fl, e, "s_chest", "s_item", "f_pct", "n_min", "n_max"))
|
||
|
|
{
|
||
|
|
var seen = new HashSet<string>();
|
||
|
|
foreach (var r in rows[fl])
|
||
|
|
{
|
||
|
|
var l = new GoodsDb.ChestLoot { chest = Get(r, "s_chest"), item = Get(r, "s_item"), pct = Float(r, "f_pct", fl, e), min = Int(r, "n_min", fl, e), max = Int(r, "n_max", fl, e) };
|
||
|
|
string at = fl + " 행 " + Get(r, "#") + " " + l.chest + " · " + l.item;
|
||
|
|
if (!seen.Add(l.chest + "|" + l.item)) e.Add(at + ": 중복");
|
||
|
|
if (d.Chests == null || d.Chests.Get(l.chest) == null) e.Add(at + ": 상자 「" + l.chest + "」 가 chests.csv 에 없음");
|
||
|
|
if (!GoodsRules.Known(d, l.item)) e.Add(at + ": 내용 「" + l.item + "」 = 지급하는 법을 코드가 모름(GoodsRules)");
|
||
|
|
if (l.pct <= 0f || l.pct > 100f) e.Add(at + ": f_pct " + l.pct.ToString("0.##", CultureInfo.InvariantCulture) + " = 0 초과 100 이하가 아님");
|
||
|
|
if (l.min < 1 || l.min > l.max) e.Add(at + ": 수량 범위 " + l.min + "~" + l.max + " 이상");
|
||
|
|
t.chestLoots.Add(l);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const string fh = "hard_mode.csv";
|
||
|
|
if (Cols(rows[fh], fh, e, "n_chapter", "l_grade", "l_weight", "n_stamina", "n_stamina_boss", "n_daily_per_stage", "f_enemy_mult", "f_gold_exp_mult", "f_boss_shard_pct", "f_chest_pct"))
|
||
|
|
{
|
||
|
|
var seen = new HashSet<string>();
|
||
|
|
foreach (var r in rows[fh])
|
||
|
|
{
|
||
|
|
var h = new GoodsDb.HardMode
|
||
|
|
{
|
||
|
|
chapter = Int(r, "n_chapter", fh, e), grades = Get(r, "l_grade").Split(';'), stamina = Int(r, "n_stamina", fh, e), staminaBoss = Int(r, "n_stamina_boss", fh, e),
|
||
|
|
dailyPerStage = Int(r, "n_daily_per_stage", fh, e), enemyMult = Float(r, "f_enemy_mult", fh, e), goldExpMult = Float(r, "f_gold_exp_mult", fh, e),
|
||
|
|
bossShardPct = Float(r, "f_boss_shard_pct", fh, e), chestPct = Float(r, "f_chest_pct", fh, e),
|
||
|
|
};
|
||
|
|
string at = fh + " " + h.chapter + "장";
|
||
|
|
if (!Unique(seen, h.chapter.ToString(CultureInfo.InvariantCulture), fh, r, e)) continue;
|
||
|
|
var ws = Get(r, "l_weight").Split(';');
|
||
|
|
h.weights = new float[ws.Length];
|
||
|
|
float sum = 0f;
|
||
|
|
for (int i = 0; i < ws.Length; i++)
|
||
|
|
{
|
||
|
|
if (!float.TryParse(ws[i], NumberStyles.Float, CultureInfo.InvariantCulture, out h.weights[i]) || h.weights[i] < 0f) e.Add(at + ": l_weight 「" + ws[i] + "」 숫자가 아님");
|
||
|
|
sum += h.weights[i];
|
||
|
|
}
|
||
|
|
if (ws.Length != h.grades.Length) e.Add(at + ": l_grade 수 " + h.grades.Length + " ≠ l_weight 수 " + ws.Length);
|
||
|
|
if (sum <= 0f) e.Add(at + ": 가중치 합 0");
|
||
|
|
foreach (var g in h.grades)
|
||
|
|
if (d.Gear == null || d.Gear.GradeOf(g) == null) e.Add(at + ": 등급 「" + g + "」 가 gear_grades 에 없음");
|
||
|
|
if (h.stamina < 0 || h.staminaBoss < 0 || h.dailyPerStage < 1) e.Add(at + ": 군량 · 하루 횟수 값 이상");
|
||
|
|
if (h.enemyMult <= 0f || h.goldExpMult <= 0f) e.Add(at + ": 배율은 0 보다 커야 함");
|
||
|
|
if (h.bossShardPct < 0f || h.bossShardPct > 100f || h.chestPct < 0f || h.chestPct > 100f) e.Add(at + ": 확률 = 0~100 아님");
|
||
|
|
t.hardModes.Add(h);
|
||
|
|
}
|
||
|
|
// 지정 장비 = 하드 등급마다 있어야 한다 · 하드 보스 조각 영웅 = heroes 의 영웅
|
||
|
|
if (d.Gear != null)
|
||
|
|
foreach (var s in d.Gear.stageDrops)
|
||
|
|
{
|
||
|
|
var h = t.HardFor(s.chapter);
|
||
|
|
if (h == null) continue;
|
||
|
|
foreach (var k in s.kinds)
|
||
|
|
foreach (var g in h.grades)
|
||
|
|
if (d.Gear.Find(s.unitType, k, g) == null) e.Add(fh + ": " + s.chapter + "-" + s.stage + " 하드 지정 장비 " + s.unitType + " · " + k + " · " + g + " 없음");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (d.Gear != null && d.Heroes != null)
|
||
|
|
foreach (var s in d.Gear.stageDrops)
|
||
|
|
foreach (var id in s.hardShardHeroes)
|
||
|
|
{
|
||
|
|
var hero = d.Heroes.Get(id);
|
||
|
|
if (hero == null || hero.isSoldier) e.Add("stage_drop.csv: " + s.chapter + "-" + s.stage + " l_hard_shard_hero 「" + id + "」 가 heroes.csv 의 영웅이 아님");
|
||
|
|
}
|
||
|
|
|
||
|
|
const string fu = "hero_unlock.csv";
|
||
|
|
if (Cols(rows[fu], fu, e, "n_rarity", "n_shards"))
|
||
|
|
{
|
||
|
|
var seen = new HashSet<string>();
|
||
|
|
foreach (var r in rows[fu])
|
||
|
|
{
|
||
|
|
var u = new GoodsDb.HeroUnlock { rarity = Int(r, "n_rarity", fu, e), shards = Int(r, "n_shards", fu, e) };
|
||
|
|
if (!Unique(seen, u.rarity.ToString(CultureInfo.InvariantCulture), fu, r, e)) continue;
|
||
|
|
if (u.shards < 1) e.Add(fu + ": ★" + u.rarity + " n_shards < 1");
|
||
|
|
t.heroUnlocks.Add(u);
|
||
|
|
}
|
||
|
|
if (d.Heroes != null)
|
||
|
|
foreach (var h in d.Heroes.heroes)
|
||
|
|
if (!h.isSoldier && t.UnlockShards(h.rarity) <= 0)
|
||
|
|
{
|
||
|
|
e.Add(fu + ": 태생 ★" + h.rarity + " 줄 없음(" + h.id + ")");
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return t;
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>보상 칸 낱말 검사(전체 해석 뒤 · 재화 표가 있어야 낱말을 안다) — 임무 구간 보상 · 탑 층 첫 클리어 추가 보상.</summary>
|
||
|
|
static void CheckRewardWords(OutGameData d, List<string> e)
|
||
|
|
{
|
||
|
|
if (d.Missions != null)
|
||
|
|
foreach (var p in d.Missions.rewards) CheckParts(p.reward, d, "mission_point_rewards.csv: " + p.kind + " " + p.step + "단", false, e);
|
||
|
|
if (d.Tower != null)
|
||
|
|
foreach (var f in d.Tower.floors) CheckParts(f.firstExtra, d, "tower.csv: " + f.floor + "층 l_first_extra", true, e);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>「키:수;키:수」 보상 칸 검사(임무 구간 · 탑 층 추가 보상) — 낱말 = GoodsRules.Known · 수 ≥ 1.</summary>
|
||
|
|
static void CheckParts(string parts, OutGameData d, string at, bool allowEmpty, List<string> e)
|
||
|
|
{
|
||
|
|
if (string.IsNullOrEmpty(parts))
|
||
|
|
{
|
||
|
|
if (!allowEmpty) e.Add(at + ": 보상 칸 비었음");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
foreach (var p in parts.Split(';'))
|
||
|
|
{
|
||
|
|
var kv = p.Split(':');
|
||
|
|
int n;
|
||
|
|
if (kv.Length != 2 || !int.TryParse(kv[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out n) || n < 1)
|
||
|
|
{
|
||
|
|
e.Add(at + ": 보상 「" + p + "」 = 낱말:수 가 아님");
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
if (!GoodsRules.Known(d, kv[0])) e.Add(at + ": 보상 낱말 「" + kv[0] + "」 = 지급하는 법을 코드가 모름(GoodsRules)");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|