Example #1
0
        public void RunTests()
        {
            HTCPilotStatsSvc   statsSvc = new HTCPilotStatsSvc();
            AcesHighPilotStats stats    = statsSvc.GetPilotStatsMultiThreaded("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            HTCPilotScoreSvc   scoreSvc = new HTCPilotScoreSvc();
            AcesHighPilotScore score    = scoreSvc.GetPilotScore("99MecInf", TourType.MainArenaTour, 76, new ProxySettingsDTO());

            int i = 0;

            /*
             * TourNode tour = TourDefinitions.Instance.GetTourDetails(76, TourType.MainArenaTour);
             *
             * Sender httpSender = new Sender(new ProxySettingsDTO());
             * StreamReader prototype = File.OpenText("individual_scores.http.txt");
             * httpSender.RequestString = "gameid=" + "99MecInf" + "&tour=" + tour.FullyQualifiedTourIdentifier;
             * httpSender.URLEncodeRequestString();
             * httpSender.Initialise(prototype, "http://www.hitechcreations.com/cgi-bin/105score/105score.pl");
             * StreamReader response = httpSender.Send();
             *
             *
             * string PilotVsBuffer = response.ReadToEnd();
             * StringReader pilotVsStringReader = new StringReader(PilotVsBuffer);
             *
             * // Use the cool sgml reader to 'interpret' the HTML as XML :) very nice!
             * SgmlReader pilotVsSgmlReader = new SgmlReader();
             * pilotVsSgmlReader.DocType = "HTML";
             * pilotVsSgmlReader.InputStream = pilotVsStringReader;
             * statsXmlDoc.Load(pilotVsSgmlReader);
             *
             * statsXmlDoc.Save(Console.Out);
             * statsXmlDoc.Save(@"C:\response.xml");
             */
        }
Example #2
0
 public static void ConstructAcesHighPilotStatsInnerObjects(ref AcesHighPilotStats pilotStats, int objScoreLen)
 {
     pilotStats.VsCountry = new AcesHighPilotStatsVsCountry {
         CountryScore = new CountryScore[3]
     };
     pilotStats.VsObjects = new AcesHighPilotStatsVsObjects {
         ObjectScore = new ObjectScore[objScoreLen]
     };
 }
Example #3
0
        public void ConstructStatsForPilot(AcesHighPilotStats stats, string pilotName)
        {
            if (stats.VsObjects.ObjectScore == null)
            {
                throw new ApplicationException(string.Format("No stats objects can be found for pilot {0} in tour {1}",
                                                             pilotName, stats.TourDetails));
            }

            // for each aircraft listed for that tour.
            foreach (var objScore in stats.VsObjects.ObjectScore)
            {
                // build mathmatical set of models (eg no duplicate entries).
                ModelSet.Add(objScore.Model);

                // add objVsObj score to our complete list.
                var objVsObjDo = new ObjectVsObjectDO(objScore, stats.TourDetails, stats.TourType,
                                                      int.Parse(stats.TourId));
                GetPilotStats(pilotName).ObjVsObjCompleteList.Add(objVsObjDo);
            }
        }
Example #4
0
        /// <summary>
        /// </summary>
        /// <param name="squad"></param>
        /// <param name="tourNumber"></param>
        /// <param name="reloadPilotsRequired"></param>
        /// <returns></returns>
        public AcesHighPilotStats BuildSquadStatsObject(Squad squad, int tourNumber, ref bool reloadPilotsRequired)
        {
            var tourIdentifier = "";
            var tourType       = "";

            var tourStats = new Dictionary <string, ObjectScore>();

            // FOR EACH PILOT IN SQUAD
            foreach (var squadMember in squad.Members.Where(member => Registry.PilotStatsContains(member.PilotName)))
            {
                // get pilot's registry.
                var pilotReg = Registry.GetPilotStats(squadMember.PilotName);

                // If Pilot wasnt in this sqaud for this tour, dont count their data
                if (!squad.WasPilotInSquadForThisTour(tourNumber, squadMember))
                {
                    continue;
                }

                // FOR EACH MODEL
                foreach (var objVsObj in pilotReg.ObjVsObjCompleteList.Where(objVsObj => objVsObj.TourNumber == tourNumber))
                {
                    if (tourIdentifier == "")
                    {
                        tourIdentifier = objVsObj.TourIdentfier;
                    }

                    if (tourType == "")
                    {
                        tourType = objVsObj.TourType;
                    }

                    if (!tourStats.ContainsKey(objVsObj.Model))
                    {
                        // doesnt exist yet? create new one and add.
                        var thisObjvObj = new ObjectScore
                        {
                            Model    = objVsObj.Model,
                            KilledBy = objVsObj.KilledBy,
                            KillsIn  = objVsObj.KillsIn,
                            KillsOf  = objVsObj.KillsOf,
                            DiedIn   = objVsObj.DiedIn
                        };
                        if (objVsObj.DiedIn == null)
                        {
                            reloadPilotsRequired = true;
                        }

                        tourStats.Add(thisObjvObj.Model, thisObjvObj);
                    }
                    else
                    {
                        // get existing objects reference and add to it.
                        var thisObjvObj = tourStats[objVsObj.Model];
                        thisObjvObj.KilledBy += objVsObj.KilledBy;
                        thisObjvObj.KillsIn  += objVsObj.KillsIn;
                        thisObjvObj.KillsOf  += objVsObj.KillsOf;
                        thisObjvObj.DiedIn   += objVsObj.DiedIn;
                        if (objVsObj.DiedIn == null)
                        {
                            reloadPilotsRequired = true;
                        }
                    }
                }
            }

            var squadStatsObj = new AcesHighPilotStats();

            Utility.ConstructAcesHighPilotStatsInnerObjects(ref squadStatsObj, tourStats.Count);
            squadStatsObj.GameId      = squad.SquadName;
            squadStatsObj.TourId      = tourNumber.ToString();
            squadStatsObj.TourType    = tourType;
            squadStatsObj.TourDetails = tourIdentifier;

            // copy the list content to bounded sized array.
            var i = 0;

            foreach (var obj in tourStats.Values)
            {
                squadStatsObj.VsObjects.ObjectScore[i++] = obj;
            }

            return(squadStatsObj);
        }