private MonsterStatBlock ApplyMultipleTemplates(TemplateManager.TemplateManager TM, MonsterStatBlock TestMonSB, List <string> templates, List <string> stackedTemplateList) { List <string> Failures; TestMonSB = TM.ApplyMultipleTemplates(TestMonSB, templates, out Failures); if (Failures.Any()) { _sbCheckerBaseInput.MessageXML.AddInfo("Failed Application of Template - " + string.Join(",", stackedTemplateList.ToArray())); } 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); } } } } }
public ValidationResult(List <ValidationRuleResult> validationResults) { Failures = validationResults?.Where(result => result.Failed).ToList().AsReadOnly() ?? throw new ArgumentNullException(nameof(validationResults)); Failed = Failures.Any(); }
internal bool ShouldHalt() => HaltsOnFirstFailure && Failures.Any();
public bool IsSuccessful() { return(!Failures.Any()); }