You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
8.8 KiB
234 lines
8.8 KiB
1 month ago
|
using Google.Protobuf.WellKnownTypes;
|
||
|
using Sog;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Text.RegularExpressions;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace CheckConfig.Strategy
|
||
|
{
|
||
|
class SystemStrategy : ConfigStrategy, InitializingConfig
|
||
|
{
|
||
|
public void AfterPropertiesSet()
|
||
|
{
|
||
|
CheckConfigStrategyFactory.Register("系统", this);
|
||
|
}
|
||
|
private static DateTime m_dateTime1970_utc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||
|
private static DateTime m_dateTime1970 = m_dateTime1970_utc.ToLocalTime();
|
||
|
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 系统检测-
|
||
|
/// </summary>
|
||
|
public override void CheckConfigAlgorithm()
|
||
|
{
|
||
|
//foreach (var item in MarketShopDescMgr.Instance.ItemTable)
|
||
|
//{
|
||
|
// SortedList<int, MarketShopGoodsDesc> itemDataGroup;
|
||
|
// MarketShopGoodsDescMgr.Instance.ItemTable.TryGetValue(item.Key, out itemDataGroup);
|
||
|
// if (itemDataGroup == null)
|
||
|
// {
|
||
|
// ConsoleStyle.Write("系统", "MarketShop", $"shopId:{item.Value.shopId}"," goods is null");
|
||
|
// return;
|
||
|
// }
|
||
|
|
||
|
// // var marketShops = itemDataGroup.Values.ToList().GroupBy(e => e.goodsPos).Select(g => new { key = g.Key, count = g.Count() });
|
||
|
// // 策划需求,先临时注释,后面调整规则
|
||
|
// //int i = 0;
|
||
|
// //foreach (var ms in marketShops)
|
||
|
// //{
|
||
|
// // //0代表通用
|
||
|
// // if (ms.key == 0)
|
||
|
// // i += ms.count;
|
||
|
// // else
|
||
|
// // i++;
|
||
|
// //}
|
||
|
// //if (i < item.Value.goodsNum)
|
||
|
// // ConsoleStyle.Write("系统", "MarketShop", $"商品ID:{item.Key},MarketShopDesc表数量:{item.Value.goodsNum},MarketShopGoods根据pos计算后数量:{i}", "小于MarketShopDesc表中设计数量");
|
||
|
|
||
|
// foreach (var value in itemDataGroup.Values)
|
||
|
// {
|
||
|
// var goodsNum = MarketShopDescMgr.Instance.GetConfig(value.shopId).goodsNum;
|
||
|
// if (value.goodsPos > goodsNum)
|
||
|
// {
|
||
|
// ConsoleStyle.Write("系统", "MarketShop", $"shopId:{value.shopId}, goodsIndex :{value.goodsIndex}, ", $" MarketShopGoodsDesc 表中 goods_pos:{value.goodsPos} 大于 MarketShopDesc表中 goodsNum:{goodsNum}");
|
||
|
// }
|
||
|
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
|
||
|
// 奖励表奖励数量与数组校验
|
||
|
RewardCheck();
|
||
|
//LogicWorldCheck();
|
||
|
//ArenaPeakSeasonInfoCheck();
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public void RewardCheck()
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//foreach (var item in DropDescMgr.Instance.ItemTable)
|
||
|
//{
|
||
|
// var num = item.Value.Num;
|
||
|
// int rewordCount = 0;
|
||
|
// foreach (var reword in item.Value.bindDropOne)
|
||
|
// {
|
||
|
// if (reword.WareID != 0 || reword.WareType != 0)
|
||
|
// {
|
||
|
// rewordCount++;
|
||
|
// }
|
||
|
// }
|
||
|
// if (rewordCount != num && num != 0)
|
||
|
// {
|
||
|
// ConsoleStyle.Write("系统", "Drop", $"key:{item.Key}" , $" Drop 表中 DropNum:{num} 不等于 DropRewordCount:{rewordCount}");
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
public void ArenaPeakSeasonInfoCheck()
|
||
|
{
|
||
|
// 初始化realmList
|
||
|
string path = "../realmList.json";
|
||
|
//string path = "../../../../arpg_svr_proj/cfg/u2_overseas/Realmlist/realmList.json";
|
||
|
//string path = "C:\\arpg\\arpg_svr_proj\\cfg\\u2_overseas\\Realmlist\\realmList.json"; // 测试
|
||
|
RealmListConfig realmConfig = JsonConfig.parseFileLitJson<RealmListConfig>(path);
|
||
|
List<RealmConfigOne> myRealmList = new List<RealmConfigOne>();
|
||
|
Dictionary<int, RealmConfigOne> myRealmDict = new Dictionary<int, RealmConfigOne>();
|
||
|
// <realmId, worldId>
|
||
|
Dictionary<int, int> realmWorldDict = new Dictionary<int, int>();
|
||
|
foreach (var areaRealm in realmConfig.areaRealmList)
|
||
|
{
|
||
|
foreach (var world in areaRealm.worldList)
|
||
|
{
|
||
|
myRealmList.AddRange(world.realmList);
|
||
|
foreach (var realm in world.realmList)
|
||
|
{
|
||
|
realmWorldDict.Add(realm.realmId, world.worldId);
|
||
|
myRealmDict.Add(realm.realmId, realm);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
public void LogicWorldCheck()
|
||
|
{
|
||
|
Dictionary<int, RealmConfigOne> realmMap = new Dictionary<int, RealmConfigOne>();
|
||
|
Dictionary<int, List<int>> bigRealmList = new Dictionary<int, List<int>>();
|
||
|
string path = "../realmList.json";
|
||
|
RealmListConfig realmConfig = JsonConfig.parseFileLitJson<RealmListConfig>(path);
|
||
|
foreach(var areaConfig in realmConfig.areaRealmList)
|
||
|
{
|
||
|
foreach(var worldConfig in areaConfig.worldList)
|
||
|
{
|
||
|
int worldId = worldConfig.worldId;
|
||
|
foreach(var oneRealm in worldConfig.realmList)
|
||
|
{
|
||
|
oneRealm.worldId = worldId;
|
||
|
realmMap.Add(oneRealm.realmId, oneRealm);
|
||
|
if (!bigRealmList.ContainsKey(oneRealm.bigRealmId))
|
||
|
{
|
||
|
bigRealmList.Add(oneRealm.bigRealmId, new List<int>());
|
||
|
}
|
||
|
bigRealmList[oneRealm.bigRealmId].Add(oneRealm.realmId);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//检查星球竞技场区服 bigRealm相同的服务器world和logicWorld一定得相同
|
||
|
foreach(var it in bigRealmList)
|
||
|
{
|
||
|
int bigRealm = it.Key;
|
||
|
int headRealm = 0;
|
||
|
int worldId = 0;
|
||
|
int logicWorldId = 0;
|
||
|
|
||
|
foreach(var realmId in it.Value)
|
||
|
{
|
||
|
if (realmMap.ContainsKey(realmId))
|
||
|
{
|
||
|
int tmpWorldId = realmMap[realmId].worldId;
|
||
|
if (worldId == 0)
|
||
|
{
|
||
|
worldId = tmpWorldId;
|
||
|
headRealm = realmId;
|
||
|
}
|
||
|
if (worldId == 0 || tmpWorldId != worldId)
|
||
|
{
|
||
|
ConsoleStyle.Write("系统", "realmList.json 配置", "", $"bigRealm:{bigRealm} realm:{realmId} worldId:{tmpWorldId}与首个realm:{headRealm} 的world:{worldId} 不符 ");
|
||
|
}
|
||
|
|
||
|
int tmpLogicWorldId = realmMap[realmId].logicWorldId;
|
||
|
if (logicWorldId == 0)
|
||
|
{
|
||
|
logicWorldId = tmpLogicWorldId;
|
||
|
}
|
||
|
if (logicWorldId == 0 || tmpLogicWorldId != logicWorldId)
|
||
|
{
|
||
|
ConsoleStyle.Write("系统", "realmList.json bigRealm配置", "", $" bigRealm:{bigRealm} realm:{realmId} logicWorldId:{tmpLogicWorldId}与首个realm:{headRealm}的logicWorldId:{logicWorldId} 不符 ");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
public static long TryGetStartTimeByDate(string date)
|
||
|
{
|
||
|
long time = 0;
|
||
|
string pattern = @"(\d{4})(\d{2})(\d{2})";
|
||
|
var match = Regex.Match(date, pattern);
|
||
|
if (match.Groups.Count == 4)
|
||
|
{
|
||
|
DateTime dt = new DateTime(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value), int.Parse(match.Groups[3].Value));
|
||
|
var correct = dt.AddHours(AppTime.GetGameResetHour());
|
||
|
time = AppTime.GetTimeSecond(correct);
|
||
|
return time;
|
||
|
}
|
||
|
return time;
|
||
|
}
|
||
|
|
||
|
public static long ParseConfigTime(string time)
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(time))
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
DateTime result;
|
||
|
bool bSuccess = DateTime.TryParse(time, out result);
|
||
|
if (bSuccess == false)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
long timeSecond = AppTime.GetTimeSecond(result);
|
||
|
return timeSecond;
|
||
|
}
|
||
|
|
||
|
public static long GetNowDateTimeTs(DateTime time)
|
||
|
{
|
||
|
TimeSpan ts = time - m_dateTime1970;
|
||
|
long times = (long)ts.TotalMilliseconds / 1000;
|
||
|
return times;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|