Exemple #1
0
        public WN8ExpValues()
        {
            XmlDocument xmlDoc      = new XmlDocument();
            XmlNodeList nodes       = null;
            XmlNodeList headerNodes = null;

            try
            {
                xmlDoc.Load(WOTHelper.GetWN8ExpectedTankValuesFile());
                XmlElement root = xmlDoc.DocumentElement;
                nodes       = root.SelectSingleNode("WN8").ChildNodes;
                headerNodes = root.SelectSingleNode("Header").ChildNodes;
            }
            catch (Exception ex)
            {
                WOTHelper.AddToLog(ex.Message);
            }
            WN8Version   = 0;
            WN8DateEpoch = 0;
            WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0);
            if (headerNodes != null)
            {
                foreach (XmlNode headerNode in headerNodes)
                {
                    if (headerNode.Name == "Version")
                    {
                        WN8Version = Convert.ToInt16(headerNode.InnerText);
                    }

                    if (headerNode.Name == "Date")
                    {
                        WN8DateEpoch = Convert.ToInt32(headerNode.InnerText);
                        WN8Date      = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(WN8DateEpoch);
                    }
                }
            }

            if (nodes != null)
            {
                MessageQueue     _messages       = null;
                TankDescriptions tankDescription = new TankDescriptions(_messages);
                foreach (XmlNode node in nodes)
                {
                    WN8ExpValue expVal = new WN8ExpValue();

                    expVal.Tank       = tankDescription.Description(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.Country    = Translations.TranslationGet(Convert.ToString(node.Attributes["countryid"].Value), "DE", Convert.ToString(node.Attributes["countryid"].Value));
                    expVal.Tier       = tankDescription.Tier(Convert.ToInt32(node.Attributes["countryid"].Value), Convert.ToInt32(node.Attributes["tankid"].Value));
                    expVal.tankID     = Convert.ToInt32(node.Attributes["tankid"].Value);
                    expVal.countryID  = Convert.ToInt32(node.Attributes["countryid"].Value);
                    expVal.expFrag    = double.Parse(node.Attributes["expFrag"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDamage  = double.Parse(node.Attributes["expDamage"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expSpot    = double.Parse(node.Attributes["expSpot"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expDefense = double.Parse(node.Attributes["expDef"].Value, System.Globalization.CultureInfo.InvariantCulture);
                    expVal.expWin     = double.Parse(node.Attributes["expWinRate"].Value, System.Globalization.CultureInfo.InvariantCulture);

                    Add(expVal);
                }
            }
        }