Beispiel #1
0
        /// <summary>
        /// Update UI with an individual pilot's statistics
        /// </summary>
        /// <param name="pilotStats"></param>
        private void UpdateUI(PilotStats pilotStats)
        {
            DataRow row = primaryTable.Rows.Find(pilotStats.PilotId);

            row["Dangerous"] = pilotStats.DangerPercent;
            row["Solo"]      = pilotStats.SoloPercent;
            row["Notes"]     = lookup.GetNotesFor(pilotStats);

            RefreshSorting();
        }
Beispiel #2
0
        /// <summary>
        /// Find stats for a list of pilots
        /// </summary>
        /// <param name="pilots"></param>
        /// <returns></returns>
        public async Task <PilotStats> FindStatsFor(Affiliation affiliation)
        {
            PilotStats stats = await statController.GetPilotStats(affiliation.Character_Id);

            stats.Notes = GetNotesFor(stats);
            PilotId pilot = pilots.Find(x => x.Id == affiliation.Character_Id);

            cache.Add(pilot, affiliation, stats);

            return(stats);
        }
Beispiel #3
0
        /// <summary>
        /// Get notes on a pilots statistics
        /// </summary>
        /// <param name="pilotStats">A PilotStats object</param>
        /// <returns>A string with any relevant notes on the PilotStats object</returns>
        public string GetNotesFor(PilotStats pilotStats)
        {
            string notes            = "";
            string CapitalPilotNote = "Capital Pilot";
            string SuperPilotNote   = "Supercap Pilot";

            if (pilotStats.CapitalPilot)
            {
                notes = CapitalPilotNote;
                if (pilotStats.SuperPilot)
                {
                    notes = SuperPilotNote;
                }
            }

            return(notes);
        }
Beispiel #4
0
        /// <summary>
        /// Get stats for a pilot
        /// </summary>
        /// <param name="pilotId">A long integer matching a pilot in CCP's database</param>
        /// <returns></returns>
        public async Task <PilotStats> GetPilotStats(long pilotId)
        {
            Task <bool> superPilotTask = HasKillsWith(pilotId, Supercarrier, Titan);
            Task <bool> capPilotTask   = HasKillsWith(pilotId, Carrier, Dreadnought, ForceAuxiliary);
            JObject     json           = await GetStatsJson(pilotId);

            PilotStats stats = new PilotStats
            {
                PilotId       = pilotId,
                DangerPercent = GetDangerPercent(json),
                SoloPercent   = GetSoloPercent(json),
                CapitalPilot  = await capPilotTask,
                SuperPilot    = await superPilotTask
            };

            return(stats);
        }
Beispiel #5
0
        /// <summary>
        /// Add a row to the cache
        /// </summary>
        /// <param name="pilot">Pilot object containing Id and Name</param>
        /// <param name="affiliation">Affiliation object containing Corporation and Alliance</param>
        /// <param name="stats">PilotStats object containing DangerPercent, SoloPercent, and Notes</param>
        public void Add(PilotId pilot, Affiliation affiliation, PilotStats stats)
        {
            Row row = new Row
            {
                Pilot_Name     = pilot.Name,
                Pilot_Id       = pilot.Id,
                Corp_Name      = affiliation.Corporation,
                Alliance_Name  = affiliation.Alliance,
                Danger_Percent = stats.DangerPercent,
                Solo_Percent   = stats.SoloPercent,
                Notes          = stats.Notes
            };

            if (!Contains(row.Pilot_Name))
            {
                cache.Add(row);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Overall pilot lookup algorithm run whenever a paste is detected
        /// </summary>
        /// <param name="names">A list of names</param>
        private async Task StartLookup(List <string> names)
        {
            try
            {
                SetStatus(Status.PilotLookup);
                List <Row> cachedRows = lookup.FromCache(ref names);
                UpdateUI(cachedRows);

                if (names.Count > 0)
                {
                    List <PilotId> pilots = await lookup.GetIds(names);

                    UpdateUI(pilots);

                    SetStatus(Status.GroupLookup);
                    List <Affiliation> affiliations = await lookup.GetAffiliations(pilots);

                    UpdateUI(affiliations);

                    SetStatus(Status.StatsLookup);
                    foreach (PilotId id in pilots)
                    {
                        Affiliation affiliation = affiliations.Find(x => x.Character_Id == id.Id);
                        PilotStats  stats       = await lookup.FindStatsFor(affiliation); // affiliation already has pilot id

                        UpdateUI(stats);
                        RefreshSorting();
                    }
                }

                SetStatus(Status.Ready);
                running = false;
            }
            catch (HttpRequestException hre)
            {
                Console.WriteLine(hre.Message);
                statusLabel.Text = hre.Message;
            }
        }