Esempio n. 1
0
        /// <summary>
        /// Tests a random condition with two values. An int overload.
        /// This is commonly used when calculating a total percentage of something happening.
        /// For example, this is used when testing whether a move will inflict a Status Effect on a BattleEntity.
        /// <para>Two values are multiplied by each other then divided by <see cref="GeneralGlobals.RandomConditionVal"/>.
        /// A random value is then rolled; if it's less than the result, it returns true. This works for any non-negative values.</para>
        /// </summary>
        /// <param name="value1">The first value to test with, representing a percentage with a number from 0 to 100+.</param>
        /// <param name="value2">The second value to test with, representing a percentage with a number from 0 to 100+.</param>
        /// <returns>true if the RNG value is less than a calculated percentage result, otherwise false.</returns>
        public static bool TestRandomCondition(int value1, int value2)
        {
            int value = GeneralGlobals.GenerateRandomInt();

            int percentageResult = ((value1 * value2) / GeneralGlobals.RandomConditionVal);

            return(value < percentageResult);
        }
Esempio n. 2
0
        /// <summary>
        /// Tests a random condition with two values.
        /// This is commonly used when calculating a total percentage of something happening.
        /// For example, this is used when testing whether a move will inflict a Status Effect on a BattleEntity.
        /// <para>Two values are multiplied by each other then divided by <see cref="GeneralGlobals.RandomConditionVal"/>.
        /// A random value is then rolled; if it's less than the result, it returns true. This works for any non-negative values.</para>
        /// </summary>
        /// <param name="value1">The first value to test with, representing a percentage with a number from 0 to 100+.</param>
        /// <param name="value2">The second value to test with, representing a percentage with a number from 0 to 100+.</param>
        /// <returns>true if the RNG value is less than a calculated percentage result, otherwise false.</returns>
        public static bool TestRandomCondition(double value1, double value2)
        {
            double value = GeneralGlobals.GenerateRandomDouble();

            double percentageResult = ((value1 * value2) / (double)GeneralGlobals.RandomConditionVal);

            return(value < percentageResult);
        }