Beispiel #1
0
        private StatBlockInfo.MetaMagicPowers ParseMetaMagicPowers(ref string spell)
        {
            StatBlockInfo.MetaMagicPowers powers = StatBlockInfo.MetaMagicPowers.None;
            foreach (string Meta in MetaMagicList)
            {
                if (spell.Contains(Meta))
                {
                    if ((Meta == "silent" && spell.Contains("silent image")))
                    {
                        continue;
                    }
                    if ((Meta == "heightened" && spell.Contains("heightened awareness")))
                    {
                        continue;
                    }

                    spell = spell.ReplaceFirst(Meta, string.Empty);
                    string temp = Meta;
                    if (temp == "still")
                    {
                        temp = "stilled";
                    }
                    try
                    {
                        powers |= (StatBlockInfo.MetaMagicPowers)Enum.Parse(typeof(StatBlockInfo.MetaMagicPowers), temp);
                    }
                    catch
                    {
                        throw new Exception("ParseMetaMagicPowers--mising MetaMagicPowers enum for " + temp);
                    }
                }
            }
            return(powers);
        }
Beispiel #2
0
        private StatBlockInfo.MetaMagicPowers ParseMetaMagicPowers(ref string scroll)
        {
            StatBlockInfo.MetaMagicPowers powers = StatBlockInfo.MetaMagicPowers.None;
            List <string> MetaMagicList          = CommonInfo.GetMetaMagicPowers();

            foreach (string Meta in MetaMagicList)
            {
                if (scroll.Contains(Meta))
                {
                    if ((Meta == "silent" && scroll.Contains("silent image")))
                    {
                        continue;
                    }
                    if ((Meta == "heightened" && scroll.Contains("heightened awareness")))
                    {
                        continue;
                    }

                    scroll = scroll.ReplaceFirst(Meta, string.Empty);
                    string temp = Meta;
                    if (temp == "still")
                    {
                        temp = "stilled";
                    }
                    powers |= (StatBlockInfo.MetaMagicPowers)Enum.Parse(typeof(StatBlockInfo.MetaMagicPowers), temp);
                }
            }
            return(powers);
        }
Beispiel #3
0
 public SpellData(string Name, int Count, int Level, int DC, int CL, string Limitations,
                  string Frequency, bool Domain, bool Spirit, bool AlreadyCast, StatBlockInfo.MetaMagicPowers MetaMagicPowers)
 {
     _Name            = Name.Trim();
     _Count           = Count;
     _Level           = Level;
     _DC              = DC;
     _CL              = CL;
     _Limitations     = Limitations.Trim();
     _Frequency       = Frequency.Trim();
     _Domain          = Domain;
     _Spirit          = Spirit;
     _alreadyCast     = AlreadyCast;
     _metaMagicPowers = MetaMagicPowers;
 }
Beispiel #4
0
        private SpellData ParseOneSpell(string spell, int Level, string Frequency)
        {
            string Name, temp, temp2;
            int    Count       = 1;
            int    DC          = 0;
            string Limitations = string.Empty;
            bool   Domain      = false;
            bool   Spirit      = false;
            bool   AlreadyCast = false;
            int    Pos;

            if (Frequency.Length > 0)
            {
                Pos = Frequency.IndexOf("/");
                if (Pos >= 0)
                {
                    temp  = Frequency.Substring(0, Pos);
                    Count = Convert.ToInt32(temp);
                }
                else
                {
                    Count = -1;
                }
            }

            Pos = spell.IndexOf("already cast");
            if (Pos >= 0)
            {
                AlreadyCast = true;
                spell       = spell.Replace("; already cast", string.Empty).Trim();
                spell       = spell.Replace("already cast", string.Empty).Trim();
            }

            Pos = spell.IndexOf(PathfinderConstants.PAREN_LEFT);
            if (Pos == -1)
            {
                if (spell.Substring(spell.Length - 1, 1) == "D")
                {
                    Domain = true;
                    spell  = spell.Substring(0, spell.Length - 1);
                }
                if (spell.EndsWith("S"))
                {
                    Spirit = true;
                    spell  = spell.Substring(0, spell.Length - 1);
                }

                spell = spell.Replace("*", string.Empty).Trim();
                StatBlockInfo.MetaMagicPowers powers = ParseMetaMagicPowers(ref spell);
                return(new SpellData(spell, Count, Level, -1, -1, string.Empty, Frequency, Domain, Spirit, false, powers));
            }
            else
            {
                Name = spell.Substring(0, Pos).Trim();
                temp = spell.Replace(Name, string.Empty).Trim();
                Name = Name.Replace("*", string.Empty);
                if (Name.EndsWith("APG"))
                {
                    Name = Name.Substring(0, Name.Length - "APG".Length);
                }

                if (Name.Substring(Name.Length - 1, 1) == "D")
                {
                    Domain = true;
                    Name   = Name.Substring(0, Name.Length - 1);
                }
                if (Name.EndsWith("S"))
                {
                    Spirit = true;
                    Name   = Name.Substring(0, Name.Length - 1);
                }
                Pos = temp.IndexOf(PathfinderConstants.PAREN_LEFT);
                while (Pos >= 0)
                {
                    Pos = temp.IndexOf(PathfinderConstants.PAREN_RIGHT);
                    if (Pos == -1)
                    {
                        Pos = temp.IndexOf(";");
                    }
                    temp2 = temp.Substring(0, Pos + 1);
                    temp  = temp.Replace(temp2, string.Empty).Trim();
                    temp2 = temp2.Replace(PathfinderConstants.PAREN_LEFT, string.Empty);
                    temp2 = temp2.Replace(PathfinderConstants.PAREN_RIGHT, string.Empty);
                    temp2 = temp2.Replace("*", string.Empty).Trim();
                    Pos   = temp2.IndexOf(";");
                    if (Pos >= 0)
                    {
                        temp2 = temp2.Substring(Pos + 1).Trim();
                    }

                    Pos = temp2.LastIndexOf("|"); //commas get changed to pipes | for splitting

                    if (Pos >= 0)
                    {
                        string temp3     = temp2.Substring(0, Pos);
                        int    holdCount = Count;
                        int.TryParse(temp3, out Count);
                        if (Count == 0)
                        {
                            Count = holdCount;
                        }
                        temp2 = temp2.Substring(Pos + 1).Trim();
                    }


                    Pos = temp2.IndexOf("DC");

                    if (Pos >= 0)
                    {
                        temp2 = temp2.Replace("DC", string.Empty).Trim();
                        temp2 = temp2.Replace("half", string.Empty).Trim();
                        DC    = Convert.ToInt32(temp2);
                    }
                    else
                    {
                        try
                        {
                            if (Frequency.Length > 0)
                            {
                                Count = Convert.ToInt32(temp2);
                            }
                            else
                            {
                                try
                                {
                                    Count = Convert.ToInt32(temp2);
                                }
                                catch
                                {
                                    Limitations = temp2.Trim();
                                    Limitations = Limitations.Replace("|", ",");
                                }
                            }
                        }
                        catch
                        {
                            Limitations = temp2.Trim();
                            Limitations = Limitations.Replace("|", ",");
                        }
                    }

                    Pos = temp.IndexOf(PathfinderConstants.PAREN_LEFT);
                }
                StatBlockInfo.MetaMagicPowers powers = ParseMetaMagicPowers(ref spell);
                if (powers != StatBlockInfo.MetaMagicPowers.None)
                {
                    Name = Name.Replace(powers.ToString(), string.Empty).Trim();
                }
                return(new SpellData(Name, Count, Level, DC, 0, Limitations, Frequency, Domain, Spirit, AlreadyCast, powers));
            }
        }