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

171 lines
6.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using UnityEngine;
namespace TKS.OutGame
{
/// <summary>
/// 스킬 표(skills.csv 전 열 + skill_levels.csv) = 스킬 DB. 영웅 화면 표시(A) + 전투 처리기(B · Runtime/Skills 의 SkillCatalog 가 effect_key·p1~p3·lv_scale 을 읽음).
/// skill_levels.csv(lv · books · gold) = levels(스킬 레벨 표 · 스킬 레벨업 비용).
/// </summary>
public class SkillInfoDb : ScriptableObject
{
[Serializable]
public class Skill
{
public string id;
public string heroId;
[Tooltip("active|passive")]
public string kind;
public string nameKo;
public string hanja;
public string trigger;
public int cooldown;
public int lvMax;
[Tooltip("desc_ko (끝 [ ] 메모 포함 원문)")]
public string descKo;
[Tooltip("effect_key 원문(효과 여럿 = ; 로 나열 · p1~p3 = 키 순서)")]
public string effectKey;
public float p1;
public float p2;
public float p3;
[Tooltip("p 칸이 비어 있지 않은가(bit0 = p1 · bit1 = p2 · bit2 = p3)")]
public int pMask;
[Tooltip("수치 × (1 + lv_scale·(lv−1))")]
public float lvScale;
[Tooltip("신규 처리기(반경 안 유닛 · HP 소모 · 이동 · 교전 반응 정지)")]
public bool needsImpl;
public string[] EffectKeys
{
get { return string.IsNullOrEmpty(effectKey) ? new string[0] : effectKey.Split(';'); }
}
public bool HasP(int i)
{
return (pMask & (1 << i)) != 0;
}
public float P(int i)
{
return i == 0 ? p1 : i == 1 ? p2 : p3;
}
}
[Serializable]
public class LevelCost
{
public int lv;
public int books;
public int gold;
}
/// <summary>skill_effects.csv 1행 = 스킬 효과 1줄(2026-11-10 #1112 · 키 · 대상 · 조건 · 지속 · p1~p3 · 뜻 = Runtime/Skills/SkillKeys).</summary>
[Serializable]
public class Effect
{
public string skillId;
public string key;
[Tooltip("빈칸 = 자신 · allies · camp:<진영>[:<병종>] · camp_male:<진영> · radius:<r> · range · aura")]
public string target;
[Tooltip("crit · vs_status · vs_bleed · vs_confused · vs_stunned · vs_type:<병종> · vs_male · vs_male_hero · vs_female_hero · turn_le:<n> · armed · unarmed")]
public string cond;
[Tooltip("0 = 상시·장착 중·1회 · n = n 라운드")]
public int dur;
public float p1;
public float p2;
public float p3;
public int pMask;
public string note;
public bool HasP(int i)
{
return (pMask & (1 << i)) != 0;
}
}
/// <summary>
/// enemy_skills.csv 1행 = 적 병종 · 계급 · 출정 장 구간 → 기본 액티브 · 패시브(PD 2026-11-21 「적 유닛도 기본적으론 1성 · 모든 유닛은 패시브와 액티브를 보유할 수 있어야」 ·
/// 기획 `적유닛_스킬_구성안_2026-11-22.md`). 스킬 정의 = skills.csv(hero_id 빈칸 = 공용 스킬) + skill_effects.csv.
/// </summary>
[Serializable]
public class EnemySkill
{
[Tooltip("infantry|cavalry|archer|spear|strategist")]
public string unitType;
[Tooltip("soldier(일반병)|general(이름 있는 무장)|boss")]
public string rank;
public int chFrom;
public int chTo;
public string skillActive;
public string skillPassive;
}
public const string RankSoldier = "soldier";
public const string RankGeneral = "general";
public const string RankBoss = "boss";
public List<Skill> skills = new List<Skill>();
public List<LevelCost> levels = new List<LevelCost>();
public List<Effect> effects = new List<Effect>();
public List<EnemySkill> enemies = new List<EnemySkill>();
/// <summary>
/// 적 1기의 기본 스킬 줄: 그 계급 줄이 없으면 한 단계 아래(boss → general → soldier) · 장 구간 안 줄 ·
/// 장 ≤ 0(연무장 등 장 정보 없는 전투) = 그 병종·계급의 가장 낮은 구간 줄 · 구간 밖 장(예 2부 11장~ · 줄 없음) = null(스킬 없음 · 구성안 §2).
/// </summary>
public EnemySkill EnemyFor(string unitType, string rank, int chapter)
{
string[] chain = rank == RankBoss ? new[] { RankBoss, RankGeneral, RankSoldier } : rank == RankGeneral ? new[] { RankGeneral, RankSoldier } : new[] { RankSoldier };
foreach (var rk in chain)
{
EnemySkill low = null;
foreach (var x in enemies)
{
if (x.unitType != unitType || x.rank != rk) continue;
if (chapter > 0 && chapter >= x.chFrom && chapter <= x.chTo) return x;
if (chapter <= 0 && (low == null || x.chFrom < low.chFrom)) low = x;
}
if (low != null) return low;
}
return null;
}
public Skill Get(string id)
{
if (string.IsNullOrEmpty(id)) return null;
foreach (var s in skills)
if (s.id == id) return s;
return null;
}
/// <summary>그 레벨이 되는 비용(skill_levels.csv lv 행 · 없으면 null = 최고).</summary>
public LevelCost CostTo(int lv)
{
foreach (var c in levels)
if (c.lv == lv) return c;
return null;
}
public int MaxLevel
{
get
{
int m = 1;
foreach (var c in levels) m = Mathf.Max(m, c.lv);
return m;
}
}
/// <summary>표시용 설명 — 끝의 [p1 … ] 개발 메모를 뺀다.</summary>
public static string DisplayDesc(Skill s)
{
if (s == null || string.IsNullOrEmpty(s.descKo)) return "";
var d = s.descKo;
int b = d.LastIndexOf('[');
if (b > 0 && d.TrimEnd().EndsWith("]")) d = d.Substring(0, b);
return d.Trim();
}
}
}