Example #1
0
        string GetDieStr(int spellSlotLevel, int spellCasterLevel, int spellcastingAbilityModifier)
        {
            string bonusThreshold = BonusThreshold.ToLower();

            DieRollDetails details = DieRollDetails.From(OriginalDieStr, spellcastingAbilityModifier);

            string dieStr = details.ToString();

            if (string.IsNullOrWhiteSpace(bonusThreshold))
            {
                return(dieStr);
            }

            int compareLevel = spellSlotLevel;

            if (bonusThreshold.StartsWith("c"))
            {
                compareLevel = spellCasterLevel;
            }

            int    minThreshold = bonusThreshold.GetFirstInt();
            double multiplier   = compareLevel - minThreshold;

            string bonusPerLevelStr = BonusPerLevel;

            if (PerLevelBonus == 0)
            {
                return(dieStr);
            }

            int totalBonus = (int)Math.Floor(PerLevelBonus * multiplier);

            if (totalBonus <= 0)
            {
                return(dieStr);
            }

            DieRollDetails bonusDetails = DieRollDetails.From(bonusPerLevelStr, spellcastingAbilityModifier);

            foreach (Roll bonusRoll in bonusDetails.Rolls)
            {
                Roll matchingRoll = details.GetRoll(bonusRoll.Sides);
                if (matchingRoll == null)
                {
                    details.AddRoll(bonusRoll.ToString());
                }
                else if (multiplier != 0)
                {
                    matchingRoll.Count  += (int)Math.Floor(bonusRoll.Count * multiplier);
                    matchingRoll.Offset += (int)Math.Floor(bonusRoll.Offset * multiplier);
                }
            }

            return(details.ToString());
        }
Example #2
0
        private bool GetMultiplier(int spellSlotLevel, int spellCasterLevel, out double multiplier)
        {
            string bonusThreshold = BonusThreshold.ToLower();
            int    compareLevel   = spellSlotLevel;

            if (bonusThreshold.StartsWith("c"))
            {
                compareLevel = spellCasterLevel;
            }

            int minThreshold = bonusThreshold.GetFirstInt();

            multiplier = compareLevel - minThreshold;
            int totalBonus = (int)Math.Floor(PerLevelBonus * multiplier);

            return(totalBonus > 0);
        }