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.
 
 
 
 
 
 

318 lines
12 KiB

using System.ComponentModel;
using System.Collections.Generic;
using System;
using LitJson;
using ProtoCSStruct;
using Sog;
namespace Operation
{
public class ObjectUtils
{
public static JsonData parseToJson(RoleBaseInfo baseInfo)
{
JsonData json = new JsonData();
json["uid"] = baseInfo.Uid;
json["world_id"] = baseInfo.RealmName.ToString();
json["nick"] = baseInfo.Nick.ToString();
json["level"] = baseInfo.Level;
json["gender"] = baseInfo.Gender;
json["icon_frame_id"] = baseInfo.IconFrameId;
json["icon"] = baseInfo.Icon.ToString();
json["selfProfession"] = baseInfo.SelfProfession;
json["integral"] = baseInfo.Integral;
json["chat_black_time"] = baseInfo.ChatBlackTime;
return json;
}
public static JsonData parseToJson(DBActInfo pb)
{
JsonData json = new JsonData();
json["activity_id"] = pb.ActID;
json["open_time"] = pb.OpenTime;
json["state"] = pb.State;
return json;
}
public static JsonData parseToJson(DBPopupGift pb)
{
JsonData json = new JsonData();
json["Type"] = pb.Type;
json["ConditionType"] = pb.ConditionType;
json["ConditionValue"] = pb.ConditionValue.ToString();
json["SpecialIndex"] = pb.SpecialIndex;
json["GiftList"] = pb.GiftList.ToString();
json["index"] = pb.Index;
json["ShowCount"] = pb.ShowCount;
json["Time"] = pb.Time;
json["AllValue"] = pb.AllValue;
json["EndShowTime"] = pb.EndShowTime;
json["coustTime"] = pb.CoustTime;
return json;
}
public static JsonData parseToJson(DBRolePayItemRecord pb)
{
JsonData json = new JsonData();
json["ItemId"] = pb.ItemId;
json["EndTime"] = pb.EndTime;
json["ItemId"] = pb.LastUpdateRecordTime;
json["PayCountMonth"] = pb.PayCountMonth;
json["PaySuccessCount"] = pb.PaySuccessCount;
json["PayCountToday"] = pb.PayCountToday;
json["VersionCode"] = pb.VersionCode;
return json;
}
public static JsonData parseToJson(DBHomeAd homeAd)
{
JsonData json = new JsonData();
json["AdId"] = homeAd.AdvToken.ToString();
json["TodayTotalGetCount"] = homeAd.TodayTotalGetCount.ToString();
json["NextTime"] = homeAd.NextTime;
json["AdType"] = homeAd.AdvId;
JsonData ads = new JsonData();
for (int i = 0; i < homeAd.Infos.Count; i++)
{
var ad = homeAd.Infos[i];
JsonData adj = new JsonData();
adj["Id"] = ad.Id;
adj["GetCount"] = ad.GetCount;
adj["ColdTime"] = ad.ColdTime;
ads.Add(adj);
}
json["infos"] = ads;
return json;
}
public static JsonData parseToJson(DBEquipment equipment)
{
JsonData json = new JsonData();
json["SerialNum"] = equipment.SerialNum;
json["DescId"] = equipment.DescId ;
json["Level"] = equipment.Level;
json["AddProp"] = equipment.AddProp.ToString();
json["Quality"] = equipment.Quality;
json["Pos"] = equipment.Pos;
return json;
}
public static JsonData parseToJson(DBHero dBHero)
{
JsonData json = new JsonData();
json["DescId"] = dBHero.DescId;
json["SerialNum"] = dBHero.SerialNum;
json["Level"] = dBHero.Level;
json["Exp"] = dBHero.Exp;
JsonData eqs = new JsonData();
for (int i = 0; i < dBHero.WearEquip.Count; i++)
{
eqs.Add(parseToJson(dBHero.WearEquip[i]));
}
json["WearEquip"] = eqs;
//json["ShowEquip"] = dBHero.ShowEquip.ToString();
return json;
}
public static JsonData parseToJson(DBPandoraBag bag)
{
JsonData json = new JsonData();
for (int i = 0; i < bag.ItemList.Count; i++)
{
var itemId = bag.ItemList[i].Id ;
var count = bag.ItemList[i].Count;
if (count == 0)
{
continue;
}
JsonData data = new JsonData();
var itemConfig = ItemDescMgr.Instance.GetConfigByInternal(itemId);
if (itemConfig == null)
{
continue;
}
data["itemId"] = itemConfig.itemID;
data["count"] = (int)count;
string nameKey = "ItmN_" + itemConfig.itemID;
var langDesc = LanguageDescMgr.Instance.GetConfig(nameKey);
if (langDesc != null)
{
nameKey = langDesc.ZH;
}
data["name"] = nameKey;
json.Add(data);
}
return json;
}
public static JsonData parseToJson(DBRolePayData payData)
{
JsonData json = new JsonData();
JsonData PayItemRecord = new JsonData();
for (int i = 0; i < payData.PayItemRecord.Count; i++)
{
JsonData record = new JsonData();
record["ItemId"] = payData.PayItemRecord[i].ItemId;
record["PaySuccessCount"] = payData.PayItemRecord[i].PaySuccessCount;
record["PayCountToday"] = payData.PayItemRecord[i].PayCountToday;
record["VersionCode"] = payData.PayItemRecord[i].VersionCode;
record["PayCountWeek"] = payData.PayItemRecord[i].PayCountWeek;
record["PayCountMonth"] = payData.PayItemRecord[i].PayCountMonth;
record["EndTime"] = payData.PayItemRecord[i].EndTime;
record["LastUpdateRecordTime"] = payData.PayItemRecord[i].LastUpdateRecordTime;
PayItemRecord.Add(record);
}
json["PayItemRecord"] = PayItemRecord;
JsonData SuccWaits = new JsonData();
for (int i = 0; i < payData.PaySuccWaitAddRole.Count; i++)
{
JsonData SuccWait = new JsonData();
SuccWait["Amount"] = payData.PaySuccWaitAddRole[i].Amount;
SuccWait["OrderId"] = payData.PaySuccWaitAddRole[i].OrderId.GetString();
SuccWait["IsPlayerFirstPay"] = payData.PaySuccWaitAddRole[i].IsPlayerFirstPay;
SuccWait["Money"] = payData.PaySuccWaitAddRole[i].Money;
SuccWait["LastSendDBTime"] = payData.PaySuccWaitAddRole[i].LastSendDBTime;
SuccWait["DbResFailCount"] = payData.PaySuccWaitAddRole[i].DbResFailCount;
SuccWait["OrderId3rd"] = payData.PaySuccWaitAddRole[i].OrderId3rd.GetString();
SuccWait["PayType"] = payData.PaySuccWaitAddRole[i].PayType;
SuccWait["IsTestPay"] = payData.PaySuccWaitAddRole[i].IsTestPay;
SuccWait["PayTime3rd"] = payData.PaySuccWaitAddRole[i].PayTime3rd;
SuccWait["Currency"] = payData.PaySuccWaitAddRole[i].Currency.GetString();
SuccWait["AddItemSuccTime"] = payData.PaySuccWaitAddRole[i].AddItemSuccTime;
SuccWait["PurchaseToken"] = payData.PaySuccWaitAddRole[i].PurchaseToken.GetString();
SuccWait["AmountExchange"] = payData.PaySuccWaitAddRole[i].AmountExchange;
SuccWait["DiamondExchange"] = payData.PaySuccWaitAddRole[i].DiamondExchange;
SuccWait["IsReplaceItem"] = payData.PaySuccWaitAddRole[i].IsReplaceItem;
SuccWait["Sandbox"] = payData.PaySuccWaitAddRole[i].Sandbox;
SuccWaits.Add(SuccWait);
}
json["PaySuccWaitAddRole"] = SuccWaits;
json["LastSendDBAddDiamondTime"] = payData.LastSendDBAddDiamondTime;
json["LastVipRewardWeek"] = payData.LastVipRewardWeek;
json["MaxPayMoneyLast7Days"] = payData.MaxPayMoneyLast7Days.ToString();
json["LastUpdateMaxPayMoneyTime"] = payData.LastUpdateMaxPayMoneyTime;
json["LastPaySuccFirstPayItemVersion"] = payData.LastPaySuccFirstPayItemVersion;
json["TodayPayDiamond"] = payData.TodayPayDiamond;
JsonData cards = new JsonData();
for (int i = 0; i < payData.MonthlyCard.Count; i++)
{
JsonData card = new JsonData();
card["CardType"] = payData.MonthlyCard[i].CardType;
card["ExpireTime"] = payData.MonthlyCard[i].ExpireTime;
card["LastRewardTime"] = payData.MonthlyCard[i].LastRewardTime;
card["IsTimeOutCard"] = payData.MonthlyCard[i].IsTimeOutCard;
cards.Add(card);
}
json["MonthlyCard"] = cards;
return json;
}
public static JsonData parseToJson(DBTaskEXData taskExData)
{
JsonData taskList = new JsonData();
for (int i = 0; i < taskExData.TaskList.Count; i++)
{
var task = taskExData.TaskList[i];
var taskDesc = QuestEXDescMgr.Instance.GetConfig(task.TaskId);
if (taskDesc == null)
{
continue;
}
var lang = LanguageDescMgr.Instance.GetConfig(taskDesc.questDescription);
string name = taskDesc.questDescription;
if (lang != null)
{
name = lang.ZH;
}
JsonData data = new JsonData();
data["TaskId"] = task.TaskId;
data["Status"] = task.Status;
data["Name"] = name;
data["Condition"] = task.Condition.ToString();
data["PickupTime"] = task.PickupTime;
taskList.Add(data);
}
return taskList;
}
public static JsonData parseToJson(DBSysUnlockData unlockData)
{
JsonData taskList = new JsonData();
foreach (var va in UnlockSystemDescMgr.Instance.ItemTable)
{
var desc = va.Value;
var descId = desc.id;
var unlockTime = "";
for (int i = 0; i < unlockData.SysUnlockDataOne.Count; i++)
{
var one = unlockData.SysUnlockDataOne[i];
if (one.SysID == descId)
{
unlockTime = AppTime.ConvertUnixTimeToString(one.SysUnlockTime);
break;
}
}
//CoreHelper.GetSequenceCheckIndex(descId, out int index, out int byteIndex);
//var unlock = CoreHelper.CheckInSequence(byteIndex, unlockData.Check[index]);
var isLock = unlockTime != "" ? "已解锁" : "未解锁";
JsonData data = new JsonData();
data["Id"] = desc.id;
data["state"] = isLock;
data["unlockTime"] = unlockTime;
taskList.Add(data);
}
return taskList;
}
public static JsonData parseToJson(RepeatedDBJobData_16 jobs)
{
JsonData taskList = new JsonData();
for (var i = 0; i < jobs.Count; i++)
{
var job = jobs[i];
JsonData data = new JsonData();
data["Id"] = job.Id;
data["Type"] = job.Type;
data["TryRet"] = job.TryRet;
data["Args"] = job.Args.ToString();
data["StartTime"] = AppTime.ConvertUnixTimeToString(job.StartTime);
data["EndTime"] = AppTime.ConvertUnixTimeToString(job.EndTime);
taskList.Add(data);
}
return taskList;
}
}
}