Ejemplo n.º 1
0
 public TVillage()
 {
     Resource   = new TResource[4];
     InBuilding = new TInBuilding[6];
     Queue      = new List <IQueue>();
     Upgrades   = new Dictionary <int, TRU>();
     Market     = new TMarket();
     Troop      = new TTroop();
     for (int i = 1; i <= 10; i++)
     {
         Upgrades[i] = new TRU();
     }
     OasisInfo = new List <TOasisInfo>();
 }
Ejemplo n.º 2
0
 public TVillage()
 {
     Resource = new TResource[4];
     InBuilding = new TInBuilding[6];
     Queue = new List<IQueue>();
     Upgrades = new Dictionary<int, TRU>();
     Market = new TMarket();
     Troop = new TTroop();
     for (int i = 1; i <= 10; i++)
         Upgrades[i] = new TRU();
     OasisInfo = new List<TOasisInfo>();
 }
Ejemplo n.º 3
0
        private void NewParseInbuilding(int VillageID, string data)
        {
            var CV = TD.Villages[VillageID];
            //if (!data.Contains("<div class=\"f10 b"))
            //  return;

            MatchCollection m;
            m = Regex.Matches(data, "<a\\shref=\"([^\"]*?)\"><img\\ssrc=\"[^\"]*?img/x.gif\"[^>]*?></a></td>.*?\r?\n?<td>([^<]*)\\s\\(\\S+\\s(\\d*)\\)</td>.*?\r?\n?<td><span\\sid=\"?timer\\d+\"?>(\\d+:\\d+:\\d+)</span>");
            /*
             * [1]: cancel url
             * [2]: build.name
             * [3]: build.level
             * [4]: build.lefttime
             */
            Match m1 = Regex.Match(data, @"class="".*rf(\d+).level(\d+)""");
            Match m2 = Regex.Match(data, @"class=""building\sd(\d+)\sg(\d+)[b]?""");
            if (m1.Success || m2.Success)
            {
                CV.InBuilding[0] = null;
                CV.InBuilding[1] = null;
            }
            for (int i = 0; i < m.Count; i++)
            {
                TInBuilding tinb;
                int gid = -1;
                foreach (var kvp in GidLang)
                    if (kvp.Value == m[i].Groups[2].Value)
                    {
                        gid = kvp.Key;
                        break;
                    }

                if (gid != -1)
                {
                    tinb = new TInBuilding()
                    {
                        CancelURL = "dorf1.php" + m[i].Groups[1].Value.Replace("&amp;", "&"),
                        Gid = gid,
                        Level = Convert.ToInt32(m[i].Groups[3].Value),
                        FinishTime = DateTime.Now.Add(TimeSpanParse(m[i].Groups[4].Value))
                    };
                }
                else
                {
                    DebugLog("Cannot recognize Gid", DebugLevel.W);
                    continue;
                }
                int tinbtype = TD.isRomans ? (tinb.Gid < 5 ? 0 : 1) : 0;
                CV.InBuilding[tinbtype] = tinb;
                if (CV.RB[tinbtype] != null &&
                    CV.Buildings.ContainsKey(CV.RB[tinbtype].ABid) &&
                    CV.RB[tinbtype].Gid == CV.Buildings[CV.RB[tinbtype].ABid].Gid &&
                    CV.RB[tinbtype].Level == CV.Buildings[CV.RB[tinbtype].ABid].Level)
                {
                    CV.Buildings[CV.RB[tinbtype].ABid].Level++;
                    CV.Buildings[CV.RB[tinbtype].ABid].InBuilding = true;
                    TD.Dirty = true;
                }
                else
                {
                    int ibbid = 0, ibbcount = 0;
                    foreach (var x in CV.Buildings)
                        if (x.Value.Gid == tinb.Gid && x.Value.Level == tinb.Level - 1)
                        {
                            ibbid = x.Key;
                            ibbcount++;
                        }
                    if (ibbid != 0 && ibbcount == 1)
                    {
                        CV.InBuilding[tinbtype].ABid = ibbid;
                        CV.Buildings[ibbid].Level++;
                        CV.Buildings[ibbid].InBuilding = true;
                        TD.Dirty = true;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        //    �������ڽ������Դ�����
        private void NewParseInbuilding(int VillageID, string data)
        {
            var CV = TD.Villages[VillageID];

            MatchCollection m;
            m = Regex.Matches(data, "<a\\shref=\"([^\"]*?)\">" +
                              "[^>]*?></a></td><td>(.*?)\\s" +
                              "<span\\sclass=\"lvl\">[^\\d]*?(\\d+)</span></td><[^<]*?" +
                              "<span\\sid=\"timer\\d+\">(\\d+:\\d+:\\d+)</span>");
            /*
             * [1]: cancel url
             * [2]: build.name
             * [3]: build.level
             * [4]: build.lefttime
             */

            //	�������������Դ����ڳǽ���ҳ��Ļ�������յ�ǰ���ڽ���Ľ���
            Match m1 = Regex.Match(data, "<div id=\"content\"\\sclass=\"village1\">");
            Match m2 = Regex.Match(data, "<div id=\"content\"\\sclass=\"village2\">");
            if (m1.Success || m2.Success)
            {
                CV.InBuilding[0] = null;
                CV.InBuilding[1] = null;
            }

            for (int i = 0; i < m.Count; i++)
            {
                TInBuilding tinb;
                int gid = -1;
                foreach (var kvp in GidLang)
                {
                    if (kvp.Value == m[i].Groups[2].Value)
                    {
                        gid = kvp.Key;
                        break;
                    }
                }

                if (gid != -1)
                {
                    tinb = new TInBuilding()
                    {
                        CancelURL = "dorf1.php" + m[i].Groups[1].Value.Replace("&amp;", "&"),
                        Gid = gid,
                        Level = Convert.ToInt32(m[i].Groups[3].Value),
                        FinishTime = DateTime.Now.Add(TimeSpanParse(m[i].Groups[4].Value))
                    };
                }
                else
                {
                    if (CV.Buildings.Count > 18)
                    {
                        DebugLog("Cannot recognize Gid", DebugLevel.E);
                    }

                    continue;
                }

                //	��������Ϊ�ڳǽ�����tinbtypeΪ1
                int tinbtype = TD.isRomans ? (tinb.Gid < 5 ? 0 : 1) : 0;
                if (CV.InBuilding[tinbtype] == null)
                {
                    CV.InBuilding[tinbtype] = tinb;
                }
                else
                {
                    CV.InBuilding[tinbtype].CancelURL = tinb.CancelURL;
                    CV.InBuilding[tinbtype].Gid = tinb.Gid;
                    CV.InBuilding[tinbtype].Level = tinb.Level;
                    CV.InBuilding[tinbtype].FinishTime = tinb.FinishTime;
                }

                if (CV.RB[tinbtype] != null &&
                    CV.Buildings.ContainsKey(CV.RB[tinbtype].ABid) &&
                    CV.RB[tinbtype].Gid == CV.Buildings[CV.RB[tinbtype].ABid].Gid &&
                    CV.RB[tinbtype].Level == CV.Buildings[CV.RB[tinbtype].ABid].Level)
                {
                    CV.InBuilding[tinbtype].ABid = CV.RB[tinbtype].ABid;
                    CV.Buildings[CV.RB[tinbtype].ABid].Level++;
                    CV.Buildings[CV.RB[tinbtype].ABid].InBuilding = true;
                    TD.Dirty = true;
                }
                else
                {
                    int ibbid = 0, ibbcount = 0;
                    foreach (var x in CV.Buildings)
                    {
                        if (x.Value.Gid == tinb.Gid && x.Value.Level == tinb.Level - 1)
                        {
                            ibbid = x.Key;
                            ibbcount++;
                        }
                    }

                    if (ibbid != 0 && ibbcount == 1)
                    {
                        CV.InBuilding[tinbtype].ABid = ibbid;
                        CV.Buildings[ibbid].Level++;
                        CV.Buildings[ibbid].InBuilding = true;
                        TD.Dirty = true;
                    }
                }
            }
        }