Beispiel #1
0
 private Task increaseHunger()
 {
     //NOTE: [Developer, Architech] this works with an in memory repo and models the concept of an always online server
     //however - logic would have to be in place to save transition values on this event being triggered
     //values also can be acalculated back from the LastFeed value -> this has been included mainly to support this note.
     //the approach below satisfies the brief and is fine for a demo, but in production we would need to modify this approach.
     Hunger = Hunger + (AnimalDataUtilities.FeedConfig()[Type] / 2);
     return(Task.CompletedTask);
 }
Beispiel #2
0
        private void Hungry()
        {
            var minuete  = 60000;
            var interval = (AnimalDataUtilities.HappinessConfig()[Type] * minuete);
            var timer    = new Timer(interval)
            {
                AutoReset = true
            };

            timer.Elapsed += async(sender, e) => await increaseHunger();

            timer.Start();
        }