ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Trade/TradeData.cs

149 lines
6.8 KiB
C#
Raw Normal View History

거래 상품 · 거래 UI 재설계 — 탭 4개(명장 등용 · 패키지 · 상점 · 패스) · 성장 패스 3권 · 월정액 2장 · 패키지 · 오늘의 상점 9칸 · 보옥 · 골드 · 누적 결제 · 시험 결제(PD 2026-11-26 「커밋 · 푸시」) - 표 = Resources/ContentModes/trade_*.csv 11장(기획 tables/_trade_v1 사본 · 값 그대로) · 새 낱말 supply_ticket(goods_awaken_evolve) · hero_r3_pick · 누적 결제 꾸미기 4종(costume_items) - 규칙 = OutGame/Trade(TradeRules · TradeData · TradeState · TradeStore = 기기 세이브 모드 시험 결제 · 구글 플레이 = 인터페이스만) · 세이브 SaveData.trade · 서버 모드 = 막음(후속) - 화면(PD 확정안) = 패키지 1차 A + V1 양피지 · 상점 A-2 + V2 인트로 게시판 · 패스 A-2 + V4 주문서 묶음 · 월정액 = 훈련장 배너 짜임 · 위 탭 = 명패 · 글자 = UI/Trade/trade_text.csv 키 - 그림 = 그림 세션 납품 37장(art · icons · 꾸미기 · 뽑기 · 훈련장 화풍으로 다시 그림) · 판 그림 8장(UI/Trade/ui) = 시안 임시 - 정리 = 보물 상자 탭 · 승급 장비 상점 · 떠돌이 상인 창 · 스텁 버튼 삭제 · 상자 포인트 구매 → 보물 > 상자 · 광고 제거 · 월정액 혜택 연결 · 보급전 입장권 1장 = 1회 더 - 시험 = TradeTests 14 통과 · UILayerTests 캔버스 통과 - 다른 세션 미커밋 변경은 넣지 않음(OutGameRoot · UICaptureDriver = 이 작업 줄만) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 13:59:28 +00:00
using System;
using System.Collections.Generic;
using System.Globalization;
namespace TKS.OutGame
{
/// <summary>
/// 거래 상품 표(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_&lt;s_id&gt;.
/// </summary>
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";
/// <summary>보옥 환산표(가치 배수 표시용 · 기획 value_conv 사본).</summary>
public const string ValueConv = "trade_value_conv";
public static readonly string[] Tables = { Packages, Monthly, PassGrowth, PassRewards, Spend, ShopDaily, Gems, Golds, Tiers, Config, ValueConv };
/// <summary>꾸러미의 보옥 환산(value_conv n_gem_value × 수 · 표에 없는 낱말 = 0).</summary>
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;
}
/// <summary>가치 배수 = 보옥 환산 ÷ (가격 ÷ 1000 × value_gem_per_krw1000) · 0 = 계산 못 함.</summary>
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;
}
/// <summary>글자 표(로컬라이징 키 · UiText).</summary>
public const string TextTable = "UI/Trade/trade_text";
/// <summary>그림 경로(요청서 4절 · 그림 세션 약속) — 배너 · 카드 · 권 · 월정액 · 팝업 / 아이콘.</summary>
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<ContentRow> 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; }
/// <summary>가격 단계 → 원화(표시 · 누적 결제 · 0 = 없는 단계).</summary>
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));
}
/// <summary>상품 하나(s_id) → 종류(pkg · monthly · pass · gem · null).</summary>
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;
}
/// <summary>결제 상품의 가격 단계(없으면 "").</summary>
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));
}
/// <summary>「키:수;키:수|키:수」 → 날(|)별 꾸러미 문자열(첫 결제 = 3일 · 그 밖 = 1개).</summary>
public static List<string> Days(string items)
{
var res = new List<string>();
if (string.IsNullOrEmpty(items)) return res;
foreach (var p in items.Split('|')) res.Add(p.Trim());
return res;
}
/// <summary>꾸러미 → (키, 수) 순서 목록(같은 키 = 합침 없음 · 표 순서 그대로).</summary>
public static List<KeyValuePair<string, int>> Items(string parts)
{
var res = new List<KeyValuePair<string, int>>();
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<string, int>(kv[0].Trim(), n));
}
return res;
}
/// <summary>「키:수;키:수」 → 사전(혜택 l_perks).</summary>
public static Dictionary<string, float> Map(string s)
{
return ContentTables.ParseMap(s);
}
}
}