From 3b2a6bb9047cfce9f501593b3669a9c1af6c5df4 Mon Sep 17 00:00:00 2001
From: lcy <1459594991@qq.com>
Date: 星期三, 05 十一月 2025 17:40:23 +0800
Subject: [PATCH] 130 战斗修改回合样式
---
Main/Config/ConfigParse.cs | 50 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/Main/Config/ConfigParse.cs b/Main/Config/ConfigParse.cs
index 355e980..c1461f7 100644
--- a/Main/Config/ConfigParse.cs
+++ b/Main/Config/ConfigParse.cs
@@ -62,6 +62,7 @@
return string.Empty;
}
+ //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1|2|3|4
public static T[] GetMultipleStr<T>(string msg) where T : struct
{
string[] segs = GetMultipleStr(msg);
@@ -105,6 +106,8 @@
return msg.Split('_');
}
+ //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1_2|2_3|3_1|4_3锛�
+ //杩斿洖涓�缁存暟缁勭粨鏋勫 1|2|3|4
public static T[] GetKeyValueKeys<T>(string msg) where T : struct
{
string[] segs = GetMultipleStr(msg);
@@ -124,6 +127,8 @@
return null;
}
+ //涓�缁存暟缁勶細鏉ユ簮鏍煎紡濡� 1_2|2_3|3_1|4_3锛�
+ //杩斿洖涓�缁存暟缁勭粨鏋勫 2|3|1|3
public static T[] GetKeyValueValues<T>(string msg) where T : struct
{
string[] segs = GetMultipleStr(msg);
@@ -143,6 +148,31 @@
return null;
}
+ //浜岀淮鏁扮粍锛氭潵婧愭牸寮忓 1_2_1|2_3_4|3_1_2|4_3_4
+ public static T[][] GetArray2<T>(string msg) where T : struct
+ {
+ string[] segs = GetMultipleStr(msg);
+ if (segs != null && segs.Length > 0)
+ {
+ T[][] array = new T[segs.Length][];
+ for (int i = 0; i < segs.Length; i++)
+ {
+ string[] pair = GetKeyValue(segs[i]);
+ if (pair.Length > 1)
+ {
+ array[i] = new T[pair.Length];
+ for (int j = 0; j < pair.Length; j++)
+ {
+ array[i][j] = (T)Convert.ChangeType(pair[j], typeof(T));
+ }
+ }
+ }
+ return array;
+ }
+ return null;
+ }
+
+ //瀛楀吀锛氭潵婧愭牸寮忓 1_2|2_3|3_1|4_3锛�
public static Dictionary<T, P> GetDic<T, P>(string msg)
{
Dictionary<T, P> dic = null;
@@ -177,7 +207,6 @@
}
//{'17':['63','6','27'],'65':['800'],'55':['139'],'19':['1000','2600','130']}
- public static Regex userDataRegex = new Regex(@"'([0-9]+)':\[(.*?)\]", RegexOptions.Singleline);
public static Dictionary<int, List<int>> Analysis(string val)//姝e垯琛ㄨ揪寮忕殑瀛楃涓插垎鍓�
{
string s = ServerStringTrim(val);
@@ -236,23 +265,8 @@
//}
}
- public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr)
- {
- if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
- {
- return new Dictionary<int, List<int>>();
- }
- var dict = JsonMapper.ToObject<Dictionary<string, List<int>>>(jsonStr);
- Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();
- foreach (var item in dict)
- {
- result[int.Parse(item.Key)] = item.Value;
- }
-
- return result;
- }
-
+ //json鏍煎紡锛� {"1":1}
public static Dictionary<int, int> ParseIntDict(string jsonStr)
{
if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
@@ -270,6 +284,7 @@
return result;
}
+ //json鏍煎紡锛� {"1":[1,2],"2":[3,4]}
public static Dictionary<int, int[]> ParseIntArrayDict(string jsonStr)
{
if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
@@ -287,6 +302,7 @@
return result;
}
+ //json鏍煎紡锛� {"1":[[1,2],[3,4]]}
public static Dictionary<int, int[][]> ParseIntArray2Dict(string jsonStr)
{
if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
--
Gitblit v1.8.0