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

113 lines
4.3 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>
/// 컨텐츠별 재화 배치 표 4장(PD 2026-11-24 · 개발 요청서 「재화배치」 §1) — chest_drop(수급처 × 구간별 보물 상자 등급 가중치) ·
/// chest_loot(상자 등급별 더해지는 내용 줄) · hard_mode(장별 출정 하드 난이도) · hero_unlock(태생 ★ → 영입 조각).
/// 임포트 = TKS/Import OutGame Data(OutGameTables.Goods.cs · 참조 오류가 있으면 자산 불변) · 규칙 = GoodsRules.
/// </summary>
public class GoodsDb : ScriptableObject
{
/// <summary>상자가 나왔을 때의 등급 가중치 한 줄(s_source · n_from~n_to 구간 · f_&lt;상자 id&gt; 칸).</summary>
[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];
}
/// <summary>상자를 열 때 더해지는 내용 한 줄(확률 % · 수량 범위) — 보물 굴림 · 골드는 chests 표 그대로.</summary>
[Serializable]
public class ChestLoot
{
public string chest = "";
public string item = "";
public float pct;
public int min;
public int max;
}
/// <summary>출정 하드 난이도 한 장(등급 가중치 · 군량 · 스테이지당 하루 횟수 · 적 능력치 배율 · 골드 · 경험 배율 · 보스 조각 % · 보물 상자 %).</summary>
[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";
public static readonly string[] Sources = { SourceStage, SourceHard, SourcePatrol, SourceBandit };
public List<ChestDrop> chestDrops = new List<ChestDrop>();
public List<ChestLoot> chestLoots = new List<ChestLoot>();
public List<HardMode> hardModes = new List<HardMode>();
public List<HeroUnlock> heroUnlocks = new List<HeroUnlock>();
/// <summary>그 수급처 · 구간(장 또는 단계)의 등급 줄 — 구간 밖이면 가장 가까운 줄(표 끝을 넘는 장 = 마지막 구간) · 수급처가 없으면 null.</summary>
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<ChestLoot> LootOf(string chest)
{
var res = new List<ChestLoot>();
foreach (var l in chestLoots)
if (l.chest == chest) res.Add(l);
return res;
}
/// <summary>그 장의 하드 난이도 줄(없으면 null = 하드 없음).</summary>
public HardMode HardFor(int chapter)
{
foreach (var h in hardModes)
if (h.chapter == chapter) return h;
return null;
}
/// <summary>태생 ★ 영웅을 조각으로 영입하는 데 드는 조각(표에 없으면 0 = 영입 불가).</summary>
public int UnlockShards(int rarity)
{
foreach (var u in heroUnlocks)
if (u.rarity == rarity) return u.shards;
return 0;
}
}
}