Inheritance: Caliburn.Micro.PropertyChangedBase, IHaveDisplayName
コード例 #1
0
 private void RestartSession(ExperienceData experienceData)
 {
     experienceData.GainedExperience = 0;
     experienceData.StartTime        = DateTime.Now;
     experienceData.TimeToLevel      = Constants.INFINITY;
     NotifyOfPropertyChange(() => experienceData.ExperiencePerHour);
 }
コード例 #2
0
 private void RestartSession(ExperienceData experienceData)
 {
     experienceData.GainedExperience = 0;
     experienceData.StartTime = DateTime.Now;
     experienceData.TimeToLevel = Constants.INFINITY;
     NotifyOfPropertyChange(() => experienceData.ExperiencePerHour);
 }
        public void WriteToFile(ExperienceData experienceData)
        {
            if(!isExperienceDataToTextServiceEnabled)
            {
                return;
            }

            var prefix = experienceData.DisplayName.Replace(" ", string.Empty).ToLower();
            WriteToFile($"{prefix}_currentBaseExperience.txt", experienceData.CurrentExperience.ToString("N0"));
            WriteToFile($"{prefix}_requiredBaseExperience.txt", experienceData.RequiredExperience.ToString("N0"));
            WriteToFile($"{prefix}_killsTilNextLevel.txt", experienceData.KillsTilNextLevel.ToString("N0"));
            WriteToFile($"{prefix}_currentBaseExperiencePercent.txt", experienceData.CurrentExperiencePercent.ToString("F2") + "%");
            WriteToFile($"{prefix}_lastExperienceGain.txt", experienceData.LastExperienceGain.ToString("N0"));
            WriteToFile($"{prefix}_timeToLevel.txt", experienceData.TimeToLevel);
            WriteToFile($"{prefix}_experiencePerHour.txt", experienceData.ExperiencePerHour.ToString("N0"));
        }
        public void UpdateExperienceValues(ExperienceData experienceData, int currentExperience, int requiredExperience)
        {
            var newCurrentBaseExperience = currentExperience;
            var requiredBasedExp = requiredExperience;

            if (newCurrentBaseExperience == int.MinValue || requiredBasedExp == int.MinValue ||
                requiredBasedExp == 15) // for some reason required base exp returns as 15 when char not selected, no idea why
            {
                experienceData.Reset();
                return;
            }

            experienceData.RequiredExperience = requiredBasedExp;

            if (experienceData.FirstUpdate)
            {
                experienceData.PreviousRequiredExperience = requiredBasedExp;
                experienceData.CurrentExperience = newCurrentBaseExperience;
                experienceData.FirstUpdate = false;
            }
            else if (newCurrentBaseExperience != experienceData.CurrentExperience) // exp hasn't changed, nothing else to do
            {
                if (experienceData.RequiredExperience > experienceData.PreviousRequiredExperience) // handle level up scenarios
                {
                    experienceData.LastExperienceGain = (experienceData.PreviousRequiredExperience - experienceData.CurrentExperience) + newCurrentBaseExperience;
                    experienceData.PreviousRequiredExperience = requiredBasedExp;
                }
                else
                {
                    experienceData.LastExperienceGain = newCurrentBaseExperience - experienceData.CurrentExperience;
                }

                experienceData.CurrentExperience = newCurrentBaseExperience;
                experienceData.GainedExperience += experienceData.LastExperienceGain;
            }

            experienceData.ExperiencePerHour = (int)(experienceData.GainedExperience * (TimeSpan.FromHours(1).TotalMilliseconds / experienceData.ElapsedTime.TotalMilliseconds));

            experienceData.TimeToLevel = CalculateTimeToLevel(experienceData);
            // make sure the elapsed time is kept updated every tick, must be called from experience data class
            experienceData.NotifyOfPropertyChange(() => experienceData.ElapsedTime);

            experienceDataToTextService.WriteToFile(experienceData);
        }
コード例 #5
0
        public ExperienceContainer(ExperienceData baseExperienceData, ExperienceData classExperienceData, IEnumerable<IExperienceControl> experienceControls)
        {
            if (baseExperienceData == null)
            {
                throw new ArgumentNullException(nameof(baseExperienceData));
            }
            if (classExperienceData == null)
            {
                throw new ArgumentNullException(nameof(classExperienceData));
            }
            if (experienceControls == null)
            {
                throw new ArgumentNullException(nameof(experienceControls));
            }

            BaseExperienceData = baseExperienceData;
            ClassExperienceData = classExperienceData;
            ExperienceControls = new BindableCollection<IExperienceControl>(experienceControls);
        }
        private string CalculateTimeToLevel(ExperienceData experienceData)
        {
            if (experienceData.LastExperienceGain == 0)
            {
                return Constants.INFINITY;
            }

            var totalExperienceRequired = experienceData.RequiredExperience - experienceData.CurrentExperience;
            var experiencePerSecond = experienceData.GainedExperience / experienceData.ElapsedTime.TotalSeconds;

            if (experiencePerSecond == 0 || double.IsNaN(experiencePerSecond))
            {
                return Constants.INFINITY;
            }

            var estimatedTimeToLevel = TimeSpan.FromSeconds(totalExperienceRequired / experiencePerSecond);

            return estimatedTimeToLevel.ToShortDisplayFormat();
        }
コード例 #7
0
        public ExperienceContainer(ExperienceData baseExperienceData, ExperienceData classExperienceData, IEnumerable <IExperienceControl> experienceControls)
        {
            if (baseExperienceData == null)
            {
                throw new ArgumentNullException(nameof(baseExperienceData));
            }
            if (classExperienceData == null)
            {
                throw new ArgumentNullException(nameof(classExperienceData));
            }
            if (experienceControls == null)
            {
                throw new ArgumentNullException(nameof(experienceControls));
            }

            BaseExperienceData  = baseExperienceData;
            ClassExperienceData = classExperienceData;
            ExperienceControls  = new BindableCollection <IExperienceControl>(experienceControls);
        }
コード例 #8
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton<IWindowManager, MetroWindowManager>();
            container.Singleton<IEventAggregator, EventAggregator>();

            var baseExperienceData = new ExperienceData() { DisplayName = "Base Experience" };
            var classExperienceData = new ExperienceData() { DisplayName = "Class Experience" };
            IExperienceControl[] baseExperienceControls = GetExperienceControls(baseExperienceData, classExperienceData);

            ExperienceContainer experienceContainer = new ExperienceContainer(baseExperienceData, classExperienceData, baseExperienceControls);

            container.Handler<ShellViewModel>(simpleContainer =>
                                              new ShellViewModel(
                                                  container.GetInstance<SettingsViewModel>(),
                                                  experienceContainer,
                                                  new ExpCardCalculatorViewModel(experienceContainer),
                                                  container.GetInstance<IWindowManager>()));

            // TODO - refactor settings view model to just take a collection of menuitems
            container.Handler<SettingsViewModel>(simpleContainer => new SettingsViewModel(baseExperienceControls));
        }
コード例 #9
0
        private IExperienceControl[] GetExperienceControls(ExperienceData baseExperienceData, ExperienceData classExperienceData)
        {
            IExperienceControl[] experienceControls = new IExperienceControl[]
            {
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideCurrentBaseExperience,
                    baseExperienceData,
                    baseData => baseData.CurrentExperience,
                    baseData => baseData.CurrentExperience.ToString("N0"),
                    classExperienceData)
                {
                    DisplayName = "Current Exp",
                    HideComponentText = "Hide Current Experience"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideRequiredBaseExperience,
                    baseExperienceData,
                    baseData => baseData.RequiredExperience,
                    baseData => baseData.RequiredExperience.ToString("N0"),
                    classExperienceData)
                {
                    DisplayName = "Required Exp",
                    HideComponentText = "Hide Required Exp"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideCurrentBaseExperencePercent,
                    baseExperienceData,
                    baseData => baseData.CurrentExperiencePercent,
                    baseData => baseData.CurrentExperiencePercent.ToString("N4"),
                    classExperienceData)
                {
                    DisplayName = "Current Exp %",
                    HideComponentText = "Hide Current Experience %"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideLastExperienceGain,
                    baseExperienceData,
                    baseData => baseData.LastExperienceGain,
                    baseData => baseData.LastExperienceGain.ToString("N0"),
                    classExperienceData)
                {
                    DisplayName = "Last Exp",
                    HideComponentText = "Hide Last Exp Gain"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideLastExperienceGainPercent,
                    baseExperienceData,
                    baseData => baseData.LastExperienceGainPercent,
                    baseData => baseData.LastExperienceGainPercent.ToString("N4"),
                    classExperienceData)
                {
                    DisplayName = "Last Exp %",
                    HideComponentText = "Hide Last Exp Gain %"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideKillsTilNextLevel,
                    baseExperienceData,
                    baseData => baseData.KillsTilNextLevel,
                    baseData => baseData.KillsTilNextLevel.ToString("N0"),
                    classExperienceData)
                {
                    DisplayName = "Kills TNL",
                    HideComponentText = "Hide Kills TNL"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideExperiencePerHour,
                    baseExperienceData,
                    baseData => baseData.ExperiencePerHour,
                    baseData => baseData.ExperiencePerHour.ToString("N0"),
                    classExperienceData)
                {
                    DisplayName = "Exp/Hr",
                    HideComponentText = "Hide Exp/Hr"
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideTimeToLevel,
                    baseExperienceData,
                    baseData => baseData.TimeToLevel,
                    baseData => baseData.TimeToLevel,
                    classExperienceData)
                {
                    DisplayName = "Time TNL",
                    HideComponentText = "Hide Time TNL",
                },
                new ExperienceControl<ExperienceData>(
                    settings => settings.HideSessionTime,
                    baseExperienceData,
                    data => data.ElapsedTime,
                    data => data.ElapsedTime.ToShortDisplayFormat())
                {
                    DisplayName = "Session",
                    HideComponentText = "Hide Session Time",
                    CanShowClassValue = false
                },
            };

            foreach (var experienceControl in experienceControls)
            {
                experienceControl.ShowClassValue = Settings.Default.ShowClassExperienceRow;
            }

            return experienceControls;
        }