ThreeKingdomsSlingshot/Assets/Scripts/OutGame/Event/EventData.cs

308 lines
10 KiB
C#
Raw Normal View History

이벤트 화면 — 출석부(오픈 기념 7일 · 일일 14일) · 7일 특별 미션 · 행운 룰렛 · 이벤트 미션 · 선물 팩 팝업 · 특별 이벤트 「준비 중」 (PD 2026-11-19 「게임에 구현해」 · 시안 7장 event_attend/final/mock) PD 결정 4건(모두 추천안): - ① 로비 오른쪽 「이벤트」 버튼 · 기기 세이브 모드만(OutGameSession.EventAvailable · ServerSession = false → 준비 중 · 서버 이벤트 API = 따로) - ② 유료 선물 팩 = 「결제 준비 중」 토스트만(지급 0) · 광고 칸 = 시험 즉시 지급 하루 3회 - ③⑤ 값 = 시안 예시 그대로 게임 표 · 룰렛 판 = 시안 돌(흰 · 검은 · 최종 금 상감) · 등급 색 = 확률 정보 창에만 - ④ 하루 = 0시 · 접속일 기준(출석 = 접속한 날마다 1칸 · 일일 14일 = 다 받으면 새 회차 · 7일 미션 = 첫 접속일부터 하루 1일차 · 룰렛 = 표 날짜 · 문구 「오전 5시」 → 「0시」) - 규칙 표 Resources/Event/*.csv(event_config · items · kinds · attend · mission7(_steps) · roulette(_extra)) → EventData · EventRules · 세이브 SaveData.ev(EventState) - 화면 OutGame/Event/EventScreen(+ Attend · Mission · Roulette · EventSpin) · 화면 표 Resources/UI/Event/event_screen.csv · 글자 event_text.csv(그림에 글자 0) - 층(P41) = Bg(Static) · Page/Art(Static) · Page/Info(Event + 레이캐스터) · Page/Fx(Frame) · EventTabs(Event) · 부품 아틀라스 UI_Event - 미션 집계 = OutGameSession 동작 성공 경로마다 EventRules.Count 한 줄 · OutGameRoot(이벤트 화면 등록 · ShowEvents · OwnTabBar) · LobbyScreen(이벤트 버튼 + 받을 것 붉은 점) - 받은 칸 탈색 셰이더 Resources/UI/UiGray.shader · 세로 그러데이션 OutGame/UI/UiGradient · 임포트 분기 UnitArtImporter UiEventRoot - 공용 표 읽기 OutGame/UI/ScreenTable 함께 올림(이벤트 화면이 씀 · 같은 날 영웅 배경 · 편성 미커밋 작업에서 만든 파일) - 캡처 UICaptureDriver -uiOnly event_*(9장) · 테스트 EventTests 2 검증: 컴파일 오류 0 · EventTests 2/2 · OutGameTests.Lobby_Tabs_Back_ComingSoon 1/1 · UILayerTests.Canvases_SplitByUpdateRate_InputAndAtlas 1/1 · 캡처 9장 시안 대조 · Fable QA r1 PASS(B 0) → M 일괄 수정 · 이 커밋 묶음만(HEAD + 이벤트) 검증 사본 배치 컴파일 오류 0 섞인 파일(OutGameRoot · LobbyScreen · UICaptureDriver · CLAUDE.md)은 이벤트 부분만 올림 — 메뉴 숨김 · 팝업 글꼴 · 영웅 배경 · 편성 변경은 작업 트리에 그대로(미커밋) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 13:37:08 +00:00
using System.Collections.Generic;
using System.Globalization;
namespace TKS.OutGame
{
/// <summary>
/// 이벤트 규칙 표(PD 2026-11-19 「게임에 구현해」 · Resources/Event/*.csv · 값 = 시안 예시 · 기획 확정 전 · PD 결정 ③ 「예시 값 그대로」) — 코드에 값을 두지 않는다(C45).
/// event_config(기간 · 횟수) · event_items(보상 id → 지급 · 아이콘 · 이름) · event_kinds(미션 종류 → 글자 · 이동) · event_attend · event_mission7(+_steps) · event_roulette(+_extra).
/// </summary>
public static class EventData
{
public const string Dir = "Event/";
public class Reward
{
public string id;
public int n;
}
public class Item
{
public string id, kind, arg, icon, nameKey;
public int star;
}
public class Kind
{
public string id, textKey, go;
public bool state;
}
public class AttendDay
{
public string ev, mark;
public int day;
public List<Reward> rewards;
}
public class Mission
{
public int day, order, target, point;
public string kind, arg, textKey;
public List<Reward> rewards;
public string Key
{
get { return day.ToString(CultureInfo.InvariantCulture) + "-" + order.ToString(CultureInfo.InvariantCulture); }
}
}
public class Step
{
public int point;
public string icon;
public List<Reward> rewards;
}
public class Slot
{
public int slot;
public Reward reward;
public string frame, tag;
public float weight;
}
public class Extra
{
public string kind, sKind, arg, reset, textKey;
public int order, target, price, limit;
public List<Reward> rewards;
}
public const string TagFinal = "final";
public const string TagLimited = "limited";
static Dictionary<string, string> config;
static Dictionary<string, Item> items;
static Dictionary<string, Kind> kinds;
static List<AttendDay> attend;
static List<Mission> missions;
static List<Step> steps;
static List<Slot> slots;
static List<Extra> extras;
/// <summary>표를 다시 읽게 비운다(테스트 · 표 교체).</summary>
public static void Reset()
{
config = null;
items = null;
kinds = null;
attend = null;
missions = null;
steps = null;
slots = null;
extras = null;
}
static List<Dictionary<string, string>> Rows(string name)
{
return UiText.Rows(Dir + name) ?? new List<Dictionary<string, string>>();
}
static string V(Dictionary<string, string> r, string k)
{
string v;
return r.TryGetValue(k, out v) && v != null ? v.Trim() : "";
}
static int I(Dictionary<string, string> r, string k)
{
int v;
return int.TryParse(V(r, k), NumberStyles.Integer, CultureInfo.InvariantCulture, out v) ? v : 0;
}
static float F(Dictionary<string, string> r, string k)
{
float v;
return float.TryParse(V(r, k), NumberStyles.Float, CultureInfo.InvariantCulture, out v) ? v : 0f;
}
/// <summary>「id×수량;id×수량」 → 보상 목록(× 또는 x).</summary>
public static List<Reward> ParseRewards(string s)
{
var list = new List<Reward>();
if (string.IsNullOrEmpty(s)) return list;
foreach (var part in s.Split(';'))
{
var p = part.Trim();
if (p.Length == 0) continue;
int k = p.LastIndexOf('×');
if (k < 0) k = p.LastIndexOf('x');
int n = 1;
string id = p;
if (k > 0)
{
id = p.Substring(0, k).Trim();
int.TryParse(p.Substring(k + 1).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out n);
}
list.Add(new Reward { id = id, n = n });
}
return list;
}
// ---------- 설정 ----------
public static string Cfg(string key)
{
if (config == null)
{
config = new Dictionary<string, string>();
foreach (var r in Rows("event_config")) config[V(r, "s_key")] = V(r, "s_value");
}
string v;
return config.TryGetValue(key, out v) ? v : "";
}
public static int CfgInt(string key)
{
int v;
return int.TryParse(Cfg(key), NumberStyles.Integer, CultureInfo.InvariantCulture, out v) ? v : 0;
}
public static bool Loaded
{
get { return Cfg("att7_days").Length > 0; }
}
// ---------- 아이템 · 종류 ----------
public static Item ItemOf(string id)
{
if (items == null)
{
items = new Dictionary<string, Item>();
foreach (var r in Rows("event_items"))
{
var it = new Item { id = V(r, "s_id"), kind = V(r, "s_kind"), arg = V(r, "s_arg"), star = I(r, "n_star"), icon = V(r, "s_icon"), nameKey = V(r, "s_name_key") };
if (it.id.Length > 0) items[it.id] = it;
}
}
Item i;
return id != null && items.TryGetValue(id, out i) ? i : null;
}
public static Kind KindOf(string id)
{
if (kinds == null)
{
kinds = new Dictionary<string, Kind>();
foreach (var r in Rows("event_kinds"))
{
var k = new Kind { id = V(r, "s_kind"), state = V(r, "s_count") == "state", textKey = V(r, "s_text_key"), go = V(r, "s_go") };
if (k.id.Length > 0) kinds[k.id] = k;
}
}
Kind kd;
return id != null && kinds.TryGetValue(id, out kd) ? kd : null;
}
// ---------- 출석 · 미션 ----------
public static List<AttendDay> Attend(string ev)
{
if (attend == null)
{
attend = new List<AttendDay>();
foreach (var r in Rows("event_attend"))
attend.Add(new AttendDay { ev = V(r, "s_event"), day = I(r, "n_day"), rewards = ParseRewards(V(r, "s_rewards")), mark = V(r, "s_mark") });
attend.Sort((a, b) => a.day.CompareTo(b.day));
}
var res = new List<AttendDay>();
foreach (var a in attend)
if (a.ev == ev) res.Add(a);
return res;
}
public static List<Mission> Missions
{
get
{
if (missions == null)
{
missions = new List<Mission>();
foreach (var r in Rows("event_mission7"))
missions.Add(new Mission
{
day = I(r, "n_day"), order = I(r, "n_order"), kind = V(r, "s_kind"), arg = V(r, "s_arg"), target = I(r, "n_target"),
point = I(r, "n_point"), rewards = ParseRewards(V(r, "s_rewards")), textKey = V(r, "s_text_key"),
});
}
return missions;
}
}
public static List<Step> Steps
{
get
{
if (steps == null)
{
steps = new List<Step>();
foreach (var r in Rows("event_mission7_steps"))
steps.Add(new Step { point = I(r, "n_point"), icon = V(r, "s_icon"), rewards = ParseRewards(V(r, "s_rewards")) });
steps.Sort((a, b) => a.point.CompareTo(b.point));
}
return steps;
}
}
// ---------- 룰렛 ----------
public static List<Slot> Slots
{
get
{
if (slots == null)
{
slots = new List<Slot>();
foreach (var r in Rows("event_roulette"))
{
var rw = ParseRewards(V(r, "s_reward"));
slots.Add(new Slot { slot = I(r, "n_slot"), reward = rw.Count > 0 ? rw[0] : new Reward(), frame = V(r, "s_frame"), weight = F(r, "n_weight"), tag = V(r, "s_tag") });
}
slots.Sort((a, b) => a.slot.CompareTo(b.slot));
}
return slots;
}
}
public static Slot FinalSlot
{
get
{
foreach (var s in Slots)
if (s.tag == TagFinal) return s;
return null;
}
}
static List<Extra> Extras
{
get
{
if (extras == null)
{
extras = new List<Extra>();
foreach (var r in Rows("event_roulette_extra"))
extras.Add(new Extra
{
kind = V(r, "kind"), order = I(r, "n_order"), sKind = V(r, "s_kind"), arg = V(r, "s_arg"), target = I(r, "n_target"),
rewards = ParseRewards(V(r, "s_rewards")), reset = V(r, "s_reset"), price = I(r, "n_price"), limit = I(r, "n_limit"), textKey = V(r, "s_text_key"),
});
extras.Sort((a, b) => a.order.CompareTo(b.order));
}
return extras;
}
}
public static List<Extra> Of(string kind)
{
var res = new List<Extra>();
foreach (var e in Extras)
if (e.kind == kind) res.Add(e);
return res;
}
}
}