Beispiel #1
0
 public PlayerDataInfo()
 {
     baseInfo  = new PlayerDataBaseInfo();
     fightInfo = new List <PlayerDataFightInfo>();
     heroInfo  = new List <PlayerDataHeroInfo>();
 }
Beispiel #2
0
        /// <summary>
        /// 获取玩家数据
        /// </summary>
        private static void GetPlayerDataFromDB(gmt.Server server)
        {
            DatabaseAssistant.Execute(reader =>
            {
                while (reader.Read())
                {
                    PlayerDataInfo pdi = new PlayerDataInfo();

                    PlayerDataBaseInfo bi = new PlayerDataBaseInfo();
                    bi.uid = reader.GetUInt32(0);

                    if (!reader.IsDBNull(1))
                    {
                        byte[] buffer = new byte[reader.GetBytes(1, 0, null, 0, int.MaxValue)];
                        reader.GetBytes(1, 0, buffer, 0, buffer.Length);
                        using (MemoryStream stream = new MemoryStream(buffer))
                        {
                            mw.Role3rdData roledata = ProtoSerializer.Instance.Deserialize(stream, null, typeof(mw.Role3rdData)) as mw.Role3rdData;
                            bi.team_level           = roledata.level;
                            bi.soulex_level         = roledata.soulex_level;

                            for (int i = 0; i < 6; i++)
                            {
                                if (i == roledata.detailInfo.heroInfos.Count)
                                {
                                    break;
                                }

                                #region 英雄战力信息
                                PlayerDataHeroInfo hi = new PlayerDataHeroInfo();

                                hi.hero_id    = roledata.detailInfo.heroInfos[i].heroInfo.index;
                                hi.hero_color = roledata.detailInfo.heroInfos[i].heroInfo.color;
                                hi.hero_star  = roledata.detailInfo.heroInfos[i].heroInfo.star;

                                if (roledata.detailInfo.heroInfos[i].heroInfo.equipInfos.Count > 0)
                                {
                                    hi.hero_equip_min_level = roledata.detailInfo.heroInfos[i].heroInfo.equipInfos[0].levelex;
                                    for (int j = 0; j < roledata.detailInfo.heroInfos[i].heroInfo.equipInfos.Count; j++)
                                    {
                                        if (roledata.detailInfo.heroInfos[i].heroInfo.equipInfos[j].levelex < hi.hero_equip_min_level)
                                        {
                                            hi.hero_equip_min_level = roledata.detailInfo.heroInfos[i].heroInfo.equipInfos[j].levelex;
                                        }
                                    }
                                }

                                if (roledata.detailInfo.heroInfos[i].heroInfo.starArrayInfos.Count > 0)
                                {
                                    hi.hero_star_min_level = roledata.detailInfo.heroInfos[i].heroInfo.starArrayInfos[0].star_count;
                                    for (int j = 0; j < roledata.detailInfo.heroInfos[i].heroInfo.starArrayInfos.Count; j++)
                                    {
                                        if (roledata.detailInfo.heroInfos[i].heroInfo.starArrayInfos[j].star_count < hi.hero_star_min_level)
                                        {
                                            hi.hero_star_min_level = roledata.detailInfo.heroInfos[i].heroInfo.starArrayInfos[j].star_count;
                                        }
                                    }
                                }

                                hi.hero_pet_star = (roledata.lookInfo.heroInfos[i].pet_type - roledata.lookInfo.heroInfos[i].pet_type / 10000 * 10000) / 100;

                                pdi.heroInfo.Add(hi);
                                #endregion

                                #region 助战位信息
                                PlayerDataFightInfo fi = new PlayerDataFightInfo();
                                if (roledata.detailInfo.heroInfos[i].fightStoneInfos.Count > 0)
                                {
                                    fi.equip_min_level   = roledata.detailInfo.heroInfos[i].fightStoneInfos[0].level;
                                    fi.equip_min_levelex = roledata.detailInfo.heroInfos[i].fightStoneInfos[0].levelex;
                                    for (int j = 0; j < roledata.detailInfo.heroInfos[i].fightStoneInfos.Count; j++)
                                    {
                                        if (roledata.detailInfo.heroInfos[i].fightStoneInfos[j].level < fi.equip_min_level)
                                        {
                                            fi.equip_min_level = roledata.detailInfo.heroInfos[i].fightStoneInfos[j].level;
                                        }
                                        if (roledata.detailInfo.heroInfos[i].fightStoneInfos[j].levelex < fi.equip_min_levelex)
                                        {
                                            fi.equip_min_levelex = roledata.detailInfo.heroInfos[i].fightStoneInfos[j].levelex;
                                        }

                                        switch ((FightStoneColor)roledata.detailInfo.heroInfos[i].fightStoneInfos[j].color)
                                        {
                                        case FightStoneColor.Blue: bi.blue_equip_count++; break;

                                        case FightStoneColor.Purple: bi.purple_equip_count++; break;

                                        case FightStoneColor.Orange: bi.orange_equip_count++; break;

                                        case FightStoneColor.Red: bi.red_equip_count++; break;
                                        }
                                    }
                                }

                                if (roledata.detailInfo.heroInfos[i].stoneInfos.Count > 0)
                                {
                                    fi.stone_min_level   = roledata.detailInfo.heroInfos[i].stoneInfos[0].level;
                                    fi.stone_min_levelex = roledata.detailInfo.heroInfos[i].stoneInfos[0].levelex;
                                    for (int j = 0; j < roledata.detailInfo.heroInfos[i].stoneInfos.Count; j++)
                                    {
                                        if (roledata.detailInfo.heroInfos[i].stoneInfos[j].level < fi.stone_min_level)
                                        {
                                            fi.stone_min_level = roledata.detailInfo.heroInfos[i].stoneInfos[j].level;
                                        }
                                        if (roledata.detailInfo.heroInfos[i].stoneInfos[j].levelex < fi.stone_min_levelex)
                                        {
                                            fi.stone_min_levelex = roledata.detailInfo.heroInfos[i].stoneInfos[j].levelex;
                                        }

                                        switch ((StoneColor)(roledata.detailInfo.heroInfos[i].stoneInfos[j].type % 10 + 1))
                                        {
                                        case StoneColor.Blue: bi.blue_stone_count++; break;

                                        case StoneColor.Purple: bi.purple_stone_count++; break;

                                        case StoneColor.Orange: bi.orange_stone_count++; break;

                                        case StoneColor.Red: Log.AddLog(bi.uid + " " + hi.hero_id + " 5"); break;
                                        }
                                    }
                                }

                                pdi.fightInfo.Add(fi);
                                #endregion
                            }
                        }
                    }
                    bi.money   = reader.GetInt32(2);
                    bi.yuanbao = reader.GetInt32(3);

                    pdi.baseInfo = bi;

                    if (!playerDataInfoDic.ContainsKey(bi.uid))
                    {
                        playerDataInfoDic.Add(bi.uid, pdi);
                    }
                }
            },
                                      server.DatabaseAddress,
                                      server.DatabasePort,
                                      server.DatabaseCharSet,
                                      server.GameDatabase,
                                      server.DatabaseUserId,
                                      server.DatabasePassword,
                                      "SELECT user.uid,3rd_data,money,yuanbao FROM USER,user_info WHERE user.uid=user_info.uid"
                                      );
        }
Beispiel #3
0
        public static System.Data.DataTable DicToTable()
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(TableManager.GetGMTText(8), typeof(uint));
            dt.Columns.Add(TableManager.GetGMTText(61), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(63), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(830), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(653), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(831), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(832), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(833), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(834), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(835), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(836), typeof(int));
            dt.Columns.Add(TableManager.GetGMTText(837), typeof(int));

            for (int i = 1; i <= 6; i++)
            {
                dt.Columns.Add(TableManager.GetGMTText(438) + i + "ID", typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(438) + i + TableManager.GetGMTText(838), typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(438) + i + TableManager.GetGMTText(839), typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(840) + i, typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(841) + i, typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(842) + i, typeof(int));
            }

            for (int i = 1; i <= 6; i++)
            {
                dt.Columns.Add(TableManager.GetGMTText(843) + i, typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(844) + i, typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(845) + i, typeof(int));
                dt.Columns.Add(TableManager.GetGMTText(846) + i, typeof(int));
            }

            foreach (var pdi in playerDataInfoDic)
            {
                DataRow dr = dt.NewRow();
                dr[0] = pdi.Key;

                PlayerDataBaseInfo         bi     = pdi.Value.baseInfo;
                List <PlayerDataHeroInfo>  hiList = pdi.Value.heroInfo;
                List <PlayerDataFightInfo> fiList = pdi.Value.fightInfo;

                dr[1]  = bi.team_level;
                dr[2]  = bi.yuanbao;
                dr[3]  = bi.money;
                dr[4]  = bi.soulex_level;
                dr[5]  = bi.blue_equip_count;
                dr[6]  = bi.purple_equip_count;
                dr[7]  = bi.orange_equip_count;
                dr[8]  = bi.red_equip_count;
                dr[9]  = bi.blue_stone_count;
                dr[10] = bi.purple_stone_count;
                dr[11] = bi.orange_stone_count;

                for (int i = 0; i < 6; i++)
                {
                    int k = 12 + (i * 6);
                    if (i < hiList.Count)
                    {
                        dr[k]     = hiList[i].hero_id;
                        dr[k + 1] = hiList[i].hero_color;
                        dr[k + 2] = hiList[i].hero_star;
                        dr[k + 3] = hiList[i].hero_equip_min_level;
                        dr[k + 4] = hiList[i].hero_star_min_level;
                        dr[k + 5] = hiList[i].hero_pet_star;
                    }
                    else
                    {
                        dr[k]     = -1;
                        dr[k + 1] = -1;
                        dr[k + 2] = -1;
                        dr[k + 3] = -1;
                        dr[k + 4] = -1;
                        dr[k + 5] = -1;
                    }

                    k = 48 + (4 * i);
                    if (i < fiList.Count)
                    {
                        dr[k]     = fiList[i].equip_min_level;
                        dr[k + 1] = fiList[i].equip_min_levelex;
                        dr[k + 2] = fiList[i].stone_min_level;
                        dr[k + 3] = fiList[i].stone_min_levelex;
                    }
                    else
                    {
                        dr[k]     = -1;
                        dr[k + 1] = -1;
                        dr[k + 2] = -1;
                        dr[k + 3] = -1;
                    }
                }

                dt.Rows.Add(dr);
            }

            return(dt);
        }