Ejemplo n.º 1
0
        /// <summary>
        /// Add pressure to a need, can also be negative, wont go below zero
        /// </summary>
        /// <param name="need">the need to apply pressure to</param>
        /// <param name="amount">how much pressure</param>
        /// <returns>the highest current need after application</returns>
        public Motivator ApplyPressure(Motivator need, int amount)
        {
            Tuple <Motivator, int> currentNeed = Needs.FirstOrDefault(nd => nd.Item1 == need);

            if (currentNeed != null)
            {
                amount += currentNeed.Item2;
                Needs.Remove(currentNeed);
            }

            Needs.Add(new Tuple <Motivator, int>(need, Math.Max(0, amount)));

            return(Needs.OrderByDescending(nd => nd.Item2).FirstOrDefault().Item1);
        }