ItmeSClass GetBag(string username) { //return rxjh.GetBag(username); var xwwl_char = gamecontext.TBL_XWWL_Char.Where(a => a.FLD_NAME == username).SingleOrDefault(); if (xwwl_char == null) { throw new ArgumentException("提示:错误没有这个人物!数据库可能有问题"); } int num = 36; ItmeSClass class2 = new ItmeSClass(); byte[] src = xwwl_char.FLD_ITEM; for (int i = 0; i < num; i++) { if (src.Length >= ((i * 37) + 37)) { byte[] dst = new byte[37]; try { Buffer.BlockCopy(src, i * 37, dst, 0, 37); 物品类 物品类 = new 物品类(dst); ItmeClass item = new ItmeClass { ID = i, FLD_ID = BitConverter.ToInt64(物品类.物品全局ID, 0), FLD_ItmeID = BitConverter.ToInt32(物品类.物品ID, 0), FLD_NAME = 物品类.物品名称, FLD_Type = 物品类.物品类型, FLD_Suliang = BitConverter.ToInt32(物品类.物品数量, 0), FLD_MAGIC0 = 物品类.FLD_MAGIC0, FLD_MAGIC1 = 物品类.FLD_MAGIC1, FLD_MAGIC2 = 物品类.FLD_MAGIC2, FLD_MAGIC3 = 物品类.FLD_MAGIC3, FLD_MAGIC4 = 物品类.FLD_MAGIC4, //FLD_CjFh = 物品类.FLD_FJ_初级附魂, //FLD_ZjFh = 物品类.FLD_FJ_中级附魂, //FLD_JingHua = 物品类.FLD_FJ_进化, //FLD_Bind = 物品类.物品绑定 }; class2.ItmeList.Add(item); if (BitConverter.ToInt32(物品类.物品ID, 0) == 0) { class2.Kwei++; } } catch (Exception exception) { throw new ArgumentException("提示:数据错误1!" + exception.Message); } class2.FLD_ID = xwwl_char.FLD_ID; class2.FLD_Name = username; class2.FLD_JOB = xwwl_char.FLD_JOB.ToString(); class2.FLD_ZX = xwwl_char.FLD_ZX.ToString(); } } return(class2); }
public static string GetItemslist(ItmeSClass ItmeSC, byte[] Itmes, int 物品数) { Dictionary <int, 物品类> dictionary = new Dictionary <int, 物品类>(); for (int i = 0; i < 物品数; i++) { if (Itmes.Length >= ((i * 0x49) + 0x49)) { byte[] dst = new byte[0x49]; try { Buffer.BlockCopy(Itmes, i * 0x49, dst, 0, 0x49); 物品类 物品类 = new 物品类(dst); dictionary.Add(i, 物品类); ItmeClass item = new ItmeClass { ID = i, FLD_ID = BitConverter.ToInt64(物品类.物品全局ID, 0), FLD_ItmeID = BitConverter.ToInt32(物品类.物品ID, 0), FLD_NAME = 物品类.物品名称, FLD_Type = 物品类.物品类型, FLD_Suliang = BitConverter.ToInt32(物品类.物品数量, 0), FLD_MAGIC0 = 物品类.FLD_MAGIC0, FLD_MAGIC1 = 物品类.FLD_MAGIC1, FLD_MAGIC2 = 物品类.FLD_MAGIC2, FLD_MAGIC3 = 物品类.FLD_MAGIC3, FLD_MAGIC4 = 物品类.FLD_MAGIC4, //FLD_CjFh = 物品类.FLD_FJ_初级附魂, //FLD_ZjFh = 物品类.FLD_FJ_中级附魂, //FLD_JingHua = 物品类.FLD_FJ_进化, FLD_Bind = 物品类.物品绑定 }; ItmeSC.ItmeList.Add(item); if (BitConverter.ToInt32(物品类.物品ID, 0) == 0) { ItmeSC.Kwei++; } } catch (Exception exception) { throw new ArgumentException("提示:数据错误1!" + exception.Message); } } } return(JsonConvert.SerializeObject(ItmeSC)); }
public ItmeSClass GetBag(string username, string serverdb = "0", string serverid = "d1") { Dictionary <int, 物品类> dictionary = null; string server = serverid; string str2 = username; string str3 = serverdb; string str4 = "TBL_XWWL_Char"; string str5 = "FLD_ITEM,FLD_ID,FLD_JOB,FLD_ZX"; string str6 = "FLD_ITEM"; string str7 = "FLD_NAME"; int num = 0x24; if (str3 == "0") { str4 = "TBL_XWWL_Char"; str5 = "FLD_ITEM,FLD_ID,FLD_JOB,FLD_ZX"; str6 = "FLD_ITEM"; str7 = "FLD_NAME"; num = 0x24; } else if (str3 == "1") { str4 = "TBL_XWWL_Char"; str5 = "FLD_WEARITEM,FLD_ID,FLD_JOB,FLD_ZX"; str6 = "FLD_WEARITEM"; str7 = "FLD_NAME"; num = 15; } else if (str3 == "2") { str4 = "TBL_XWWL_Warehouse"; str5 = "FLD_ITEM,FLD_ID"; str6 = "FLD_ITEM"; str7 = "FLD_NAME"; num = 60; } else if (str3 == "3") { str4 = "TBL_XWWL_PublicWarehouse"; str5 = "FLD_ITEM,FLD_ID"; str6 = "FLD_ITEM"; str7 = "FLD_ID"; num = 60; } DataTable table = DBA.GetDBToDataTable(string.Format("select {3} from {2} WHERE {1} ='{0}'", new object[] { str2, str7, str4, str5 }), "rxjhgame", server); if (table == null) { throw new ArgumentException("提示:错误没有这个人物!数据库可能有问题"); } if (table.Rows.Count == 0) { throw new ArgumentException("提示:错误没有这个人物!"); } dictionary = new Dictionary <int, 物品类>(); ItmeSClass class2 = new ItmeSClass(); byte[] src = (byte[])table.Rows[0][str6]; for (int i = 0; i < num; i++) { if (src.Length >= (i * 37 + 37)) { byte[] dst = new byte[37]; try { Buffer.BlockCopy(src, i * 37, dst, 0, 37); 物品类 物品类 = new 物品类(dst); dictionary.Add(i, 物品类); ItmeClass item = new ItmeClass { ID = i, FLD_ID = BitConverter.ToInt64(物品类.物品全局ID, 0), FLD_ItmeID = BitConverter.ToInt32(物品类.物品ID, 0), FLD_NAME = 物品类.物品名称, FLD_Type = 物品类.物品类型, FLD_Suliang = BitConverter.ToInt32(物品类.物品数量, 0), FLD_MAGIC0 = 物品类.FLD_MAGIC0, FLD_MAGIC1 = 物品类.FLD_MAGIC1, FLD_MAGIC2 = 物品类.FLD_MAGIC2, FLD_MAGIC3 = 物品类.FLD_MAGIC3, FLD_MAGIC4 = 物品类.FLD_MAGIC4, }; class2.ItmeList.Add(item); if (BitConverter.ToInt32(物品类.物品ID, 0) == 0) { class2.Kwei++; } } catch (Exception exception) { throw new ArgumentException("提示:数据错误1!" + exception.Message); } class2.FLD_ID = table.Rows[0]["FLD_ID"].ToString(); class2.FLD_Name = str2; if ((str3 != "2") && (str3 != "3")) { class2.FLD_JOB = table.Rows[0]["FLD_JOB"].ToString(); class2.FLD_ZX = table.Rows[0]["FLD_ZX"].ToString(); } DataTable table2 = DBA.GetDBToDataTable(string.Format("select FLD_ID,FLD_ONLINE,FLD_SEX from [TBL_ACCOUNT] where FLD_ID='{0}'", class2.FLD_ID), "rxjhaccount", server); class2.FLD_ONLINE = table2.Rows[0]["FLD_ONLINE"].ToString(); table2.Dispose(); } } table.Dispose(); return(class2); }