Exemplo n.º 1
0
        private Task decreaseHappiness()
        {
            //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 LastPetted 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.

            Happiness = Happiness - (AnimalDataUtilities.HappinessConfig()[Type] / 2);
            return(Task.CompletedTask);
        }
Exemplo n.º 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();
        }