Beispiel #1
0
        public VillageData()
        {
            Productions[ResourcesType.Lumber] = new Production();
            Productions[ResourcesType.Lumber].Type = ResourcesType.Lumber;
            Productions[ResourcesType.Lumber].TargetPercent = 30;
            Productions[ResourcesType.Clay] = new Production();
            Productions[ResourcesType.Clay].Type = ResourcesType.Clay;
            Productions[ResourcesType.Clay].TargetPercent = 30;
            Productions[ResourcesType.Iron] = new Production();
            Productions[ResourcesType.Iron].Type = ResourcesType.Iron;
            Productions[ResourcesType.Iron].TargetPercent = 20;
            Productions[ResourcesType.Crop] = new Production();
            Productions[ResourcesType.Crop].Type = ResourcesType.Crop;
            Productions[ResourcesType.Crop].TargetPercent = 20;

            for (int i = 1; i <= 18; i++)
            {
                Resources[i] = new Building();
                Resources[i].Id = i;
                Resources[i].BuildId = i;

            }

            for (int i = 1; i <= 22; i++)
            {
                Buildings[i] = new Building();
                Buildings[i].Id = i;
                Buildings[i].BuildId = i + 18;
            }
            Buildings[21].Type = BuildingType.Rally_point;
            Buildings[21].BuildId = 39;
            Buildings[22].Type = BuildingType.City_wall;
            Buildings[22].BuildId = 40;
        }
Beispiel #2
0
        /// <summary>
        /// egy épület megépítése
        /// kéne tudni valóban sikerült-e megépíteni,
        /// és csak akkor emelni a szintet...
        /// </summary>
        /// <param name="b"></param>
        private void BuildIt(Building b)
        {
            Globals.Logger.Log( "Try Upgrade: " + b.Name + '@' + b.Id + ' ' + b.NextLevelCost, LogType.ltDebug);

            Navigate("build.php?id=" + b.BuildId);
            ParseConstruction(b, true);

            Regex rex = new Regex(@"dorf[1-2]\.php\?a=.*&c=(.{3})");
            MatchCollection matches = rex.Matches(Globals.Web.Document.GetElementById("lmid2").InnerHtml.Replace("&amp;", "&"));
            if (matches.Count > 0)
                b.BuildHref = matches[matches.Count - 1].Value;

            if (b.BuildHref != null && b.BuildHref.Length != 0)
            {
                Globals.Logger.Log("Upgrade: " + b.href, LogType.ltDebug);
                Navigate(b.BuildHref);
                b.Level++;
                b.BuildHref = "";
                b.NextLevelCost.Clear();
                AddToConstructionList(b);
            }
        }
Beispiel #3
0
        private void AddToConstructionList(Building b)
        {
            Construction c = new Construction();
            c.Building = b.Type;
            c.Started = DateTime.Now;
            if (b.BuildTime == TimeSpan.Zero)
                c.Ends = c.Started.AddMinutes(2);
            else
                c.Ends = c.Started.Add(b.BuildTime);
            c.Level = b.Level;

            Data.Villages[ActiveVillage].Constructing.Add(c);
        }
Beispiel #4
0
        /// <summary>
        /// megnézi, hogy egy épület építhető-e és mennyibe kerül
        /// lehetne reszelni még rajta: pacik, katonák
        /// </summary>
        /// <param name="building"></param>
        private void ParseConstruction(Building building, bool Forced)
        {
            if (building.Type != BuildingType.None && building.Level < building.Target)
            {
                if (Forced || building.NextLevelCost.Sum == 0)
                {
                    Navigate("build.php?id=" + building.BuildId);

                    //build href
                    /*
                    building.BuildHref = "";
                    Regex rex = new Regex(@"dorf[1-2]\.php\?a=.*&c=(.{3})");
                    MatchCollection matches = rex.Matches(Globals.Web.Document.GetElementById("lmid2").InnerHtml.Replace("&amp;", "&"));
                    if (matches.Count > 0)
                        building.BuildHref = matches[matches.Count - 1].Value;
                    */

                    building.NextLevelCost.Clear();

                    //cost
                    Regex rex = new Regex(@"\d+ \| \d+ \| \d+ \| \d+ \| \d+ \|  \d+\:\d+\:\d+");
                    MatchCollection matches = rex.Matches(Globals.Web.Document.GetElementById("lmid2").InnerText);
                    if (matches.Count > 0)
                    {
                        string[] sa = matches[matches.Count - 1].Value.Split('|');
                        building.NextLevelCost[ResourcesType.Lumber] = int.Parse(sa[0]);
                        building.NextLevelCost[ResourcesType.Clay] = int.Parse(sa[1]);
                        building.NextLevelCost[ResourcesType.Iron] = int.Parse(sa[2]);
                        building.NextLevelCost[ResourcesType.Crop] = int.Parse(sa[3]);

                        sa = sa[5].Split(':');
                        building.BuildTime =
                            TimeSpan.FromHours(int.Parse(sa[0])) +
                            TimeSpan.FromMinutes(int.Parse(sa[1])) +
                            TimeSpan.FromSeconds(int.Parse(sa[2]));
                    }
                }
            }
        }