Exemple #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());
        }
Exemple #2
0
        string GetDieStr(int spellSlotLevel, int spellCasterLevel, int spellcastingAbilityModifier)
        {
            DieRollDetails details = DieRollDetails.From(OriginalDieStr, spellcastingAbilityModifier);

            string dieStr = details.ToString();

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

            if (!GetMultiplier(spellSlotLevel, spellCasterLevel, out double multiplier))
            {
                return(dieStr);
            }

            DieRollDetails bonusDetails = DieRollDetails.From(BonusPerLevel, 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);
                    if (BonusMax > 0 && matchingRoll.Count > BonusMax)
                    {
                        matchingRoll.Count = BonusMax;
                    }
                    matchingRoll.Offset += (int)Math.Floor(bonusRoll.Offset * multiplier);
                }
            }

            return(details.ToString());
        }