Esempio n. 1
0
        private void ParseBlockHeader(Match m)
        {
            SpellBlockInfo blockInfo = this;

            if (m.Groups["classname"].Success)
            {
                blockInfo.Class = m.Groups["classname"].Value.Trim();
            }

            if (m.Groups["sla"].Success)
            {
                blockInfo._SpellLikeAbilities = true;
            }

            else if (m.Groups["blocktype"].Success)
            {
                blockInfo.BlockType = m.Groups["blocktype"].Value.Trim();
            }


            blockInfo.Concentration = m.IntValue("concentration");
            blockInfo.MeleeTouch    = m.IntValue("meleetouch");
            blockInfo.RangedTouch   = m.IntValue("rangedtouch");
            blockInfo.CasterLevel   = m.IntValue("cl");
            blockInfo.SpellFailure  = m.IntValue("spellfailure");
        }
Esempio n. 2
0
 public SpellBlockInfo(SpellBlockInfo old)
 {
     _Class              = old._Class;
     _MeleeTouch         = old._MeleeTouch;
     _RangedTouch        = old._RangedTouch;
     _Concentration      = old.Concentration;
     _CasterLevel        = old._CasterLevel;
     _SpellLikeAbilities = old._SpellLikeAbilities;
     _BlockType          = old._BlockType;
     _SpellFailure       = old.SpellFailure;
     foreach (SpellLevelInfo info in old._Levels)
     {
         _Levels.Add(new SpellLevelInfo(info));
     }
 }
Esempio n. 3
0
        private static void ParseSLABlocks(ObservableCollection <SpellBlockInfo> info, string text)
        {
            //DebugTimer t = new DebugTimer("SLA Blocks", false, false);

            Regex regSpell  = new Regex(slaspellblock);
            Regex regSpells = new Regex("(?<classname>" + _ClassRegexString + " )?(?<sla>Spell-Like Abilities) *\\(CL ((?<cl>[0-9]+)(st|nd|rd|th)?)(?<altcl> \\[[0-9]+(st|nd|rd|th)? [A-Za-z]+\\.\\])?([,;] *concentration *[\\p{Pd}+]?(?<concentration>[0-9]+)( \\[[\\p{Pd}+][0-9]+ [\\p{L} ]+\\])?)?([,;] *[\\p{Pd}+]?(?<spellfailure>[0-9]+)% spell failure)?([,;] *[\\p{Pd}+]?(?<meleetouch>[0-9]+) melee touch)?([,;] *[\\p{Pd}+]?(?<rangedtouch>[0-9]+) ranged touch)?\\)[:\r\n]*");
            Regex regLevel  = new Regex(slablock);



            Match m = regSpells.Match(text);


            //t.MarkEventIf("First", 20);

            if (m.Success)
            {
                SpellBlockInfo blockInfo = new SpellBlockInfo();
                blockInfo.ParseBlockHeader(m);

                Regex           regSlaHeader   = new Regex(slaheader, RegexOptions.IgnoreCase);
                string          spellBlock     = text;
                List <string>   spellblockList = new List <string>();
                MatchCollection mc             = regSlaHeader.Matches(spellBlock);


                for (int i = 0; i < mc.Count; i++)
                {
                    Match spellMatch = mc[i];
                    int   start      = spellMatch.Index;
                    int   length;
                    Match next = null;

                    if (i + 1 < mc.Count)
                    {
                        next = mc[i + 1];
                    }

                    if (next != null)
                    {
                        length = next.Index - start;
                    }
                    else
                    {
                        length = spellBlock.Length - start;
                    }


                    string btext = spellBlock.Substring(start, length);
                    spellblockList.Add(btext);
                }

                //t.MarkEventIf("SpellBlocklist", 20);


                foreach (string block in spellblockList)
                {
                    //t.MarkEventIf("levmatch s", 100);
                    Match levelMatch = regLevel.Match(block);
                    //t.MarkEventIf("levmatch: " + block, 10);

                    SpellLevelInfo levelInfo = new SpellLevelInfo();


                    if (levelMatch.Groups["daily"].Success)
                    {
                        if (String.Compare(levelMatch.Groups["daily"].Value.Trim(), "At Will", true) == 0)
                        {
                            levelInfo.AtWill = true;
                        }
                        else if (String.Compare(levelMatch.Groups["daily"].Value.Trim(), "Constant", true) == 0)
                        {
                            levelInfo.Constant = true;
                        }
                        else
                        {
                            levelInfo.PerDay = int.Parse(levelMatch.Groups["daily"].Value);
                        }
                    }
                    else if (levelMatch.Groups["atwill"].Success)
                    {
                        levelInfo.AtWill = true;
                    }
                    else if (levelMatch.Groups["constant"].Success)
                    {
                        levelInfo.Constant = true;
                    }

                    levelInfo.More = levelMatch.IntValue("more");

                    SpellInfo prevInfo = null;
                    Match     spell    = regSpell.Match(levelMatch.Groups["spellblocks"].Value);
                    while (spell.Success)
                    {
                        SpellInfo spellInfo = ParseSpell(spell, prevInfo);

                        if (spellInfo != prevInfo && spellInfo.Name.Length > 0)
                        {
                            levelInfo.Spells.Add(spellInfo);
                        }

                        prevInfo = spellInfo;
                        spell    = spell.NextMatch();
                    }

                    if (levelInfo.Spells.Count > 0)
                    {
                        blockInfo.Levels.Add(levelInfo);
                    }
                }

                if (blockInfo.Levels.Count > 0)
                {
                    info.Add(blockInfo);
                }
            }

            //t.MarkEventIfTotal("Long: " + text , 10);
        }
Esempio n. 4
0
        public static ObservableCollection <SpellBlockInfo> ParseInfo(string spellBlock)
        {
            ObservableCollection <SpellBlockInfo> blocklist = new ObservableCollection <SpellBlockInfo>();


            Regex group = new Regex("((" + _ClassRegexString + ") )?(?<sla>Spell-Like Abilities)|((" + _ClassRegexString + ") )?Spells (?<blocktype>(Known|Prepared))");

            List <string> list     = new List <string>();
            List <string> slablock = new List <string>();

            foreach (Match spellMatch in group.Matches(spellBlock))
            {
                int   start = spellMatch.Index;
                int   length;
                Match next = spellMatch.NextMatch();

                if (next.Success)
                {
                    length = next.Index - start;
                }
                else
                {
                    length = spellBlock.Length - start;
                }

                string text = spellBlock.Substring(start, length);
                if (spellMatch.Groups["sla"].Success)
                {
                    slablock.Add(text);
                }
                else
                {
                    list.Add(text);
                }
            }

            foreach (String spells in list)
            {
                Regex regSpell  = new Regex(spellblock);
                Regex regSpells = new Regex("((?<classname>" + _ClassRegexString + " )?(?<sla>Spell-Like Abilities)|(?<classname>" + _ClassRegexString + " )?(Spells (?<blocktype>(Known|Prepared)) +))(\\(CL ((?<cl>([0-9]+))(st|nd|rd|th)?)(?<altcl> \\[[0-9]+(st|nd|rd|th)? [A-Za-z]+\\.\\])?([,;] *concentration *[\\p{Pd}+]?(?<concentration>[0-9]+)( \\[[\\p{Pd}+][0-9]+ [\\p{L}. ]+\\])?)?([,;] *[\\p{Pd}+]?(?<spellfailure>[0-9]+)% spell failure)?([,;] *[\\p{Pd}+]?(?<meleetouch>[0-9]+) melee touch)?([,;] *[\\p{Pd}+]?(?<rangedtouch>[0-9]+) ranged touch)?\\))[:\r\n]*" +
                                            "(?<levelblocks>" + levelblock + "\r?\n?)+");
                Regex regLevel = new Regex(levelblock);


                foreach (Match m in regSpells.Matches(spells))
                {
                    SpellBlockInfo blockInfo = new SpellBlockInfo();
                    blockInfo.ParseBlockHeader(m);


                    foreach (Capture cap in m.Groups["levelblocks"].Captures)
                    {
                        Match levelMatch = regLevel.Match(cap.Value);

                        SpellLevelInfo levelInfo = new SpellLevelInfo();

                        levelInfo.Level = levelMatch.IntValue("level");

                        levelInfo.Cast = levelMatch.IntValue("levelcast");

                        if (levelMatch.Groups["daily"].Success)
                        {
                            if (String.Compare(levelMatch.Groups["daily"].Value.Trim(), "At Will", true) == 0)
                            {
                                levelInfo.AtWill = true;
                            }
                            else if (String.Compare(levelMatch.Groups["daily"].Value.Trim(), "Constant", true) == 0)
                            {
                                levelInfo.Constant = true;
                            }
                            else
                            {
                                levelInfo.PerDay = int.Parse(levelMatch.Groups["daily"].Value);
                            }
                        }

                        levelInfo.More = levelMatch.IntValue("more");

                        SpellInfo prevInfo = null;
                        foreach (Match spell in regSpell.Matches(levelMatch.Groups["spellblocks"].Value))
                        {
                            SpellInfo spellInfo = ParseSpell(spell, prevInfo);

                            if (spellInfo != prevInfo && spellInfo.Name.Length > 0)
                            {
                                levelInfo.Spells.Add(spellInfo);
                            }

                            prevInfo = spellInfo;
                        }

                        if (levelInfo.Spells.Count > 0)
                        {
                            blockInfo.Levels.Add(levelInfo);
                        }
                    }

                    if (blockInfo.Levels.Count > 0)
                    {
                        blocklist.Add(blockInfo);
                    }
                }
            }

            foreach (String slatext in slablock)
            {
                ParseSLABlocks(blocklist, slatext);
            }

            return(blocklist);
        }