DND_Monster.Ability.TextSpellcasterBoilerplate C# (CSharp) Method

TextSpellcasterBoilerplate() public method

public TextSpellcasterBoilerplate ( string name ) : string
name string
return string
        public string TextSpellcasterBoilerplate(string name)
        {
            if (!isSpell) return "";
            if (String.IsNullOrEmpty(name) || String.IsNullOrWhiteSpace(name))
            {
                name = "Creature";
            }
            else
            {
                if (!name.Contains('*')) { name = name.ToLower(); }
            }
            string spellcastingstat = Description.Split('|')[1];
            int modifier = 0;

            switch (spellcastingstat.ToLower().Substring(0, 3))
            {
                case "str":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.STR) - 10) / 2);
                    break;
                case "int":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.INT) - 10) / 2);
                    break;
                case "wis":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.WIS) - 10) / 2);
                    break;
                case "cha":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.CHA) - 10) / 2);
                    break;
                case "con":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.CON) - 10) / 2);
                    break;
                case "dex":
                    modifier = (int)Math.Floor((double)(Convert.ToInt32(Monster.DEX) - 10) / 2);
                    break;
            }

            string levelSuffix = "th";
            if (Description.Split('|')[2].Trim() == "1")
            {
                levelSuffix = "st";
            }
            if (Description.Split('|')[2].Trim() == "2")
            {
                levelSuffix = "nd";
            }
            if (Description.Split('|')[2].Trim() == "3")
            {
                levelSuffix = "rd";
            }

            string returnstring = "";
            returnstring += "The " + name + " is a " + Description.Split('|')[2] + levelSuffix + "-level spellcaster. ";
            returnstring += "Its spellcasting ability is " + spellcastingstat + " (spell save DC " + (8 + Monster.CR.profBonus + modifier) + ", +" + (modifier + Monster.CR.profBonus) + " to hit with spell attacks). ";

            if (!Description.Contains("NotInnate"))
            {
                returnstring += "It requires no material components to cast its spells. ";
            }
            else
            {
                returnstring += "The " + name + " has the following " + Description.Split('|')[0] + " spells prepared:";
            }

            return returnstring + Environment.NewLine + Environment.NewLine;
        }