Beispiel #1
0
        /// <summary>
        /// Creates a new copy with the same values
        /// </summary>
        /// <returns></returns>
        public StatsCollection Clone()
        {
            var clone = new StatsCollection(_startingValue);

            foreach (Stat s in Keys.ToArray())
            {
                clone[s] = this[s];
            }

            return(clone);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the stats of the <paramref name="other"/> to this (changes permanently
        /// this class)
        /// </summary>
        /// <param name="other"></param>
        public StatsCollection Increase(StatsCollection other)
        {
            foreach (Stat s in Keys.ToArray().Union(other.Keys.ToArray()))
            {
                this[s] += other[s];
            }

            this._startingValue += other._startingValue;

            return(this);
        }
Beispiel #3
0
        /// <summary>
        /// Multiply each stat by the given <paramref name="ratios"/>.
        /// </summary>
        /// <param name="ratios"></param>   /// <param name="invertForNegatives">true to invert the ratio for negative stats e.g. ratio of 0.5 would make 10 become 5
        /// but -10 would become -20 (instead of -5).)</param>
        /// <returns></returns>
        public StatsCollection Multiply(StatsCollection ratios, bool invertForNegatives)
        {
            foreach (var s in Keys.ToArray().Union(ratios.Keys))
            {
                if (invertForNegatives && this[s] < 0)
                {
                    this[s] *= 1 / ratios[s];
                }
                else
                {
                    this[s] *= ratios[s];
                }
            }

            return(this);
        }