コード例 #1
0
        private HitEffect FindEffectForPosition(int position, DynamicEnumProvider dep, Dictionary <int, HitEffect> effects, Dictionary <int, Match> dcPositions)
        {
            HitEffect effect;
            var       dc = dcPositions.LastOrDefault(d => d.Key < position || d.Key - 20 < position && d.Value.Value.Contains("escape"));

            if (!dc.Equals(default(KeyValuePair <int, Match>)))
            {
                if (!effects.ContainsKey(dc.Key))
                {
                    effects[dc.Key] = new HitEffect();
                    if (dc.Value.Value.Contains("escape"))
                    {
                        effects[dc.Key].DC = new SkillCheck
                        {
                            Skill = Skill.Acrobatics | Skill.Athletics,
                            Value = Convert.ToInt32(dc.Value.Groups[5].Value)
                        };
                    }
                    else if (dc.Value.Value.Contains("check"))
                    {
                        effects[dc.Key].DC = new SkillCheck
                        {
                            Value = Convert.ToInt32(dc.Value.Groups[7].Value)
                        };
                        var reg = new Regex(@"\([A-Za-z]*\)");
                        foreach (var s in reg.Matches(dc.Value.Value).Select(s => Enum.Parse <Skill>(s.Value.Trim('(', ')'), true)))
                        {
                            ((SkillCheck)effects[dc.Key].DC).Skill |= s;
                        }
                    }
                    else if (dc.Value.Value.Contains("saving throw"))
                    {
                        var str = dc.Value.Value.Replace("saving throw", "").Replace("DC " + dc.Value.Groups[2].Value, "").Trim();
                        effects[dc.Key].DC = new SavingThrow()
                        {
                            Value   = Convert.ToInt32(dc.Value.Groups[2].Value),
                            Ability = dep.GetEnumValues("Ability").Parse(str)
                        };
                    }
                }
                effect = effects[dc.Key];
            }
            else
            {
                if (!effects.ContainsKey(0))
                {
                    effects[0] = new HitEffect();
                }
                effect = effects[0];
            }
            return(effect);
        }
コード例 #2
0
        private string TryFindSpellcastingAbility(string spellcastingDescription, DynamicEnumProvider dep, ref List <String> errors)
        {
            var desc = spellcastingDescription.ToLower();

            foreach (var attr in dep.GetEnumValues("Ability").Data)
            {
                if (desc.Contains("ability is " + attr.ToLower()))
                {
                    return(attr);
                }
                if (desc.Contains("that uses " + attr.ToLower() + " as "))
                {
                    return(attr);
                }
            }
            errors.Add("Unable to find spellcasting ability in description: " + spellcastingDescription);
            return("Strength");
        }
コード例 #3
0
 public Monster(DynamicEnumProvider dep)
 {
     Abilities = new Dictionary <string, AbilityScore>();
     foreach (var ability in dep.GetEnumValues("Ability").Data)
     {
         Abilities.Add(ability, new AbilityScore()
         {
             Value = 10
         });
     }
     Race            = new();
     Senses          = new();
     ChallengeRating = new();
     HitDie          = new();
     Skillmodifiers  = new();
     SavingThrows    = new();
     Alignment       = new();
     Speed           = new();
     ArmorInfo       = new();
 }
コード例 #4
0
 public string GetAbility(DynamicEnumProvider dep)
 {
     return(dep.GetEnumValues("Ability").GetFromInt(AbilityId));
 }