public static void GetTownHallInfomation(int iIndex) {//xem nhu da o trong trang townhall //total gold and total gold per hour HtmlNode node1 = Gloval.Database.DocumentNode.SelectSingleNode( XPathManager.XPathCity.PopulationLimit); Gloval.Database.Account.Cities[iIndex].PopulationLimit = NodeParser.toLong(node1.InnerText); //---------------- HtmlNode node2 = Gloval.Database.DocumentNode.SelectSingleNode( XPathManager.XPathCity.PopulationGrow); Gloval.Database.Account.Cities[iIndex].PopulationGrow = float.Parse(node2.InnerText.Split(' ')[0]); //net gold HtmlNode node3 = Gloval.Database.DocumentNode.SelectSingleNode( XPathManager.XPathCity.NetGold); Gloval.Database.Account.Cities[iIndex].GoldPerHour = NodeParser.toUnsignedLong(node3.InnerText); //scientist point per hour HtmlNode node4 = Gloval.Database.DocumentNode.SelectSingleNode( XPathManager.XPathCity.ScientistPointPerHour); Gloval.Database.Account.Cities[iIndex].ResearchPointPerHour = NodeParser.toInt(node4.NextSibling.InnerText); }
static DTOResearchBranch GetInfoResearchBranch(HtmlNode node) { DTOResearchBranch rb = new DTOResearchBranch(); rb.Name = node.ChildNodes[1].ChildNodes[0].InnerText.Trim(new char[] { '\r', '\n', '\t' }); rb.Description = node.ChildNodes[5].InnerText; rb.Need = NodeParser.toInt(node.ChildNodes[9].ChildNodes[3].ChildNodes[1].ChildNodes[0].InnerText); return(rb); }
static DTOTroops GetUnitAndTroop(HtmlNode node, DTOTroops.TYPE type, bool bIsUnits) { DTOTroops troop = new DTOTroops(); troop.Type = type; troop.IsUnits = bIsUnits; //string strTemp = node.InnerText; //strTemp = strTemp.Replace(",", ""); //strTemp = strTemp.Replace("-", ""); //troop.Quality = int.Parse(strTemp); troop.Quality = NodeParser.toInt(node.InnerText); return(troop); }
public static DTOResearch GetCurrentResearchScientists() {//xem nhu chuyen trang roi` ////ul[@class='researchLeftMenu'] if (Gloval.Database.Account.Research == null) { Gloval.Database.Account.Research = new DTOResearch(); } HtmlNode node = Gloval.Database.DocumentNode.SelectSingleNode(XPathManager.XPathResearch.ResearchPoint); Gloval.Database.Account.Research.Scientists = NodeParser.toInt(node.ChildNodes[1].InnerText); Gloval.Database.Account.Research.ResearchPoints = NodeParser.toLong(node.ChildNodes[3].InnerText); Gloval.Database.Account.Research.ResearchPointsPerHour = NodeParser.toInt(node.ChildNodes[5].InnerText); return(Gloval.Database.Account.Research); }
public static DTOResearch GetResearchInformation() {//xem nhu chuyen trang roi` DTOResearch rs = new DTOResearch(); //scientist point HtmlNode node = Gloval.Database.DocumentNode.SelectSingleNode(XPathManager.XPathResearch.ResearchPoint); rs.Scientists = NodeParser.toInt(node.ChildNodes[1].InnerText); rs.ResearchPoints = NodeParser.toLong(node.ChildNodes[3].InnerText); rs.ResearchPointsPerHour = NodeParser.toInt(node.ChildNodes[5].InnerText); //4 branch HtmlNodeCollection noderesearchinfoCol = Gloval.Database.DocumentNode.SelectNodes(XPathManager.XPathResearch.ResearchEntry); rs.Seafaring = GetInfoResearchBranch(noderesearchinfoCol[0]); rs.Economic = GetInfoResearchBranch(noderesearchinfoCol[1]); rs.Scientific = GetInfoResearchBranch(noderesearchinfoCol[2]); rs.Militaristic = GetInfoResearchBranch(noderesearchinfoCol[3]); return(rs); }
static DTOResearchBranch GetInfoResearchBranch(HtmlNode node) { DTOResearchBranch rb = new DTOResearchBranch(); rb.Name = node.ChildNodes[1].ChildNodes[0].InnerText.Trim(new char[] { '\r', '\n', '\t' }); rb.Description = node.ChildNodes[5].InnerText; //HtmlNode nodeNeed = node.ChildNodes[9].ChildNodes[3].ChildNodes[1].ChildNodes[0]; HtmlNode nodeNeed = node.SelectSingleNode("./div[@class='costs']/ul/li"); if (nodeNeed != null) { rb.Need = NodeParser.toInt(nodeNeed.InnerText); rb.NeedDescription = ""; } else { rb.Need = 0; rb.NeedDescription = node.SelectSingleNode("./div[2]").InnerText.Trim(new char[] { '\r', '\n', '\t' }); } return(rb); }
public static DTOBuilding[] GetBuildingCity() {//xem nhu da vao duoc view thanh pho HtmlNodeCollection nodeCol = Gloval.Database.DocumentNode.SelectNodes( XPathManager.XPathCity.ListBuilding); List <DTOBuilding> list = new List <DTOBuilding>(); foreach (HtmlNode node in nodeCol) { if (!node.GetAttributeValue("id", "err").Contains("position")) { continue; } DTOBuilding building = new DTOBuilding(); //tên của building --> type tương ứng string strTemp = node.GetAttributeValue("class", "err"); switch (strTemp) { case "townHall": building.Type = DTOBuilding.TYPE.Townhall; break; case "museum": building.Type = DTOBuilding.TYPE.Museum; break; case "palace": building.Type = DTOBuilding.TYPE.Palace; break; case "vineyard": building.Type = DTOBuilding.TYPE.Winepress; break; case "tavern": building.Type = DTOBuilding.TYPE.Tavern; break; case "safehouse": building.Type = DTOBuilding.TYPE.Hideout; break; case "architect": building.Type = DTOBuilding.TYPE.Architect; break; case "dump": building.Type = DTOBuilding.TYPE.Dump; break; case "academy": building.Type = DTOBuilding.TYPE.Academy; break; case "forester": building.Type = DTOBuilding.TYPE.Forester; break; case "winegrower": building.Type = DTOBuilding.TYPE.Winegrower; break; case "carpentering": building.Type = DTOBuilding.TYPE.Carpenter; break; case "wall": building.Type = DTOBuilding.TYPE.Townwall; break; case "port": building.Type = DTOBuilding.TYPE.TradingPort; break; case "shipyard": building.Type = DTOBuilding.TYPE.Shipyard; break; case "palaceColony": building.Type = DTOBuilding.TYPE.PalaceColony; break; case "stonemason": building.Type = DTOBuilding.TYPE.Stonemason; break; case "barracks": building.Type = DTOBuilding.TYPE.Barracks; break; case "fireworker": building.Type = DTOBuilding.TYPE.Firework; break; case "warehouse": building.Type = DTOBuilding.TYPE.Warehouse; break; case "temple": building.Type = DTOBuilding.TYPE.Temple; break; case "glassblowing": building.Type = DTOBuilding.TYPE.GlassBlower; break; case "optician": building.Type = DTOBuilding.TYPE.Optician; break; case "alchemist": building.Type = DTOBuilding.TYPE.Alchemist; break; case "embassy": building.Type = DTOBuilding.TYPE.Embassy; break; case "buildingGround land": building.Type = DTOBuilding.TYPE.Flag; break; case "buildingGround shore": building.Type = DTOBuilding.TYPE.Flag; break; case "branchOffice": building.Type = DTOBuilding.TYPE.TradingPost; break; case "workshop": building.Type = DTOBuilding.TYPE.Workshop; break; default: building.Type = DTOBuilding.TYPE.Unknown; break; } //kiểm tra is bulding if ("constructionSite" == node.ChildNodes[1].GetAttributeValue("class", "err")) { building.IsBuilding = true; //lấy thời gian xây .5.3 building.Time = node.ChildNodes[5].ChildNodes[2].InnerText; } else { building.IsBuilding = false; } //lấy lvl //strTemp = node.ChildNodes[3].GetAttributeValue("title", "err"); //strTemp = strTemp.Substring(strTemp.LastIndexOf(' ')); building.Lvl = NodeParser.toInt(node.ChildNodes[3].GetAttributeValue("title", "err")); list.Add(building); } return(list.ToArray()); }
//cap nhat dan so //action point //4 loai tai nguyen cua tp public static void UpdateResourceCity(int iIndexCity) { HtmlNodeCollection nodeLi = Gloval.Database.DocumentNode.SelectNodes( XPathManager.XPathCity.cityResources); foreach (HtmlNode nodeLiChild in nodeLi) { switch (nodeLiChild.GetAttributeValue("class", "err")) { case "population": { //population: 966 (1,627) string str = nodeLiChild.InnerText; string strFreePo = str.Substring(0, str.IndexOf('(') - 1); Gloval.Database.Account.Cities[iIndexCity].FreePopulation = NodeParser.toInt(strFreePo); string strPo = str.Substring(str.IndexOf('(') + 1); Gloval.Database.Account.Cities[iIndexCity].Population = NodeParser.toInt(strPo); break; } case "actions": { Gloval.Database.Account.Cities[iIndexCity].ActionPoint = NodeParser.toInt(nodeLiChild.InnerText); break; } case "wood": { Gloval.Database.Account.Cities[iIndexCity].Wood = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_wood']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { Gloval.Database.Account.Cities[iIndexCity].WoodLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } Gloval.Database.Account.Cities[iIndexCity].WoodPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); Gloval.Database.Account.Cities[iIndexCity].WoodLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "wine": { Gloval.Database.Account.Cities[iIndexCity].Wine = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_wine']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { Gloval.Database.Account.Cities[iIndexCity].WineLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } Gloval.Database.Account.Cities[iIndexCity].WinePerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); Gloval.Database.Account.Cities[iIndexCity].WineLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "marble": { Gloval.Database.Account.Cities[iIndexCity].Marble = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_marble']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { Gloval.Database.Account.Cities[iIndexCity].MarbleLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } Gloval.Database.Account.Cities[iIndexCity].MarblePerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); Gloval.Database.Account.Cities[iIndexCity].MarbleLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "glass": { Gloval.Database.Account.Cities[iIndexCity].Crystal = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_crystal']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { Gloval.Database.Account.Cities[iIndexCity].CrystalLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } Gloval.Database.Account.Cities[iIndexCity].CrystalPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); Gloval.Database.Account.Cities[iIndexCity].CrystalLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "sulfur": { Gloval.Database.Account.Cities[iIndexCity].Sulphur = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_sulfur']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { Gloval.Database.Account.Cities[iIndexCity].SulphurLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } Gloval.Database.Account.Cities[iIndexCity].SulphurPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); Gloval.Database.Account.Cities[iIndexCity].SulphurLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } } } Gloval.Database.Account.Cities[iIndexCity].IsUpdatedResource = true; //MessageBox.Show(Gloval.Database.accInf.Cities[iIndexCity].Population.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].PopulationLimit.ToString() // + "/ " + Gloval.Database.accInf.Cities[iIndexCity].ActionPoint.ToString() //+ "/ " + Gloval.Database.accInf.Cities[iIndexCity].Wood.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].WoodPerHour.ToString() //+ "/ " + Gloval.Database.accInf.Cities[iIndexCity].Wine.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].WinePerHour.ToString() //+ "/ " + Gloval.Database.accInf.Cities[iIndexCity].Marble.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].MarblePerHour.ToString() //+ "/ " + Gloval.Database.accInf.Cities[iIndexCity].Crystal.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].CrystalPerHour.ToString() //+ "/ " + Gloval.Database.accInf.Cities[iIndexCity].Sulphur.ToString() + " " + Gloval.Database.accInf.Cities[iIndexCity].SulphurPerHour.ToString()); }
//cap nhat dan so //action point //4 loai tai nguyen cua tp public static DTOCity ParseResources(DTOCity ct) { HtmlNodeCollection nodeLi = Gloval.Database.DocumentNode.SelectNodes( XPathManager.XPathCity.cityResources); foreach (HtmlNode nodeLiChild in nodeLi) { switch (nodeLiChild.GetAttributeValue("class", "err")) { case "population": { //population: 966 (1,627) string str = nodeLiChild.InnerText; string strFreePo = str.Substring(0, str.IndexOf('(') - 1); ct.FreePopulation = NodeParser.toInt(strFreePo); string strPo = str.Substring(str.IndexOf('(') + 1); ct.Population = NodeParser.toInt(strPo); break; } case "actions": { ct.ActionPoint = NodeParser.toInt(nodeLiChild.InnerText); break; } case "wood": { HtmlNode node = nodeLiChild.SelectSingleNode("./span[@id='value_wood']"); if (node == null) { break; } ct.Wood = NodeParser.toInt(node.InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { ct.WoodLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } ct.WoodPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); ct.WoodLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "wine": { ct.Wine = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_wine']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { ct.WineLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } ct.WinePerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); ct.WineLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "marble": { ct.Marble = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_marble']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { ct.MarbleLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } ct.MarblePerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); ct.MarbleLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "glass": { ct.Crystal = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_crystal']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { ct.CrystalLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } ct.CrystalPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); ct.CrystalLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } case "sulfur": { ct.Sulphur = NodeParser.toInt(nodeLiChild.SelectSingleNode("./span[@id='value_sulfur']").InnerText); if (nodeLiChild.ChildNodes[5].ChildNodes.Count == 3) { ct.SulphurLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); break; } ct.SulphurPerHour = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[1]").NextSibling.InnerText); ct.SulphurLimit = NodeParser.toInt(nodeLiChild.SelectSingleNode("./div/span[2]").NextSibling.InnerText); break; } } } return(ct); }