using System; using System.Collections.Generic; using System.Globalization; namespace TKS.OutGame { /// /// 거래 상품 표(PD 2026-11-26 · 기획 `tables/_trade_v1` 사본 · Resources/ContentModes/trade_*.csv · 실행 중에 읽음) — 값은 전부 표(C45 · 가격 = trade_price_tiers 만 바꾸면 됨). /// 게임 사본에만 덧붙인 칸(값 아님 · 코드 열쇠): packages n_open_chapter · s_popup_stage · s_art · s_banner / monthly l_perks · s_art / pass_growth s_open · s_art / gem · gold s_art. /// 상품 id(구글 플레이) = tks_<s_id>. /// public static class TradeData { public const string Packages = "trade_packages"; public const string Monthly = "trade_monthly"; public const string PassGrowth = "trade_pass_growth"; public const string PassRewards = "trade_pass_rewards"; public const string Spend = "trade_spend_rewards"; public const string ShopDaily = "trade_shop_daily"; public const string Gems = "trade_gem_products"; public const string Golds = "trade_gold_products"; public const string Tiers = "trade_price_tiers"; public const string Config = "trade_config"; /// 보옥 환산표(가치 배수 표시용 · 기획 value_conv 사본). public const string ValueConv = "trade_value_conv"; public static readonly string[] Tables = { Packages, Monthly, PassGrowth, PassRewards, Spend, ShopDaily, Gems, Golds, Tiers, Config, ValueConv }; /// 꾸러미의 보옥 환산(value_conv n_gem_value × 수 · 표에 없는 낱말 = 0). public static float GemValue(string parts) { float v = 0f; foreach (var kv in Items(parts)) { var r = ContentTables.Find(ValueConv, "s_key", kv.Key); if (r != null) v += r.F("n_gem_value") * kv.Value; } return v; } /// 가치 배수 = 보옥 환산 ÷ (가격 ÷ 1000 × value_gem_per_krw1000) · 0 = 계산 못 함. public static float ValueMult(float gemValue, int krw) { float per = Cfg("value_gem_per_krw1000", 100f); return krw > 0 && per > 0f ? gemValue / (krw / 1000f * per) : 0f; } /// 글자 표(로컬라이징 키 · UiText). public const string TextTable = "UI/Trade/trade_text"; /// 그림 경로(요청서 4절 · 그림 세션 약속) — 배너 · 카드 · 권 · 월정액 · 팝업 / 아이콘. public const string ArtDir = "UI/Trade/art/"; public const string IconDir = "UI/Trade/icons/"; public const string ProductPrefix = "tks_"; // 묶음(packages s_group) · 초기화(s_reset) public const string GFirst = "first", GAdFree = "adfree", GDaily = "daily", GWeekly = "weekly", GMonthly = "monthly", GChapter = "chapter"; public const string RNone = "none", RDaily = "daily", RWeekly = "weekly", RMonthly = "monthly"; public const string CurGold = "gold", CurGem = "gem", CurAd = "ad"; public static List Rows(string table) { return ContentTables.Rows(table); } public static ContentRow Package(string id) { return ContentTables.Find(Packages, "s_id", id); } public static ContentRow MonthlyRow(string id) { return ContentTables.Find(Monthly, "s_id", id); } public static ContentRow Pass(string id) { return ContentTables.Find(PassGrowth, "s_pass", id); } public static ContentRow Gem(string id) { return ContentTables.Find(Gems, "s_id", id); } public static ContentRow Gold(string id) { return ContentTables.Find(Golds, "s_id", id); } public static string ProductId(string sid) { return ProductPrefix + sid; } /// 가격 단계 → 원화(표시 · 누적 결제 · 0 = 없는 단계). public static int Krw(string tier) { var r = ContentTables.Find(Tiers, "s_tier", tier); return r != null ? r.I("n_krw") : 0; } public static float Usd(string tier) { var r = ContentTables.Find(Tiers, "s_tier", tier); return r != null ? r.F("n_usd") : 0f; } public static float Cfg(string key, float def) { var r = ContentTables.Find(Config, "key", key); float v; return r != null && ContentTables.TryNum(r.S("value"), out v) ? v : def; } public static int CfgInt(string key, int def) { return (int)Math.Round(Cfg(key, def)); } /// 상품 하나(s_id) → 종류(pkg · monthly · pass · gem · null). public static string KindOf(string sid) { if (Package(sid) != null) return "pkg"; if (MonthlyRow(sid) != null) return "monthly"; if (Pass(sid) != null) return "pass"; if (Gem(sid) != null) return "gem"; return null; } /// 결제 상품의 가격 단계(없으면 ""). public static string TierOf(string sid) { var r = Package(sid) ?? MonthlyRow(sid) ?? Gem(sid); if (r != null) return r.S("s_tier"); var p = Pass(sid); return p != null ? p.S("s_tier") : ""; } public static int PriceKrw(string sid) { return Krw(TierOf(sid)); } /// 「키:수;키:수|키:수」 → 날(|)별 꾸러미 문자열(첫 결제 = 3일 · 그 밖 = 1개). public static List Days(string items) { var res = new List(); if (string.IsNullOrEmpty(items)) return res; foreach (var p in items.Split('|')) res.Add(p.Trim()); return res; } /// 꾸러미 → (키, 수) 순서 목록(같은 키 = 합침 없음 · 표 순서 그대로). public static List> Items(string parts) { var res = new List>(); if (string.IsNullOrEmpty(parts)) return res; foreach (var part in parts.Split(';', '|')) { var kv = part.Split(':'); if (kv.Length != 2) continue; int n; if (!int.TryParse(kv[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out n)) continue; res.Add(new KeyValuePair(kv[0].Trim(), n)); } return res; } /// 「키:수;키:수」 → 사전(혜택 l_perks). public static Dictionary Map(string s) { return ContentTables.ParseMap(s); } } }