Exemple #1
0
        public List <HeroScore> GetHeroScore(bool sort)
        {
            m_HeroScores.Clear();
            //读取文件重建m_HeroScores
            FileStream   cwar_last_fs = new FileStream(m_BaseForlder + "\\Login\\cwar\\cwar_last.txt", FileMode.Open, FileAccess.Read);
            StreamReader cwar_last_rd = new StreamReader(cwar_last_fs, Encoding.GetEncoding(950));

            string strLine = "";

            strLine = cwar_last_rd.ReadLine();

            do
            {
                strLine = strLine.Split('/')[0];
                if (strLine.Contains("item"))
                {
                    //ToSimplified
                    HeroScore heroScore = new HeroScore();
                    strLine = CFormat.ToSimplified(strLine);
                    strLine = strLine.Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries)[1];
                    var heres = strLine.Split(',');
                    if (heres[0] != "")
                    {
                        heroScore.name    = heres[0];
                        heroScore.level   = int.Parse(heres[1]);
                        heroScore.unkown1 = heres[2];
                        heroScore.unkown2 = heres[3];
                        heroScore.score   = int.Parse(heres[4]);
                        heroScore.num     = int.Parse(heres[5]);
                        heroScore.unkwon3 = heres[6];
                        m_HeroScores.Add(heroScore);
                    }
                }

                strLine = "";
                strLine = cwar_last_rd.ReadLine();
            } while (strLine != null);

            if (sort)
            {
                m_HeroScores.Sort(new Comparison <HeroScore>(AnswerResultCompare));
            }


            cwar_last_rd.Close();
            cwar_last_fs.Close();

            return(m_HeroScores);
        }
Exemple #2
0
        public int AnswerResultCompare(HeroScore x, HeroScore y)
        {
            int value = y.score.CompareTo(x.score);

            return(value);
        }
Exemple #3
0
        public List <HeroScore> GetHeroScore(bool sort)
        {
            m_HeroScores.Clear();
            //读取文件重建m_HeroScores
            FileStream   cwar_last_fs = new FileStream(m_BaseForlder + "\\Map\\history\\history_0351.txt", FileMode.Open, FileAccess.Read);
            StreamReader cwar_last_rd = new StreamReader(cwar_last_fs, Encoding.GetEncoding(950));

            string strLine = "";

            strLine = cwar_last_rd.ReadLine();
            int lastMode = -1;

            do
            {
                strLine = strLine.Split('/')[0];
                if (strLine.Contains("last_result"))
                {
                    lastMode = 1;
                }
                else if (strLine.Contains("register_list"))
                {
                    lastMode = 2;
                    m_HeroScores.Clear();
                }
                if (strLine.Contains("item") && lastMode == 1)
                {
                    //ToSimplified
                    HeroScore heroScore = new HeroScore();
                    strLine = CFormat.ToSimplified(strLine);
                    strLine = strLine.Split(new string[] { " = " }, StringSplitOptions.RemoveEmptyEntries)[1];
                    var heres = strLine.Split(',');
                    if (heres[0] != "")
                    {
                        heroScore.name    = heres[0];
                        heroScore.level   = 0;
                        heroScore.unkown1 = "";
                        heroScore.unkown2 = "";
                        heroScore.score   = int.Parse(heres[3]);
                        heroScore.num     = int.Parse(heres[5]);
                        heroScore.unkwon3 = "";
                        m_HeroScores.Add(heroScore);
                    }
                }
                strLine = "";
                strLine = cwar_last_rd.ReadLine();
            } while (strLine != null);

            if (m_HeroScores.Count == 0)
            {
                SGExHandle SGEx = new SGExHandle();
                SGEx.SendWorldWords("赤壁未分胜负,以讨敌数排名,自动发奖!");

                //查询数据库
            }

            if (sort)
            {
                m_HeroScores.Sort(new Comparison <HeroScore>(AnswerResultCompare));
            }


            cwar_last_rd.Close();
            cwar_last_fs.Close();

            return(m_HeroScores);
        }