Пример #1
0
        /// <summary>
        /// Imports data from the given skills information.
        /// </summary>
        /// <param name="skills">The serialized character skill information</param>
        internal void Import(EsiAPISkills skills, EsiAPISkillQueue queue)
        {
            var      newSkills   = new LinkedList <SerializableCharacterSkill>();
            DateTime uselessDate = DateTime.UtcNow;

            FreeSkillPoints = skills.UnallocatedSP;

            // Keep track of the current skill queue's completed skills, as ESI does not
            // transfer them to the skills list until you login
            var dict = new Dictionary <long, SerializableQueuedSkill>();

            if (queue != null)
            {
                foreach (var queuedSkill in queue.CreateSkillQueue())
                {
                    // If the skill is completed or currently training, we need it later to
                    // copy the progress over to the imported skills
                    if (queuedSkill.IsCompleted || queuedSkill.IsTraining)
                    {
                        if (!dict.ContainsKey(queuedSkill.ID))
                        {
                            dict.Add(queuedSkill.ID, queuedSkill);
                        }
                        else
                        {
                            dict[queuedSkill.ID] = queuedSkill;
                        }
                    }
                }
            }
            // Convert skills to EVE format
            foreach (var skill in skills.Skills)
            {
                // Check if the skill is in the queue, and completed at a higher level or has
                // higher current SP
                if (dict.ContainsKey(skill.ID))
                {
                    var queuedSkill = dict[skill.ID];
                    if (queuedSkill.IsCompleted)
                    {
                        // Queued skill is completed, so make sure the imported skill is
                        // updated
                        skill.ActiveLevel = Math.Max(skill.ActiveLevel, queuedSkill.Level);
                        skill.Level       = Math.Max(skill.Level, queuedSkill.Level);
                        skill.Skillpoints = Math.Max(skill.Skillpoints, queuedSkill.EndSP);
                    }
                    else if (queuedSkill.IsTraining)
                    {
                        // Queued skill is currently training - use QueuedSkill class to
                        // calculate the CurrentSP of the skill
                        var tempSkill = new QueuedSkill(this, queuedSkill, ref uselessDate);
                        skill.Skillpoints = Math.Max(skill.Skillpoints, tempSkill.CurrentSP);
                    }
                }
                newSkills.AddLast(skill.ToXMLItem());
            }
            Skills.Import(newSkills, true);

            UpdateMasteries();
        }
Пример #2
0
        /// <summary>
        /// Processes the queried character's skill queue information.
        /// </summary>
        /// <param name="result"></param>
        private void OnSkillQueueUpdated(EsiAPISkillQueue result)
        {
            var target = m_ccpCharacter;

            // Character may have been deleted since we queried
            if (target != null)
            {
                m_lastQueue = result;
                target.SkillQueue.Import(result.CreateSkillQueue());
                // Check if the character has less than the threshold queue length
                if (target.IsTraining && target.SkillQueue.LessThanWarningThreshold)
                {
                    EveMonClient.Notifications.NotifySkillQueueThreshold(target,
                                                                         Settings.UI.MainWindow.SkillQueueWarningThresholdDays);
                }
                else
                {
                    EveMonClient.Notifications.InvalidateSkillQueueThreshold(target);
                }
            }
            else
            {
                m_lastQueue = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Imports data from the given skills information.
        /// </summary>
        /// <param name="skills">The serialized character skill information</param>
        internal void Import(EsiAPISkills skills, EsiAPISkillQueue queue)
        {
            var newSkills = new LinkedList <SerializableCharacterSkill>();

            FreeSkillPoints = skills.UnallocatedSP;

            // Keep track of the current skill queue's completed skills, as ESI doesn't transfer them to the skills list until you login
            Dictionary <long, QueuedSkill> dict = new Dictionary <long, QueuedSkill>();

            if (queue != null && IsTraining)
            {
                DateTime uselessDate = DateTime.UtcNow;

                foreach (var serialSkill in queue.ToXMLItem().Queue)
                {
                    var queuedSkill = new QueuedSkill(this, serialSkill, ref uselessDate);
                    if (!dict.ContainsKey(queuedSkill.Skill.ID))
                    {
                        dict.Add(queuedSkill.Skill.ID, queuedSkill);
                    }
                    else if (queuedSkill.Level > dict[queuedSkill.Skill.ID].Level)
                    {
                        dict[queuedSkill.Skill.ID] = queuedSkill;
                    }
                }
            }
            // Convert skills to EVE format
            foreach (var skill in skills.Skills)
            {
                // Check if the skill is in the queue, and completed at a higher level or has higher current SP
                if (dict.ContainsKey(skill.ID))
                {
                    var queuedSkill = dict[skill.ID];

                    if (queuedSkill.IsCompleted)
                    {
                        skill.ActiveLevel = Math.Max(skill.ActiveLevel, queuedSkill.Level);
                        skill.Level       = Math.Max(skill.Level, queuedSkill.Level);
                        skill.Skillpoints = Math.Max(skill.Skillpoints, queuedSkill.EndSP);
                    }
                    else
                    {
                        skill.Skillpoints = Math.Max(skill.Skillpoints, queuedSkill.CurrentSP);
                    }
                }

                newSkills.AddLast(skill.ToXMLItem());
            }

            Skills.Import(newSkills, true);
        }
Пример #4
0
        /// <summary>
        /// Processes the queried character's skill queue information.
        /// </summary>
        /// <param name="result"></param>
        private void OnSkillQueueUpdated(EsiAPISkillQueue result)
        {
            var target = m_ccpCharacter;

            // Character may have been deleted since we queried
            if (target != null)
            {
                target.SkillQueue.Import(result.ToXMLItem().Queue);
                // Check the character has less than a day of training in skill queue
                if (target.IsTraining && target.SkillQueue.LessThanWarningThreshold)
                {
                    EveMonClient.Notifications.NotifySkillQueueLessThanADay(target);
                }
                else
                {
                    EveMonClient.Notifications.InvalidateSkillQueueLessThanADay(target);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CharacterDataQuerying"/> class.
        /// </summary>
        /// <param name="ccpCharacter">The CCP character.</param>
        internal CharacterDataQuerying(CCPCharacter ccpCharacter)
        {
            var notifiers = EveMonClient.Notifications;

            m_ccpCharacter           = ccpCharacter;
            m_characterQueryMonitors = new List <IQueryMonitorEx>();
            m_attrResponse           = null;
            m_lastQueue = null;

            // Add the monitors in an order as they will appear in the throbber menu
            m_charSheetMonitor = new CharacterQueryMonitor <EsiAPICharacterSheet>(ccpCharacter,
                                                                                  ESIAPICharacterMethods.CharacterSheet, OnCharacterSheetUpdated,
                                                                                  notifiers.NotifyCharacterSheetError);
            m_characterQueryMonitors.Add(m_charSheetMonitor);
            // Location
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPILocation>(
                                             ccpCharacter, ESIAPICharacterMethods.Location, OnCharacterLocationUpdated,
                                             notifiers.NotifyCharacterLocationError));
            // Clones
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIClones>(
                                             ccpCharacter, ESIAPICharacterMethods.Clones, OnCharacterClonesUpdated,
                                             notifiers.NotifyCharacterClonesError));
            // Implants
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <List <int> >(
                                             ccpCharacter, ESIAPICharacterMethods.Implants, OnCharacterImplantsUpdated,
                                             OnCharacterImplantsFailed));
            // Ship
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIShip>(
                                             ccpCharacter, ESIAPICharacterMethods.Ship, OnCharacterShipUpdated,
                                             notifiers.NotifyCharacterShipError));
            // Skills
            m_charSkillsMonitor = new CharacterQueryMonitor <EsiAPISkills>(
                ccpCharacter, ESIAPICharacterMethods.Skills, OnCharacterSkillsUpdated,
                notifiers.NotifyCharacterSkillsError);
            m_characterQueryMonitors.Add(m_charSkillsMonitor);
            // Skill queue
            m_charSkillQueueMonitor = new CharacterQueryMonitor <EsiAPISkillQueue>(
                ccpCharacter, ESIAPICharacterMethods.SkillQueue, OnSkillQueueUpdated,
                notifiers.NotifySkillQueueError);
            m_characterQueryMonitors.Add(m_charSkillQueueMonitor);
            // Employment history
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIEmploymentHistory>(
                                             ccpCharacter, ESIAPICharacterMethods.EmploymentHistory,
                                             OnCharacterEmploymentUpdated, notifiers.NotifyCharacterEmploymentError));
            // Standings
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIStandings,
                                                                EsiStandingsListItem>(new CharacterQueryMonitor <EsiAPIStandings>(
                                                                                          ccpCharacter, ESIAPICharacterMethods.Standings, OnStandingsUpdated,
                                                                                          notifiers.NotifyCharacterStandingsError)
            {
                QueryOnStartup = true
            }));
            // Contacts
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIContactsList,
                                                                EsiContactListItem>(new CharacterQueryMonitor <EsiAPIContactsList>(ccpCharacter,
                                                                                                                                   ESIAPICharacterMethods.ContactList, OnContactsUpdated,
                                                                                                                                   notifiers.NotifyCharacterContactsError)
            {
                QueryOnStartup = true
            }));
            // Factional warfare
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIFactionalWarfareStats>(
                                             ccpCharacter, ESIAPICharacterMethods.FactionalWarfareStats,
                                             OnFactionalWarfareStatsUpdated, notifiers.
                                             NotifyCharacterFactionalWarfareStatsError)
            {
                QueryOnStartup = true
            });
            // Medals
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIMedals,
                                                                EsiMedalsListItem>(new CharacterQueryMonitor <EsiAPIMedals>(ccpCharacter,
                                                                                                                            ESIAPICharacterMethods.Medals, OnMedalsUpdated,
                                                                                                                            notifiers.NotifyCharacterMedalsError)
            {
                QueryOnStartup = true
            }));
            // Kill log
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIKillLog,
                                                                EsiKillLogListItem>(new CharacterQueryMonitor <EsiAPIKillLog>(ccpCharacter,
                                                                                                                              ESIAPICharacterMethods.KillLog, OnKillLogUpdated,
                                                                                                                              notifiers.NotifyCharacterKillLogError)
            {
                QueryOnStartup = true
            }));
            // Assets
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIAssetList,
                                                                EsiAssetListItem>(new CharacterQueryMonitor <EsiAPIAssetList>(ccpCharacter,
                                                                                                                              ESIAPICharacterMethods.AssetList, OnAssetsUpdated,
                                                                                                                              notifiers.NotifyCharacterAssetsError)
            {
                QueryOnStartup = true
            }));
            // Market orders
            m_charMarketOrdersMonitor = new CharacterQueryMonitor <EsiAPIMarketOrders>(
                ccpCharacter, ESIAPICharacterMethods.MarketOrders, OnMarketOrdersUpdated,
                notifiers.NotifyCharacterMarketOrdersError)
            {
                QueryOnStartup = true
            };
            m_characterQueryMonitors.Add(m_charMarketOrdersMonitor);
            // Contracts
            m_charContractsMonitor = new PagedQueryMonitor <EsiAPIContracts,
                                                            EsiContractListItem>(new CharacterQueryMonitor <EsiAPIContracts>(ccpCharacter,
                                                                                                                             ESIAPICharacterMethods.Contracts, OnContractsUpdated,
                                                                                                                             notifiers.NotifyCharacterContractsError)
            {
                QueryOnStartup = true
            });
            m_characterQueryMonitors.Add(m_charContractsMonitor);
            // Wallet journal
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIWalletJournal,
                                                                EsiWalletJournalListItem>(new CharacterQueryMonitor <EsiAPIWalletJournal>(
                                                                                              ccpCharacter, ESIAPICharacterMethods.WalletJournal, OnWalletJournalUpdated,
                                                                                              notifiers.NotifyCharacterWalletJournalError)
            {
                QueryOnStartup = true
            }));
            // Wallet balance
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <string>(
                                             ccpCharacter, ESIAPICharacterMethods.AccountBalance, OnWalletBalanceUpdated,
                                             notifiers.NotifyCharacterBalanceError));
            // Wallet transactions
            m_characterQueryMonitors.Add(new PagedQueryMonitor <EsiAPIWalletTransactions,
                                                                EsiWalletTransactionsListItem>(new CharacterQueryMonitor <
                                                                                                   EsiAPIWalletTransactions>(ccpCharacter, ESIAPICharacterMethods.
                                                                                                                             WalletTransactions, OnWalletTransactionsUpdated, notifiers.
                                                                                                                             NotifyCharacterWalletTransactionsError)
            {
                QueryOnStartup = true
            }));
            // Industry
            m_charIndustryJobsMonitor = new CharacterQueryMonitor <EsiAPIIndustryJobs>(
                ccpCharacter, ESIAPICharacterMethods.IndustryJobs, OnIndustryJobsUpdated,
                notifiers.NotifyCharacterIndustryJobsError)
            {
                QueryOnStartup = true
            };
            m_characterQueryMonitors.Add(m_charIndustryJobsMonitor);
            // Research points
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIResearchPoints>(
                                             ccpCharacter, ESIAPICharacterMethods.ResearchPoints, OnResearchPointsUpdated,
                                             notifiers.NotifyCharacterResearchPointsError)
            {
                QueryOnStartup = true
            });
            // Mail
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIMailMessages>(
                                             ccpCharacter, ESIAPICharacterMethods.MailMessages, OnEVEMailMessagesUpdated,
                                             notifiers.NotifyEVEMailMessagesError)
            {
                QueryOnStartup = true
            });
            // Mailing lists
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIMailingLists>(
                                             ccpCharacter, ESIAPICharacterMethods.MailingLists, OnEveMailingListsUpdated,
                                             notifiers.NotifyMailingListsError));
            // Notifications
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPINotifications>(
                                             ccpCharacter, ESIAPICharacterMethods.Notifications, OnEVENotificationsUpdated,
                                             notifiers.NotifyEVENotificationsError)
            {
                QueryOnStartup = true
            });
            // Calendar
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPICalendarEvents>(
                                             ccpCharacter, ESIAPICharacterMethods.UpcomingCalendarEvents,
                                             OnUpcomingCalendarEventsUpdated, notifiers.
                                             NotifyCharacterUpcomingCalendarEventsError)
            {
                QueryOnStartup = true
            });
            // PI
            m_characterQueryMonitors.Add(new CharacterQueryMonitor <EsiAPIPlanetaryColoniesList>(
                                             ccpCharacter, ESIAPICharacterMethods.PlanetaryColonies,
                                             OnPlanetaryColoniesUpdated, notifiers.
                                             NotifyCharacterPlanetaryColoniesError)
            {
                QueryOnStartup = true
            });
            m_characterQueryMonitors.ForEach(monitor => ccpCharacter.QueryMonitors.Add(monitor));

            // Enumerate the basic feature monitors into a separate list
            m_basicFeaturesMonitors = new List <IQueryMonitorEx>(m_characterQueryMonitors.Count);
            long basicFeatures = (long)CCPAPIMethodsEnum.BasicCharacterFeatures;

            foreach (var monitor in m_characterQueryMonitors)
            {
                long method = (long)(ESIAPICharacterMethods)monitor.Method;
                if (method == (method & basicFeatures))
                {
                    m_basicFeaturesMonitors.Add(monitor);
                    // If force update is selected, update basic features only
                    if (ccpCharacter.ForceUpdateBasicFeatures)
                    {
                        monitor.ForceUpdate(true);
                    }
                }
            }

            EveMonClient.TimerTick += EveMonClient_TimerTick;
        }