/// <summary>
 /// Calculate the total of all unexpired entries.
 /// </summary>
 private void CalculateTotalStatistics()
 {
     totalStatistics = new StatisticsValue();
     foreach (StatisticsValueStackEntry entry in entries)
     {
         totalStatistics += entry.Statistics;
     }
 }
示例#2
0
 /// <summary>
 /// Clamp all values piecewise with the provided maximum values.
 /// </summary>
 public void ApplyMaximum(StatisticsValue maximumValue)
 {
     HealthPoints    = Math.Min(HealthPoints, maximumValue.HealthPoints);
     MagicPoints     = Math.Min(MagicPoints, maximumValue.MagicPoints);
     PhysicalOffense = Math.Min(PhysicalOffense, maximumValue.PhysicalOffense);
     PhysicalDefense = Math.Min(PhysicalDefense, maximumValue.PhysicalDefense);
     MagicalOffense  = Math.Min(MagicalOffense, maximumValue.MagicalOffense);
     MagicalDefense  = Math.Min(MagicalDefense, maximumValue.MagicalDefense);
 }
        /// <summary>
        /// Recalculate the character's equipment-buff statistics.
        /// </summary>
        public void RecalculateEquipmentStatistics()
        {
            // start from scratch
            equipmentBuffStatistics = new StatisticsValue();

            // add the statistics for each piece of equipped equipment
            foreach (Equipment equipment in equippedEquipment)
            {
                equipmentBuffStatistics += equipment.OwnerBuffStatistics;
            }
        }
 /// <summary>
 /// Reset the character's base statistics.
 /// </summary>
 public void ResetBaseStatistics()
 {
     if (characterClass == null)
     {
         baseStatistics = new StatisticsValue();
     }
     else
     {
         baseStatistics = characterClass.GetStatisticsForLevel(characterLevel);
     }
 }
示例#5
0
        /// <summary>
        /// Calculate the statistics of a character of this class and the given level.
        /// </summary>
        public StatisticsValue GetStatisticsForLevel(int characterLevel)
        {
            // check the parameter
            if (characterLevel <= 0)
            {
                throw new ArgumentOutOfRangeException("characterLevel");
            }

            // start with the initial statistics
            StatisticsValue output = initialStatistics;

            // add each level of leveling statistics
            for (int i = 1; i < characterLevel; i++)
            {
                if ((levelingStatistics.LevelsPerHealthPointsIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerHealthPointsIncrease) == 0))
                {
                    output.HealthPoints += levelingStatistics.HealthPointsIncrease;
                }
                if ((levelingStatistics.LevelsPerMagicPointsIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerMagicPointsIncrease) == 0))
                {
                    output.MagicPoints += levelingStatistics.MagicPointsIncrease;
                }
                if ((levelingStatistics.LevelsPerPhysicalOffenseIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerPhysicalOffenseIncrease) == 0))
                {
                    output.PhysicalOffense += levelingStatistics.PhysicalOffenseIncrease;
                }
                if ((levelingStatistics.LevelsPerPhysicalDefenseIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerPhysicalDefenseIncrease) == 0))
                {
                    output.PhysicalDefense += levelingStatistics.PhysicalDefenseIncrease;
                }
                if ((levelingStatistics.LevelsPerMagicalOffenseIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerMagicalOffenseIncrease) == 0))
                {
                    output.MagicalOffense += levelingStatistics.MagicalOffenseIncrease;
                }
                if ((levelingStatistics.LevelsPerMagicalDefenseIncrease > 0) &&
                    ((i % levelingStatistics.LevelsPerMagicalDefenseIncrease) == 0))
                {
                    output.MagicalDefense += levelingStatistics.MagicalDefenseIncrease;
                }
            }

            return(output);
        }
        /// <summary>
        /// Add a new statistics, with a given duration, to the stack.
        /// </summary>
        /// <remarks>Entries with durations of 0 or less never expire.</remarks>
        public void AddStatistics(StatisticsValue statistics, int duration)
        {
            if (duration < 0)
            {
                throw new ArgumentOutOfRangeException("duration");
            }

            StatisticsValueStackEntry entry = new StatisticsValueStackEntry();

            entry.Statistics        = statistics;
            entry.RemainingDuration = duration;

            entries.Add(entry);

            CalculateTotalStatistics();
        }
示例#7
0
        /// <summary>
        /// Add one value to another, piecewise, and return the result.
        /// </summary>
        public static StatisticsValue Add(StatisticsValue value1,
                                          StatisticsValue value2)
        {
            StatisticsValue outputValue = new StatisticsValue();

            outputValue.HealthPoints =
                value1.HealthPoints + value2.HealthPoints;
            outputValue.MagicPoints =
                value1.MagicPoints + value2.MagicPoints;
            outputValue.PhysicalOffense =
                value1.PhysicalOffense + value2.PhysicalOffense;
            outputValue.PhysicalDefense =
                value1.PhysicalDefense + value2.PhysicalDefense;
            outputValue.MagicalOffense =
                value1.MagicalOffense + value2.MagicalOffense;
            outputValue.MagicalDefense =
                value1.MagicalDefense + value2.MagicalDefense;
            return(outputValue);
        }
示例#8
0
        /// <summary>
        /// Add one value to another, piecewise, and return the result.
        /// </summary>
        public static StatisticsRange Add(StatisticsRange value1,
                                          StatisticsValue value2)
        {
            StatisticsRange outputRange = new StatisticsRange();

            outputRange.HealthPointsRange =
                value1.HealthPointsRange + value2.HealthPoints;
            outputRange.MagicPointsRange =
                value1.MagicPointsRange + value2.MagicPoints;
            outputRange.PhysicalOffenseRange =
                value1.PhysicalOffenseRange + value2.PhysicalOffense;
            outputRange.PhysicalDefenseRange =
                value1.PhysicalDefenseRange + value2.PhysicalDefense;
            outputRange.MagicalOffenseRange =
                value1.MagicalOffenseRange + value2.MagicalOffense;
            outputRange.MagicalDefenseRange =
                value1.MagicalDefenseRange + value2.MagicalDefense;
            return(outputRange);
        }
示例#9
0
        /// <summary>
        /// Generate a random value between the minimum and maximum, inclusively.
        /// </summary>
        /// <param name="random">The Random object used to generate the value.</param>
        public StatisticsValue GenerateValue(Random random)
        {
            // check the parameters
            Random usedRandom = random;

            if (usedRandom == null)
            {
                usedRandom = new Random();
            }

            // generate the new value
            StatisticsValue outputValue = new StatisticsValue();

            outputValue.HealthPoints    = HealthPointsRange.GenerateValue(usedRandom);
            outputValue.MagicPoints     = MagicPointsRange.GenerateValue(usedRandom);
            outputValue.PhysicalOffense = PhysicalOffenseRange.GenerateValue(usedRandom);
            outputValue.PhysicalDefense = PhysicalDefenseRange.GenerateValue(usedRandom);
            outputValue.MagicalOffense  = MagicalOffenseRange.GenerateValue(usedRandom);
            outputValue.MagicalDefense  = MagicalDefenseRange.GenerateValue(usedRandom);

            return(outputValue);
        }