From bae41593e19d32046f77ed1f036089e015380b99 Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期三, 30 七月 2025 22:25:18 +0800 Subject: [PATCH] 117 【武将】武将系统 - 布阵临时版 --- Main/Config/ConfigParse.cs | 62 +++++++++++++++++++++---------- 1 files changed, 42 insertions(+), 20 deletions(-) diff --git a/Main/Config/ConfigParse.cs b/Main/Config/ConfigParse.cs index 4ad01b1..355e980 100644 --- a/Main/Config/ConfigParse.cs +++ b/Main/Config/ConfigParse.cs @@ -187,31 +187,53 @@ } s = s.Replace(" ", string.Empty); - if (!userDataRegex.IsMatch(s)) - { + + + var dict = JsonMapper.ToObject<Dictionary<string, string[]>>(s); + + if (dict == null || dict.Count == 0) return null; - } - else + + Dictionary<int, List<int>> result = new Dictionary<int, List<int>>(); + + foreach (var item in dict) { - Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>(); - foreach (Match match in userDataRegex.Matches(s)) + List<int> list = new List<int>(); + for (int i = 0; i < item.Value.Length; i++) { - int id = int.Parse(match.Groups[1].Value); - string str = match.Groups[2].Value; - string[] vals = str.Split(','); - List<int> list = new List<int>(); - for (int i = 0; i < vals.Length; i++) - { - int intval = int.Parse(vals[i].Replace('\'', ' ')); - list.Add(intval); - } - if (!dics.ContainsKey(id)) - { - dics.Add(id, list); - } + list.Add(int.Parse(item.Value[i])); } - return dics; + if (list.Count != 0) + result[int.Parse(item.Key)] = list; } + + return result; + + //if (!userDataRegex.IsMatch(s)) + //{ + // return null; + //} + //else + //{ + // Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>(); + // foreach (Match match in userDataRegex.Matches(s)) + // { + // int id = int.Parse(match.Groups[1].Value); + // string str = match.Groups[2].Value; + // string[] vals = str.Split(','); + // List<int> list = new List<int>(); + // for (int i = 0; i < vals.Length; i++) + // { + // int intval = int.Parse(vals[i].Replace('\'', ' ')); + // list.Add(intval); + // } + // if (!dics.ContainsKey(id)) + // { + // dics.Add(id, list); + // } + // } + // return dics; + //} } public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr) -- Gitblit v1.8.0