Beispiel #1
0
        public ActionStatus Check(ActionStatus actionStatus, int changeEvery)
        {
            var elapsedTime = _elapsedService.GetElapsedTime(actionStatus.LastAction);

            // Calculate how many changes in mood have happened since last petting time
            var seconds = (int)elapsedTime.TotalSeconds;

            // divide the seconds by the change every to get the number of changes
            var changes = seconds / changeEvery;

            // Get int value for the enum of lastchecked status
            var lastStatus           = (int)actionStatus.SatisfactionLevel;
            var minSatisfactionLevel = (int)Utils.MinEnumValue <SatisfactionLevel>();

            // Caluculate the status
            if (changes != 0)
            {
                lastStatus -= changes;

                if (lastStatus < minSatisfactionLevel)
                {
                    lastStatus = minSatisfactionLevel;
                }

                actionStatus.SatisfactionLevel = (SatisfactionLevel)lastStatus;
                actionStatus.LastAction        = _timeService.GetCurrentTime();
            }

            actionStatus.LastChecked = _timeService.GetCurrentTime();

            return(actionStatus);
        }
Beispiel #2
0
 public Models.Dragon Age(Models.Dragon tamagotchi)
 {
     return(tamagotchi with
     {
         Age = (int)_elapsedService.GetElapsedTime(tamagotchi.Hatched).TotalSeconds,
         LifeStage = Update(tamagotchi.Age, tamagotchi.AgeingOptions)
     });
 }