308 lines
10 KiB
C#
308 lines
10 KiB
C#
|
|
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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|