public static Condition Parse(TextSpan value, bool invert, ProficiencyKind kind) { var baseFunction = kind == ProficiencyKind.Armor ? "character.IsProficientWithArmor" : kind == ProficiencyKind.Shield ? "character.IsProficientWithShield" : kind == ProficiencyKind.Weapon ? "character.IsProficientWithWeapon" : throw new InvalidOperationException("How did we get here?"); int?count = null; var conditions = new List <string>(); foreach (var part in value.Split(',')) { if (!count.HasValue) { count = Helpers.ParseInt(part); continue; } if (part.TryRemovePrefix("TYPE.", out var type)) { conditions.Add($"{baseFunction}Type(\"{type.Value}\")"); } else { conditions.Add($"{baseFunction}(\"{part.Value}\")"); } } if (!count.HasValue) { throw new ParseFailedException(value, "Unable to parse PREPROF**"); } return(new ProficiencyCondition(invert, count.Value, conditions)); }
public Problem Add(ProficiencyKind kind, decimal value) { if (value > 0) { if (Proficiencies.ContainsKey(kind)) { Proficiencies[kind] += (int)value; } else { Proficiencies.Add(kind, (int)value); } } return(this); }
public int GetValue(ProficiencyKind kind) { return(proficiencies[(int)kind]); }