ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Data/AwakenDb.cs

229 lines
6.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;
namespace TKS.OutGame
{
/// <summary>
/// 각성 · 진화 · 스킬 강화 표 10장(2026-11-20 요청서 §1 · §5 2차 · 기획 tables/ 사본) — awaken_config · awaken_cost · awaken_grades · awaken_stats · awaken_slots ·
/// evolve_config · evolve_items · goods_awaken_evolve · skill_upgrade · skill_config.
/// ★ 별 재료 · 최대 레벨 = evolve_stars → EvolveTable · 각성 칸 = awaken_slots(승급 장비 등급). 임포트 = TKS/Import Awaken(또는 전체) → Resources/OutGame/AwakenDb.asset · 값은 전부 표(C45).
/// </summary>
public class AwakenDb : ScriptableObject
{
[Serializable]
public class KV
{
public string key = "";
public string value = "";
}
[Serializable]
public class Cost
{
public int locks;
public int stone;
}
[Serializable]
public class Grade
{
public string grade = "";
public int order;
public float weight;
public string color = "";
public string nameKo = "";
}
[Serializable]
public class Stat
{
public string stat = "";
public string nameKo = "";
public string unit = "";
public float weight;
[Tooltip("등급 순서(n_order) 별 최소 · 최대")]
public float[] min = new float[0];
public float[] max = new float[0];
}
[Serializable]
public class Item
{
public int id;
public string key = "";
public string nameKo = "";
public string faction = "";
public int tier;
public int priceShard;
public int pricePoint;
public int weekLimit;
}
[Serializable]
public class Good
{
public int id;
public string key = "";
public string nameKo = "";
public string kind = "";
public string wallet = "";
}
/// <summary>각성 칸 1줄(awaken_slots · 2차) — 승급 장비 6칸을 모두 gearGrade 장비로 채우면 열림 · 빈 값 = 열리지 않음.</summary>
[Serializable]
public class Slot
{
public int slot;
public string gearGrade = "";
public string nameKo = "";
}
/// <summary>스킬 강화 1단계(skill_upgrade · 2차) — from → to · 그 영웅 조각 수 · 필요한 영웅 레벨.</summary>
[Serializable]
public class SkillStep
{
public int from;
public int to;
public int shard;
public int needHeroLv;
}
public List<KV> config = new List<KV>();
public List<KV> evolveConfig = new List<KV>();
public List<KV> skillConfig = new List<KV>();
public List<Cost> costs = new List<Cost>();
public List<Grade> grades = new List<Grade>();
public List<Stat> stats = new List<Stat>();
public List<Item> items = new List<Item>();
public List<Good> goods = new List<Good>();
public List<Slot> slots = new List<Slot>();
public List<SkillStep> skillSteps = new List<SkillStep>();
static string Find(List<KV> l, string key)
{
foreach (var c in l)
if (c.key == key) return c.value;
return "";
}
public string Cfg(string key)
{
return Find(config, key);
}
public string EvCfg(string key)
{
return Find(evolveConfig, key);
}
public string SkCfg(string key)
{
return Find(skillConfig, key);
}
/// <summary>스킬 lv → lv+1 단계(없으면 null = 최고).</summary>
public SkillStep StepTo(int lv)
{
foreach (var s in skillSteps)
if (s.to == lv) return s;
return null;
}
/// <summary>만능 조각 키(skill_config substitute = goods s_key).</summary>
public string UnivKey
{
get { return SkCfg("substitute"); }
}
public static int ToInt(string s)
{
int v;
return int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out v) ? v : 0;
}
/// <summary>각성 재화 키(awaken_config currency = goods 의 s_key).</summary>
public string StoneKey
{
get { return Cfg("currency"); }
}
/// <summary>등용 포인트 키(goods e_kind Point 의 s_key).</summary>
public string PointKey
{
get
{
foreach (var g in goods)
if (g.kind == "Point") return g.key;
return "";
}
}
public int CostFor(int locks)
{
foreach (var c in costs)
if (c.locks == locks) return c.stone;
return -1;
}
public Grade GradeOf(string g)
{
foreach (var x in grades)
if (x.grade == g) return x;
return null;
}
public Stat StatOf(string s)
{
foreach (var x in stats)
if (x.stat == s) return x;
return null;
}
public Item ItemOf(string faction, int tier)
{
foreach (var x in items)
if (x.faction == faction && x.tier == tier) return x;
return null;
}
public Item ItemByKey(string key)
{
foreach (var x in items)
if (x.key == key) return x;
return null;
}
public Good GoodOf(string key)
{
foreach (var g in goods)
if (g.key == key) return g;
return null;
}
/// <summary>등급 가중치 합(확률 % = 가중치 / 합).</summary>
public float GradeWeightSum
{
get
{
float s = 0f;
foreach (var g in grades) s += g.weight;
return s;
}
}
/// <summary>진영 순서(evolve_items 첫 등장 순 = 촉 · 위 · 오 · 군웅).</summary>
public List<string> Factions
{
get
{
var l = new List<string>();
foreach (var x in items)
if (!l.Contains(x.faction)) l.Add(x.faction);
return l;
}
}
}
}