private MonsterStatBlock ApplyStackedTemplates(TemplateManager.TemplateManager TM, MonsterStatBlock TestMonSB, List <string> stackedTemplateList, string stackedTemplateBase, out List <string> Failures)
        {
            TestMonSB = TM.ApplyTemplate(_sbCheckerBaseInput.MonsterSB, stackedTemplateBase, stackedTemplateList, out Failures);
            if (Failures.Any())
            {
                _sbCheckerBaseInput.MessageXML.AddInfo("Failed Application of Template - " + string.Join(",", Failures.ToArray()));
            }

            return(TestMonSB);
        }
        private MonsterStatBlock ApplyOneTemplate(string CheckName, TemplateManager.TemplateManager TM, MonsterStatBlock TestMonSB)
        {
            bool success;

            TestMonSB = TM.ApplyTemplate(TestMonSB, _sbCheckerBaseInput.MonsterSB.TemplatesApplied.Trim(), out success);
            if (success)
            {
                _sbCheckerBaseInput.MessageXML.AddInfo("Template Applied - " + _sbCheckerBaseInput.MonsterSB.TemplatesApplied.Trim());
            }
            else
            {
                _sbCheckerBaseInput.MessageXML.AddFail(CheckName, "Failed Application of Template - " + _sbCheckerBaseInput.MonsterSB.TemplatesApplied.Trim());
            }

            return(TestMonSB);
        }
        private void CheckAppliedTemplates(TemplateManager.TemplateManager TM, ref MonsterStatBlock TestMonSB)
        {
            string CheckName        = "CheckAppliedTemplates";
            bool   stackedTemplates = false;

            if (_sbCheckerBaseInput.MonsterSB.TemplatesApplied.Contains(","))
            {
                stackedTemplates = true;                                                               //|1,2,3…@sk|
            }
            List <string> templates = _sbCheckerBaseInput.MonsterSB.TemplatesApplied.Split('|').ToList();

            templates.RemoveAll(x => x == string.Empty);
            List <string> stackedTemplateList = new List <string>();
            string        stackedTemplateBase = string.Empty;

            if (stackedTemplates)
            {
                FindStackTemplates(templates, ref stackedTemplateList, ref stackedTemplateBase);
            }

            foreach (string appliedTemplate in templates)
            {
                string lowerAppliedTemplate = appliedTemplate.ToLower();
                if (lowerAppliedTemplate.Contains("advanced") || lowerAppliedTemplate.Contains("advanced hd") || lowerAppliedTemplate.Contains("advanced-hd"))
                {
                    if (_sbCheckerBaseInput.MonsterSB.HDValue() - _sbCheckerBaseInput.CharacterClasses.FindTotalClassLevels() != _sbCheckerBaseInput.Race_Base.RacialHDValue())
                    {
                        TestMonSB = ApplyAdvancedHDTemplate(TM, TestMonSB);
                    }
                    else
                    {
                        if (TestMonSB != null)
                        {
                            List <string> Failures;
                            if (stackedTemplates)
                            {
                                TestMonSB = ApplyStackedTemplates(TM, TestMonSB, stackedTemplateList, stackedTemplateBase, out Failures);
                            }
                            else
                            {
                                if (templates.Count == 1)
                                {
                                    TestMonSB = ApplyOneTemplate(CheckName, TM, TestMonSB);
                                }
                                else
                                {
                                    TestMonSB = ApplyMultipleTemplates(TM, TestMonSB, templates, stackedTemplateList);
                                }
                            }
                            _sbCheckerBaseInput.Race_Base.ApplyTemplatedRaceSB(TestMonSB, true);
                        }
                    }
                }
                else
                {
                    if (TestMonSB != null)
                    {
                        bool             Success;
                        MonsterStatBlock tempmonSB = null;
                        List <string>    Failures;

                        if (stackedTemplates)
                        {
                            TestMonSB = ApplyStackedTemplates(TM, TestMonSB, stackedTemplateList, stackedTemplateBase, out Failures);
                            Success   = !Failures.Any();
                        }
                        else
                        {
                            TM.ApplyTemplate(TestMonSB, lowerAppliedTemplate.Trim(), out Success);
                        }
                        if (tempmonSB != null)
                        {
                            TestMonSB = tempmonSB;
                        }
                        if (!Success)
                        {
                            _sbCheckerBaseInput.MessageXML.AddFail("CheckTemplates", "Template not applied for " + lowerAppliedTemplate.Trim());
                        }
                        else
                        {
                            _sbCheckerBaseInput.MessageXML.AddInfo("Template Applied - " + lowerAppliedTemplate.Trim());
                            _sbCheckerBaseInput.Race_Base.ApplyTemplatedRaceSB(TestMonSB, true);
                        }
                    }
                }
            }
        }