Exemple #1
0
        /// <summary>
        /// Gets the troop amounts
        /// </summary>
        /// <param name="groupAmount">The RegEx group with home troops</param>
        /// <param name="groupLost">The RegEx group with lost troops</param>
        /// <param name="groupOut">The RegEx group with the out troops</param>
        private static Dictionary <UnitTypes, ReportUnit> GetTroops(Group groupAmount, Group groupLost, Group groupOut)
        {
            var troops = new Dictionary <UnitTypes, ReportUnit>();

            for (int i = 0; i < groupAmount.Captures.Count; i++)
            {
                if (WorldUnits.Default[i] != null)
                {
                    var unit = new ReportUnit(WorldUnits.Default[i]);
                    int val;
                    if (GetTroopCount(groupAmount.Captures[i].Value, out val))
                    {
                        unit.AmountStart = val;
                        if (GetTroopCount(groupLost.Captures[i].Value, out val))
                        {
                            unit.AmountLost = val;
                        }
                        if (groupOut != null && groupOut.Captures.Count > 0 && GetTroopCount(groupOut.Captures[i].Value, out val))
                        {
                            unit.AmountOut = val;
                        }
                        troops.Add(unit.Unit.Type, unit);
                    }
                }
            }
            return(troops);
        }
Exemple #2
0
        public virtual void ReadXml(XmlReader r)
        {
            r.MoveToContent();
            string   reportDate = r.GetAttribute(0);
            DateTime reportDateTest;

            if (DateTime.TryParse(reportDate, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out reportDateTest))
            {
                _dateReport = reportDateTest;
            }
            _dateCopied = Convert.ToDateTime(r.GetAttribute(1), System.Globalization.CultureInfo.InvariantCulture);

            r.Read();
            _reportType   = (ReportTypes)Convert.ToInt32(r.ReadElementString("Type"));
            _reportStatus = (ReportStatusses)Convert.ToInt32(r.ReadElementString("Status"));
            _reportFlag   = (ReportFlags)Convert.ToInt32(r.ReadElementString("Flags"));

            r.MoveToContent();
            _loyaltyBegin = Convert.ToInt32(r.GetAttribute(0));
            _loyaltyEnd   = Convert.ToInt32(r.GetAttribute(1));
            r.Read();
            r.MoveToContent();

            _attacker = new ReportVillage();
            _attacker.ReadXml(r);
            //r.ReadEndElement();
            //r.MoveToContent();

            _defender = new ReportVillage();
            _defender.ReadXml(r);
            //r.Read();
            //r.MoveToContent();
            //r.ReadStartElement();
            //r.MoveToContent();

            _resourcesHaul = new Resource();
            r.Read();
            _resourcesHaul.ReadXml(r);
            //r.ReadEndElement();
            _resourceHaulMax = Convert.ToInt32(r.ReadElementString("Max"));
            r.Read();
            r.Read();

            _resourcesLeft = new Resource();
            _resourcesLeft.ReadXml(r);
            r.Read();

            DateTime?tempDate;

            _attack = ReportUnit.LoadXmlList(r, out tempDate);

            _defense = ReportUnit.LoadXmlList(r, out tempDate);

            _buildings = ReportBuilding.LoadXmlList(r, out tempDate);

            r.ReadEndElement();
            r.Read();
        }
Exemple #3
0
        public virtual void WriteXml(XmlWriter w)
        {
            w.WriteStartElement("Report");
            if (_dateReport.HasValue)
            {
                w.WriteAttributeString("Report", _dateReport.Value.ToString(System.Globalization.CultureInfo.InvariantCulture));
            }
            else
            {
                w.WriteAttributeString("Report", "");
            }
            w.WriteAttributeString("Copied", _dateCopied.ToString(System.Globalization.CultureInfo.InvariantCulture));

            w.WriteElementString("Type", ((int)_reportType).ToString());
            w.WriteElementString("Status", ((int)_reportStatus).ToString());
            w.WriteElementString("Flags", ((int)_reportFlag).ToString());

            w.WriteStartElement("Loyalty");
            w.WriteAttributeString("Begin", _loyaltyBegin.ToString());
            w.WriteAttributeString("End", _loyaltyEnd.ToString());
            w.WriteEndElement();

            Attacker.WriteXml(w);
            Defender.WriteXml(w);

            w.WriteStartElement("Haul");
            _resourcesHaul.WriteXml(w);
            w.WriteElementString("Max", _resourceHaulMax.ToString());
            w.WriteEndElement();

            w.WriteStartElement("Scouted");
            _resourcesLeft.WriteXml(w);
            w.WriteEndElement();

            ReportUnit.WriteXmlList(w, "Attack", Attack, true, null);
            ReportUnit.WriteXmlList(w, "Defense", Defense, true, null);

            ReportBuilding.WriteXmlList(w, Buildings, null);

            w.WriteEndElement();
        }