예제 #1
0
        public void CalculatorSourceOverPercent()
        {
            DeserializeLanguage();
            Language language = Languages.GetLanguage("sl-SI");
            Assert.IsNotNull(language, "Language is null!");

            HtmlDocument htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.php.html");
            HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceDestination = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceDestination, "NULL");
            Village destinationVillage = new Village();
            destinationVillage.AddId(123).AddName("01");
            Production productionDestination = htmlParser.GetProduction();
            Assert.IsNotNull(productionDestination, "NULL");
            destinationVillage.UpdateProduction(productionDestination);

            htmlDocument = new HtmlDocument();
            htmlDocument.Load("..\\..\\Test Files\\Marketplace.idle.php.html");
            htmlParser = new HtmlParser(htmlDocument, language);
            MarketPlace marketPlaceSource = htmlParser.MarketPlace();
            Assert.IsNotNull(marketPlaceSource, "NULL");
            Village sourceVillage = new Village();
            sourceVillage.AddId(321).AddName("02");
            Production productionSource = htmlParser.GetProduction();
            Assert.IsNotNull(productionSource, "NULL");
            sourceVillage.UpdateProduction(productionSource);

            DateTime dt = new DateTime(DateTime.Now.Ticks);
            MarketPlaceQueue queue = new MarketPlaceQueue
            {
                DestinationVillage = destinationVillage,
                SourceVillage = sourceVillage,
                Goods = 50,
                GoodsToSend = 750,
                SendWood = true,
                SendClay = true,
                SendIron = true,
                SendCrop = true,
                SendGoodsType = SendGoodsType.SourceOverPercent,
                LastSend = dt.AddHours(-2),
                RepeatMinutes = 10,
            };

            MarketPlaceCalculator calculator = new MarketPlaceCalculator
            {
                Destination = destinationVillage,
                Source = sourceVillage,
                MarketPlaceDestination = marketPlaceDestination,
                MarketPlaceSource = marketPlaceSource,
                Queue = queue,
            };
            calculator.CalculateSourceOver();
            Assert.AreEqual("&r1=750&r2=750&r3=0&r4=750", calculator.PostParameters, "PostParameters");
            Assert.IsTrue(calculator.TimeToSend(dt), "Last send time");
        }
예제 #2
0
 public void ParseCenterBuildings()
 {
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\dorf2.php.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     Village village = new Village();
     village.AddId(123).AddName("01");
     List<Buildings> buildings = htmlParser.GetCenterBuildings(village);
     Assert.IsNotNull(buildings, "NULL");
     Assert.AreEqual(22, buildings.Count, "COUNT");
 }
예제 #3
0
 public void HtmlParserTroopMovements()
 {
     DeserializeLanguage();
     Language language = Languages.GetLanguage("sl-SI");
     Assert.IsNotNull(language, "Language is null!");
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\RallyPoint.php.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
     List<TroopMovement> troopMovements = htmlParser.TroopMovements(new Village().AddId(1).AddName("02"));
     Assert.IsNotNull(troopMovements, "TroopMovement is null!");
     Village village = new Village();
     village.SetTroopMovements(troopMovements);
     Assert.AreEqual(23, village.TroopMovementCount, "Troop movement count!");
     Assert.Sorted(village.TroopMovement, SortOrder.Increasing, new TroopMovementComparer());
     village.ClearTroopMovementsList();
     Assert.AreEqual(0, village.TroopMovementCount, "Troop movement count!");
 }
예제 #4
0
 /// <summary>
 /// Gets the available villages.
 /// </summary>
 /// <returns></returns>
 public List<Village> GetAvailableVillages()
 {
     List<Village> villages = new List<Village>();
     HtmlNode tableVillages = htmlDocument.DocumentNode.SelectSingleNode("//table[@id='vlist']");
     if (tableVillages == null)
     {
         HtmlNode nodeVillage = htmlDocument.DocumentNode.SelectSingleNode("//h1");
         Village village = new Village();
         village.AddName(nodeVillage.InnerText.Trim());
         villages.Add(village);
     }
     else
     {
         foreach (HtmlNode htmlNodeVillage in tableVillages.SelectNodes("./tbody//tr"))
         {
             //<td class="link"><a href="?newdid=75579" >01</a></td>
             HtmlNode singleNode = htmlNodeVillage.SelectSingleNode("./td[@class='link']");
             if(singleNode!=null)
             {
                 HtmlNode htmlNode = singleNode.SelectSingleNode(".//a");
                 string villageName = htmlNode.InnerText.Trim();
                 string villageId = htmlNode.Attributes["href"].Value.Trim();
                 //<div class="cox">(-82</div>
                 HtmlNode nodeCoordsX = htmlNodeVillage.SelectSingleNode(".//div[@class='cox']");
                 string x = nodeCoordsX.InnerText.Trim().Substring(1);
                 //<div class="coy">64)</div>
                 HtmlNode nodeCoordsY = htmlNodeVillage.SelectSingleNode(".//div[@class='coy']");
                 string trimY = nodeCoordsY.InnerText.Trim();
                 string y = trimY.Substring(0, trimY.Length - 1);
                 Village village = new Village();
                 village
                     .AddName(villageName)
                     .AddId(Misc.String2Number(villageId.Substring(8)))
                     .UpdateCoordinates(Misc.String2Number(x), Misc.String2Number(y));
                 villages.Add(village);
             }
         }
     }
     return villages;
 }
예제 #5
0
 public void ParseProduction()
 {
     HtmlDocument htmlDocument = new HtmlDocument();
     htmlDocument.Load("..\\..\\Test Files\\dorf1.php.html");
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     Village village = new Village();
     village.AddId(123).AddName("01");
     Production production = htmlParser.GetProduction();
     Assert.IsNotNull(production, "NULL");
     village.UpdateProduction(production);
     Assert.AreEqual(production, village.Production, "production");
     Assert.AreEqual(575, village.Production.WoodPerHour, "wood per hour");
     Assert.AreEqual(590, village.Production.ClayPerHour, "clay per hour");
     Assert.AreEqual(525, village.Production.IronPerHour, "iron per hour");
     Assert.AreEqual(359, village.Production.CropPerHour, "crop per hour");
     Assert.AreEqual(4675, village.Production.WoodTotal, "wood total");
     Assert.AreEqual(3343, village.Production.ClayTotal, "clay total");
     Assert.AreEqual(4463, village.Production.IronTotal, "iron total");
     Assert.AreEqual(5236, village.Production.CropTotal, "crop total");
     Assert.AreEqual(14400, village.Production.Warehouse, "warehouse");
     Assert.AreEqual(11800, village.Production.Granary, "granary");
 }
예제 #6
0
 /// <summary>
 /// Gets troop movements from rally point.
 /// </summary>
 /// <returns><see cref="List{T}"/></returns>
 public List<TroopMovement> TroopMovements(Village village)
 {
     List<TroopMovement> troopMovement = new List<TroopMovement>();
     DateTime dt = new DateTime(DateTime.Now.Ticks);
     HtmlNodeCollection nodes = htmlDocument.DocumentNode.SelectNodes("//table[@class='troop_details']");
     if (nodes != null)
     {
         foreach (HtmlNode tableNode in nodes)
         {
             TroopMovement movement = new TroopMovement();
             //source and destination
             HtmlNodeCollection htmlNodeCollection = tableNode.SelectNodes(".//thead/tr/td//a");
             if (htmlNodeCollection != null)
             {
                 HtmlNode nodeSource = htmlNodeCollection[0];
                 movement.SetSource(nodeSource.InnerText,
                                    nodeSource.Attributes["href"].Value);
                 HtmlNode nodeDestination = htmlNodeCollection[1];
                 movement.SetDestination(nodeDestination.InnerText,
                                         nodeDestination.Attributes["href"].Value);
             }
             //units
             HtmlNodeCollection nodeCollection = tableNode.SelectNodes(".//tbody[@class='units']//td");
             if (nodeCollection != null)
             {
                 Troops troops = new Troops();
                 int totalUnits = nodeCollection.Count/2;
                 for (int i = 0; i < totalUnits; i++)
                 {
                     string classAttribute = nodeCollection[i].Element("img").Attributes["class"].Value;
                     string titleAttribute = nodeCollection[i].Element("img").Attributes["title"].Value;
                     int unitCount = Misc.String2Number(nodeCollection[i + totalUnits].InnerText);
                     troops.AddTroopUnit(new TroopUnit(titleAttribute, unitCount).AddHtmlClassName(classAttribute));
                 }
                 movement.AddTroops(troops);
             }
             //resoures
             HtmlNodeCollection arrivalSpan =
                 tableNode.SelectNodes(".//tbody[@class='infos']//span[starts-with(@id, 'timer')]");
             if (arrivalSpan != null)
             {
                 TimeSpan timeSpan = Misc.String2TimeSpan(arrivalSpan[0].InnerText);
                 movement.SetDate(dt + timeSpan);
                 if (movement.SourceVillageName.Equals(village.Name))
                 {
                     //own troops
                     string destinationVillageName = movement.DestinationVillageName;
                     if ((destinationVillageName.StartsWith(language.RallyPoint.AttackOut)) ||
                         (destinationVillageName.StartsWith(language.RallyPoint.RaidOut)))
                     {
                         movement.SetType(TroopMovementType.AttackOutgoing);
                     }
                     else if (destinationVillageName.StartsWith(language.RallyPoint.ReinforcementBack))
                     {
                         movement.SetType(TroopMovementType.ReinforcementIncomming);
                     }
                     else if (destinationVillageName.StartsWith(language.RallyPoint.Scout))
                     {
                         movement.SetType(TroopMovementType.Scouting);
                     }
                     else
                     {
                         movement.SetType(TroopMovementType.ReinforcementOutgoing);
                     }
                 }
                 else
                 {
                     string destinationVillageName = movement.DestinationVillageName;
                     if ((destinationVillageName.StartsWith(language.RallyPoint.AttackIn)) ||
                         (destinationVillageName.StartsWith(language.RallyPoint.RaidIn)))
                     {
                         movement.SetType(TroopMovementType.AttackIncomming);
                     }
                     else
                     {
                         movement.SetType(TroopMovementType.ReinforcementIncomming);
                     }
                 }
             }
             else
             {
                 movement.SetType(TroopMovementType.Idle);
                 movement.SetDestination("", "");
             }
             troopMovement.Add(movement);
         }
     }
     return troopMovement;
 }
예제 #7
0
 /// <summary>
 /// Gets the center village buildings levels.
 /// </summary>
 /// <param name="village">The village.</param>
 /// <returns></returns>
 public List<Buildings> GetCenterBuildings(Village village)
 {
     List<Buildings> resources = new List<Buildings>();
     HtmlNodeCollection nodes = htmlDocument.DocumentNode.SelectNodes("//map[@id='map2']//area");
     if (nodes != null)
     {
         bool wallAdded = false;
         foreach (HtmlNode htmlNode in nodes)
         {
             if (htmlNode != null)
             {
                 //<area href="build.php?id=19" title="Žitnica Stopnja 10" alt="Žitnica Stopnja 10" coords="53,91,53,37,128,37,128,91,91,112" shape="poly"/>
                 string url = htmlNode.Attributes["href"].Value;
                 if (url.StartsWith("build.php"))
                 {
                     int id = Misc.String2Number(url.Substring(13));
                     string name = htmlNode.Attributes["title"].Value;
                     int index = name.LastIndexOf(' ');
                     int level = Misc.String2Number(name.Substring(index + 1));
                     if (!wallAdded)
                     {
                         if (id == 40)
                         {
                             wallAdded = true;
                         }
                         resources.Add(
                             new Buildings
                                 {
                                     Id = id,
                                     Name = name,
                                     Url = url,
                                     Level = level,
                                 });
                     }
                 }
             }
         }
     }
     return resources;
 }
예제 #8
0
 /// <summary>
 /// Adds the village to the list.
 /// </summary>
 /// <param name="village">The village.</param>
 public void AddVillage(Village village)
 {
     if (villages.Contains(village))
     {
         return;
     }
     villages.Add(village);
 }
예제 #9
0
        public void VillageData()
        {
            Production production = new Production();
            const int warehouse = 3100;
            const int granary = 4000;
            production
                .UpdateWarehouse(warehouse)
                .UpdateGranary(granary)
                .UpdateTotals(132, 213, 11, 223)
                .UpdatePerHour(100, 200, 300, 400);
            Assert.IsNotNull(production, "Production is null!");

            TroopUnit phalanx = new TroopUnit();
            phalanx.AddName("Phalanx").AddHtmlClassName("unit u23").AddTroopCount(11);
            TroopUnit axeman = new TroopUnit();
            axeman.AddName("Axeman").AddHtmlClassName("unit u3").AddTroopCount(22);
            Troops troops = new Troops();
            troops.AddTroopUnit(phalanx).AddTroopUnit(axeman);
            Assert.IsNotNull(troops.TroopsList, "Troop list is null!");

            const int villageId = 0;
            const string villageName = "asds";
            const int coordinateX = 13;
            const int coordinateY = -131;
            Village village = new Village();
            village
                .AddId(villageId)
                .AddName(villageName)
                .UpdateCoordinates(coordinateX, coordinateY)
                .UpdateProduction(production)
                .UpdateTroopsInVillage(troops);

            Assert.IsNotNull(village.Production, "Production is null!");
            Assert.IsNotNull(village.TroopsAvailable, "TroopsAvailable is null!");
            Assert.AreEqual(production, village.Production, "Village production!");
            Assert.AreEqual(troops, village.TroopsAvailable, "Village troops!");
            Assert.AreEqual(warehouse, village.Production.Warehouse, "Warehouse!");
            Assert.AreEqual(granary, village.Production.Granary, "Granary!");
            Assert.AreEqual(coordinateX, village.CoordinateX, "CoordinateX!");
            Assert.AreEqual(coordinateY, village.CoordinateY, "CoordinateY!");
            village
                .AddTroopsMovement(new TroopMovement()
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit11", 12)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit12", 13)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit13", 14)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit14", 15)))
                                       .SetDate(new DateTime(2222, 12, 1, 1, 1, 1))
                                       .SetType(TroopMovementType.AttackIncomming))
                .AddTroopsMovement(new TroopMovement()
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit31", 1201)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit32", 1202)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit33", 1203)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit34", 1204)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit35", 1205)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit36", 1206)))
                                       .SetDate(new DateTime(2222, 10, 1, 1, 1, 1))
                                       .SetType(TroopMovementType.AttackOutgoing))
                .AddTroopsMovement(new TroopMovement()
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit21", 121)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit22", 122)))
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit23", 123)))
                                       .SetDate(new DateTime(2222, 11, 1, 1, 1, 1))
                                       .SetType(TroopMovementType.AttackOutgoing))
                .AddTroopsMovement(new TroopMovement()
                                       .AddTroops(new Troops().AddTroopUnit(new TroopUnit("unit4", 12000)))
                                       .SetDate(new DateTime(2222, 9, 1, 1, 1, 1))
                                       .SetType(TroopMovementType.ReinforcementIncomming))
                ;

            Assert.IsNotNull(village.TroopMovement, "Troop movement!");
            Assert.AreEqual(4, village.TroopMovementCount, "Troop movement count!");
            Assert.AreEqual(2, village.OwnAttacks, "Own attacks!");
            Assert.Sorted(village.TroopMovement, SortOrder.Increasing, new TroopMovementComparer());
            village.ClearTroopMovementsList();
            Assert.AreEqual(0, village.TroopMovementCount, "Troop movement count!");
        }
예제 #10
0
 public void ParseUnknownDestination()
 {
     parseSucceeded = false;
     if (language == null) return;
     source = account.GetVillage(queue.SourceVillage.Id);
     if (source == null) return;
     string url = String.Format(CultureInfo.InvariantCulture,
                                "{0}build.php?newdid={1}&gid=17",
                                settings.LoginData.Servername, source.Id);
     htmlDocument = htmlWeb.Load(url);
     if (htmlDocument == null) return;
     HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
     marketPlaceSource = htmlParser.MarketPlace();
     if (marketPlaceSource == null) return;
     destination = queue.DestinationVillage;
     parseSucceeded = true;
 }
예제 #11
0
 private void PopulateRallyPoint(Village village)
 {
     Language language = languages.GetLanguage(settings.LanguageId);
     string servername = settings.LoginData.Servername;
     //http://s1.travian.com/build.php?newdid=75579&gid=16&id=39
     string url = String.Format(CultureInfo.InvariantCulture, "{0}build.php?newdid={1}&gid=16&id=39",
                                servername, village.Id);
     htmlDocument = htmlWeb.Load(url);
     HtmlParser htmlParser = new HtmlParser(htmlDocument, language);
     List<TroopMovement> troopMovements = htmlParser.TroopMovements(village);
     //ArrayList list = new ArrayList();
     //list.AddRange(troopMovements);
     UpdateDataGridViewRallyPoint(dataGridViewRallyPoint, troopMovements);
     UpdateStatus(String.Format(CultureInfo.InvariantCulture, "Populate Rally Point in {0}", village.Name));
 }
예제 #12
0
 private void PopulateMap(Village village)
 {
     int centerX = village.CoordinateX;
     int centerY = village.CoordinateY;
     List<Valley> list = new List<Valley>();
     foreach (Valley valley in map.Valleys)
     {
         double distance =
             Math.Round(Math.Sqrt(Math.Pow((valley.X - centerX), 2) + Math.Pow((valley.Y - centerY), 2)), 1);
         valley.AddDistance(distance);
         ValleyType valleyType = GetValleyTypeNotes(valley);
         valley.ValleyType = valleyType;
         if (checkBoxUnoccupiedOasis.Checked && valleyType == ValleyType.UnoccupiedOasis)
         {
             list.Add(valley);
         }
         else if (checkBoxMapOccupiedOasis.Checked && valleyType == ValleyType.OccupiedOasis)
         {
             list.Add(valley);
         }
         else if (checkBoxFarmsNoProfit.Checked && valleyType == ValleyType.FarmNoProfit)
         {
             list.Add(valley);
         }
         else if (checkBoxFarmsLowRisk.Checked && valleyType == ValleyType.FarmLowRisk)
         {
             list.Add(valley);
         }
         else if (checkBoxFarmsMiddleRisk.Checked && valleyType == ValleyType.FarmMiddleRisk)
         {
             list.Add(valley);
         }
         else if (checkBoxFarmsHighRish.Checked && valleyType == ValleyType.FarmHighRisk)
         {
             list.Add(valley);
         }
         else if (checkBoxAlly.Checked && valleyType == ValleyType.AllianceAlly)
         {
             list.Add(valley);
         }
         else if (checkBoxNap.Checked && valleyType == ValleyType.AllianceNap)
         {
             list.Add(valley);
         }
         else if (checkBoxWar.Checked && valleyType == ValleyType.AllianceWar)
         {
             list.Add(valley);
         }
         else if (checkBoxExcludedPlayers.Checked && valleyType == ValleyType.ExcludedPlayer)
         {
             list.Add(valley);
         }
         else if (checkBoxExcludedAlliances.Checked && valleyType == ValleyType.ExcludedAlliance)
         {
             list.Add(valley);
         }
         else
         {
             if (valley.ValleyType == ValleyType.UnknownType)
             {
                 list.Add(valley);
             }
         }
     }
     list.Sort((v1, v2) => Comparer<double>.Default.Compare(v1.Distance, v2.Distance));
     UpdateDataGridViewMap(dataGridViewMap, list);
     //if (dataGridViewMap.InvokeRequired)
     //{
     //    SetDataGridViewRallyPoint m = SetDataSource;
     //    Invoke(m, new object[] {dataGridViewMap, list});
     //}
     //else
     //{
     //    dataGridViewMap.DataSource = list;
     //}
 }
예제 #13
0
 private void PopulateBuildQueueForVillage(Village village)
 {
     string servername = settings.LoginData.Servername;
     string url = String.Format(CultureInfo.InvariantCulture, "{0}dorf1.php?newdid={1}",
                                servername, village.Id);
     htmlDocument = htmlWeb.Load(url);
     HtmlParser htmlParser = new HtmlParser(htmlDocument);
     List<Buildings> resources = htmlParser.GetResourceBuildings();
     url = String.Format(CultureInfo.InvariantCulture, "{0}dorf2.php?newdid={1}",
                         servername, village.Id);
     htmlDocument = htmlWeb.Load(url);
     htmlParser = new HtmlParser(htmlDocument);
     List<Buildings> center = htmlParser.GetCenterBuildings(village);
     ArrayList list = new ArrayList();
     list.AddRange(resources);
     list.AddRange(center);
     UpdateComboBoxQueues(comboBoxBuildQueueBuilding, list);
 }
예제 #14
0
 private void GetMapInfo(Village selectedVillage)
 {
     DisableMapButtons();
     int x = selectedVillage.CoordinateX;
     int y = selectedVillage.CoordinateY;
     int distance = Misc.String2Number(textBoxMapDistance.Text.Trim());
     map.Valleys.Clear();
     if (distance < 2)
     {
         GetMapInfoAt(x, y);
     }
     else
     {
         for (int i = 0; i < distance; i++)
         {
             if (i != 1)
             {
                 continue;
             }
             int size = 7*i;
             for (int j = (1 - distance); j < distance; j++)
             {
                 for (int k = (1 - distance); k < distance; k++)
                 {
                     int distX = size*k;
                     int distY = size*j;
                     GetMapInfoAt(x + distX, y + distY);
                 }
             }
         }
     }
     //UpdateStatus(String.Format(CultureInfo.InvariantCulture, "Valleys count: {0}", map.Valleys.Count));
     map.SerializeValleys();
     EnableMapButtons();
 }
예제 #15
0
 /// <summary>
 /// Adds item to listview of build queue.
 /// </summary>
 /// <param name="buildings">The buildings.</param>
 /// <param name="selectedVillage">The selected village.</param>
 /// <param name="level">The level.</param>
 private void UpdateQueue(Buildings buildings, Village selectedVillage, ComboBox level)
 {
     StringBuilder sb = new StringBuilder();
     string[] strings = buildings.Name.Split(' ');
     for (int i = 0; i < strings.Length - 2; i++)
     {
         sb.AppendFormat("{0} ", strings[i]);
     }
     BuildQueue buildQueue = new BuildQueue
         {
             Level = Misc.String2Number(level.SelectedItem.ToString()),
             Name = sb.ToString().Trim(),
             BuildingId = buildings.Id,
             VillageId = selectedVillage.Id,
             VillageName = selectedVillage.Name,
         };
     if (!actions.BuildQueue.Contains(buildQueue))
     {
         UpdateStatus("New build queue: " + buildQueue);
         actions.BuildQueue.Add(buildQueue);
     }
 }
예제 #16
0
        public void Account()
        {
            Account account = new Account();
            const string accountName = "kekec";
            const int accountId = 123;
            const TribeTypes accountTribe = TribeTypes.Gauls;
            account.AddName(accountName).AddId(accountId).AddTribe(accountTribe);
            Assert.IsNotNull(account, "Account is null!");
            Assert.AreEqual(accountName, account.Name);
            Assert.AreEqual(accountId, account.Id);
            Assert.AreEqual(accountTribe, account.TribeType);

            Village firstVillage = new Village();
            const int firstVillageId = 0;
            const string firstVillageName = "01";
            firstVillage.AddId(firstVillageId).AddName(firstVillageName);
            account.AddVillage(firstVillage);
            Assert.IsNotNull(account.Villages, "Village list!");
            Assert.AreEqual(1, account.Villages.Count, "Village list count!");
            Assert.AreEqual(firstVillageId, account.Villages[0].Id, "Village id!");
            Assert.AreEqual(firstVillageName, account.Villages[0].Name, "Village name!");

            Village secondVillage = new Village();
            const int secondVillageId = 1324;
            const string secondVillageName = "02";
            secondVillage.AddId(secondVillageId).AddName(secondVillageName);
            Production production = new Production();
            production
                .UpdateWarehouse(3100)
                .UpdateGranary(4000)
                .UpdateTotals(132, 213, 11, 223)
                .UpdatePerHour(100, 200, 300, 400);
            secondVillage.UpdateProduction(production);
            account.AddVillage(secondVillage);

            Assert.AreEqual(2, account.Villages.Count, "Village list count!");

            Village firstAccountVillage = account.GetVillage(firstVillageId);
            Assert.IsNotNull(firstAccountVillage, "Village not found!");
            Assert.AreEqual(firstVillageId, firstAccountVillage.Id, "Village id!");
            Assert.AreEqual(firstVillageName, firstAccountVillage.Name, "Village name!");
            Assert.IsNull(firstAccountVillage.Production, "Village production!");
            Assert.IsNull(firstAccountVillage.TroopsAvailable, "Village troops!");

            Village secondAccountVillage = account.GetVillage(secondVillageId);
            Assert.IsNotNull(secondAccountVillage, "Village not found!");
            Assert.AreEqual(secondVillageId, secondAccountVillage.Id, "Village id!");
            Assert.AreEqual(secondVillageName, secondAccountVillage.Name, "Village name!");
            Assert.AreEqual(production, secondAccountVillage.Production, "Village production!");
            Assert.IsNull(secondAccountVillage.TroopsAvailable, "Village troops!");

            Gauls gauls = new Gauls();
            TroopUnit phalanx = gauls.Phalanx.AddTroopCount(123);
            TroopUnit haeduan = gauls.Haeduan.AddTroopCount(13);
            Romans romans = new Romans();
            TroopUnit legionnaire = romans.Legionnaire.AddTroopCount(2222);
            TroopUnit praetorian = romans.Praetorian.AddTroopCount(45632);
            Teutons teutons = new Teutons();
            TroopUnit spearman = teutons.Spearman.AddTroopCount(5123);
            Troops troops = new Troops();
            troops
                .AddTroopUnit(phalanx).AddTroopUnit(haeduan)
                .AddTroopUnit(legionnaire).AddTroopUnit(praetorian)
                .AddTroopUnit(spearman);
            secondAccountVillage.UpdateTroopsInVillage(troops);
            Assert.IsNull(firstAccountVillage.TroopsAvailable, "Village troops!");
            Assert.IsNotNull(secondAccountVillage.TroopsAvailable, "Village troops!");
            Assert.AreEqual(13, secondAccountVillage.TroopsAvailable.GetTroopCount("unit u26"), "Haeduan count!");
        }