public SubClass(OGLContext context, String name, ClassDefinition classdefinition) { Name = name; if (classdefinition != null) { ClassName = classdefinition.Name; } Features = new List <Feature>(); MulticlassingSpellLevels = new List <int>(); MulticlassingFeatures = new List <Feature>(); FirstClassFeatures = new List <Feature>(); Descriptions = new List <Description>(); Source = context.Config.DefaultSource; Register(context, null, false); }
public bool Test(OGLContext context) { if (Name != null && Name.ToLowerInvariant().Contains(context.Search)) { return(true); } if (Description != null && Description.ToLowerInvariant().Contains(context.Search)) { return(true); } if (Keywords != null && Keywords.Exists(k => k.Name == context.Search)) { return(true); } return(false); }
public bool Test(OGLContext context) { if (Name != null && Name.ToLowerInvariant().Contains(context.Search)) { return(true); } if (Description != null && Description.ToLowerInvariant().Contains(context.Search)) { return(true); } if (Requirement != null && Requirement.ToLowerInvariant().Contains(context.Search)) { return(true); } return(false); }
public Item(OGLContext context, String name, String description, Price price, double weight, int stacksize = 1, Keyword kw1 = null, Keyword kw2 = null, Keyword kw3 = null, Keyword kw4 = null, Keyword kw5 = null, Keyword kw6 = null, Keyword kw7 = null) { Name = name; Description = description; Price = price; Weight = weight; autogenerated = false; StackSize = stacksize; Category = Category.Make(context); Source = context.Config.DefaultSource; Keywords = new List <Keyword>() { kw1, kw2, kw3, kw4, kw5, kw6, kw7 }; Keywords.RemoveAll(kw => kw == null); Register(context, null); }
public void Register(OGLContext context, string filename, bool applyKeywords) { this.FileName = filename; string full = Name + " " + ConfigManager.SourceSeperator + " " + Source; if (context.Classes.ContainsKey(full)) { throw new Exception("Duplicate Class: " + full); } context.Classes.Add(full, this); if (context.ClassesSimple.ContainsKey(Name)) { context.ClassesSimple[Name].ShowSource = true; ShowSource = true; } else { context.ClassesSimple.Add(Name, this); } Keyword me = new Keyword(Name); if (applyKeywords) { if (FeaturesToAddClassKeywordTo != null && FeaturesToAddClassKeywordTo.Count > 0) { foreach (Feature f in context.Features) { if (FeaturesToAddClassKeywordTo.Contains(f.Name, ConfigManager.SourceInvariantComparer)) { f.AssignKeywords(me); } } } if (SpellsToAddClassKeywordTo != null && SpellsToAddClassKeywordTo.Count > 0) { foreach (Spell s in context.Spells.Values) { if (SpellsToAddClassKeywordTo.Contains(s.Name + " " + ConfigManager.SourceSeperator + " " + s.Source, ConfigManager.SourceInvariantComparer)) { s.AssignKeywords(me); } } } } }
public static Dictionary <DirectoryInfo, string> GetAllDirectories(OGLContext context, string type) { Dictionary <DirectoryInfo, string> result = new Dictionary <DirectoryInfo, string>(); foreach (string s in Sources) { if (context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { continue; } DirectoryInfo res = new DirectoryInfo(Path.Combine(AppPath, s, type)); if (res.Exists) { result.Add(res, s); } } return(result); }
public static Dictionary <FileInfo, string> GetAllZips(OGLContext context) { Dictionary <FileInfo, string> result = new Dictionary <FileInfo, string>(); foreach (string s in Sources) { if (context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { continue; } FileInfo res = new FileInfo(Path.Combine(AppPath, s + ".zip")); if (res.Exists) { result.Add(res, s); } } return(result); }
public void Register(OGLContext context, string file, bool applyKeywords) { this.FileName = file; string full = Name + " " + ConfigManager.SourceSeperator + " " + Source; if (context.SubClasses.ContainsKey(full)) { throw new Exception("Duplicate Subclass: " + full); } context.SubClasses.Add(full, this); if (context.SubClassesSimple.ContainsKey(Name)) { context.SubClassesSimple[Name].ShowSource = true; ShowSource = true; } else { context.SubClassesSimple.Add(Name, this); } }
public static Dictionary <FileInfo, string> EnumerateFiles(OGLContext context, string type, SearchOption option = SearchOption.AllDirectories, string pattern = "*.xml") { Dictionary <FileInfo, string> result = new Dictionary <FileInfo, string>(); try { foreach (var f in GetAllDirectories(context, type)) { foreach (FileInfo file in f.Key.EnumerateFiles(pattern, option)) { result.Add(file, f.Value); } } } catch (Exception e) { ConfigManager.LogError(e); } return(result); }
public void Register(OGLContext context, string file) { FileName = file; string full = Name + " " + ConfigManager.SourceSeperator + " " + Source; if (context.Conditions.ContainsKey(full)) { throw new Exception("Duplicate Condition: " + full); } context.Conditions.Add(full, this); if (context.ConditionsSimple.ContainsKey(Name)) { context.ConditionsSimple[Name].ShowSource = true; ShowSource = true; } else { context.ConditionsSimple.Add(Name, this); } }
public static bool Init(OGLContext context, string path, bool skipInsteadOfExit = false) { Sources = new List <string>(); AppPath = path; ConfigManager.InvalidChars = (new string(Path.GetInvalidFileNameChars()) + ConfigManager.SourceSeperator).ToCharArray(); foreach (string s in Directory.EnumerateDirectories(path)) { if (s.Equals(context.Config.Plugins_Directory)) { continue; } string f = Path.Combine(s, "LICENSE"); if (File.Exists(f)) { if (ConfigManager.LicenseProvider.ShowLicense(Path.GetFileName(s), File.ReadAllLines(f))) { Sources.Add(Path.GetFileName(s)); File.Move(f, f + ".txt"); } else if (!skipInsteadOfExit) { return(false); } } else { Sources.Add(Path.GetFileName(s)); } } foreach (string s in Directory.EnumerateFiles(path, "*.zip")) { string n = Path.GetFileName(s).Substring(0, Path.GetFileName(s).Length - 4); if (!Sources.Contains(n)) { Sources.Add(n); } } return(true); }
public ClassDefinition(OGLContext context, String name, String description, int hitdie, List <string> featuresToAddClassKeywordTo = null, List <List <string> > spellsToAddClassKeywordTo = null) { Name = name; Description = description; Descriptions = new List <Description>(); Source = context.Config.DefaultSource; Features = new List <Feature>(); MulticlassingSpellLevels = new List <int>(); MulticlassingFeatures = new List <Feature>(); FirstClassFeatures = new List <Feature>(); MulticlassingAbilityScores = Ability.None; HPFirstLevel = hitdie; HitDie = hitdie; AverageHPPerLevel = (hitdie / 2) + 1; FeaturesToAddClassKeywordTo = featuresToAddClassKeywordTo; SpellsToAddClassKeywordTo = new List <string>(); int level = 0; if (spellsToAddClassKeywordTo != null) { foreach (List <string> ls in spellsToAddClassKeywordTo) { foreach (string s in ls) { if (!context.SpellsSimple.ContainsKey(s)) { Spell sp = new Spell(context, level, s, "", "", "", "Missing Entry"); if (level == 0) { sp.AssignKeywords(new Keyword("Cantrip")); } } } level++; SpellsToAddClassKeywordTo.AddRange(ls); } } Register(context, null, false); }
public static Dictionary <ZipArchive, string> GetAllZips(OGLContext context, string type) { Dictionary <ZipArchive, string> result = new Dictionary <ZipArchive, string>(); string t = type.TrimEnd('/', '\\').ToLowerInvariant() + "/"; string tt = type.TrimEnd('/', '\\').ToLowerInvariant() + "\\"; foreach (string s in Sources) { if (context.ExcludedSources.Contains(s, StringComparer.OrdinalIgnoreCase)) { continue; } FileInfo res = new FileInfo(Path.Combine(AppPath, s + ".zip")); if (res.Exists) { string f = s.ToLowerInvariant() + "/" + t; string ff = s.ToLowerInvariant() + "\\" + tt; try { ZipArchive archive = ZipFile.OpenRead(res.FullName); foreach (var e in archive.Entries) { string name = e.FullName.ToLowerInvariant(); if (name.StartsWith(t) || name.StartsWith(f) || name.StartsWith(tt) || name.StartsWith(ff)) { result.Add(archive, s); break; } } } catch (Exception e) { ConfigManager.LogError(e); } } } return(result); }
public void Register(OGLContext context, String file) { FileName = file; foreach (Keyword kw in Keywords) { kw.check(); } string full = Name + " " + ConfigManager.SourceSeperator + " " + Source; if (context.Items.ContainsKey(full)) { throw new Exception("Duplicate Item: " + full); } context.Items.Add(full, this); if (context.ItemsSimple.ContainsKey(Name)) { context.ItemsSimple[Name].ShowSource = true; ShowSource = true; } else { context.ItemsSimple.Add(Name, this); } }
public static void ImportItem(Stream reader, string fullpath, string source, OGLContext context, IEnumerable <String> path) { String cat = context.Config.Items_Directory; List <String> p = new List <string>() { cat }; p.AddRange(path); for (int i = 1; i < p.Count; i++) { cat = String.Join("/", p.Take(i)); if (!Category.Categories.ContainsKey(cat)) { Category.Categories.Add(cat, new Category(cat, p.Take(i), context)); } } Item s = (Item)Item.Serializer.Deserialize(reader); s.Category = Category.Categories[cat]; s.Source = source; s.Register(context, fullpath); }
public List <Feature> CollectFeatures(int level, bool secondClass, IChoiceProvider provider, OGLContext context) { List <Feature> res = new List <Feature>(); foreach (Feature f in Features) { f.Source = Source; res.AddRange(f.Collect(level, provider, context)); } if (secondClass) { foreach (Feature f in MulticlassingFeatures) { f.Source = Source; res.AddRange(f.Collect(level, provider, context)); } } else { foreach (Feature f in FirstClassFeatures) { f.Source = Source; res.AddRange(f.Collect(level, provider, context)); } } return(res); }
public List <Feature> CollectFeatures(int level, IChoiceProvider choiceProvider, OGLContext context) { List <Feature> res = new List <Feature>(); foreach (Feature f in Features) { f.Source = Source; res.AddRange(f.Collect(level, choiceProvider, context)); } return(res); }
public Spell(OGLContext context, int level, string name, string castingTime, string range, string duration, string description) { Keywords = new List <Keyword>(); Descriptions = new List <Description>(); Level = level; Name = name; CastingTime = castingTime; Range = range; Duration = duration; Description = description; Source = context.Config.DefaultSource; CantripDamage = new List <CantripDamage>(); if (Duration != null && Duration.ToLowerInvariant().Contains("instantaneous")) { Keywords.Add(new Keyword("Instantaneous")); } if (Duration != null && Duration.ToLowerInvariant().Contains("concentration")) { Keywords.Add(new Keyword("Concentration")); } if (Level == 0) { Keywords.Add(new Keyword("Cantrip")); } if (Description != null && Description.ToLowerInvariant().Contains("make a ranged spell attack")) { Keywords.Add(new Keyword("Ranged")); Keywords.Add(new Keyword("Attack")); } if (Description != null && Description.ToLowerInvariant().Contains("make a melee spell attack")) { Keywords.Add(new Keyword("Melee")); if (!Keywords.Exists(k => k.Name == "attack")) { Keywords.Add(new Keyword("Attack")); } } if (Description != null && (Description.ToLowerInvariant().Contains("your spell save dc"))) { Keywords.Add(new Keyword("Save")); } if (Description != null && (Description.ToLowerInvariant().Contains("must make a strength saving throw") || Description.ToLowerInvariant().Contains("must succeed on a strength saving throw"))) { Keywords.Add(new Keyword("Strength Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } if (Description != null && (Description.ToLowerInvariant().Contains("must make a dexterity saving throw") || Description.ToLowerInvariant().Contains("must succeed on a dexterity saving throw"))) { Keywords.Add(new Keyword("Dexterity Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } if (Description != null && (Description.ToLowerInvariant().Contains("must make a constitution saving throw") || Description.ToLowerInvariant().Contains("must succeed on a constitution saving throw"))) { Keywords.Add(new Keyword("Constitution Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } if (Description != null && (Description.ToLowerInvariant().Contains("must make an intelligence saving throw") || Description.ToLowerInvariant().Contains("must succeed on an intelligence saving throw"))) { Keywords.Add(new Keyword("Intelligence Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } if (Description != null && (Description.ToLowerInvariant().Contains("must make a wisdom saving throw") || Description.ToLowerInvariant().Contains("must succeed on a wisdom saving throw"))) { Keywords.Add(new Keyword("Wisdom Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } if (Description != null && (Description.ToLowerInvariant().Contains("must make a charisma saving throw") || Description.ToLowerInvariant().Contains("must succeed on a charisma saving throw"))) { Keywords.Add(new Keyword("Charisma Saving Throw")); if (!Keywords.Exists(k => k.Name == "save")) { Keywords.Add(new Keyword("Save")); } } Register(context, null); }
public static void ImportCondition(Stream reader, string fullpath, string source, OGLContext context) { Condition s = (Condition)Condition.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath); }
public static void ImportLanguage(Stream reader, string fullpath, string source, OGLContext context) { Language s = (Language)Language.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath); }
public static void ImportFeatureContainer(Stream reader, string fullpath, string source, OGLContext context, IEnumerable <String> path) { String cat = context.Config.Features_Directory; List <String> p = new List <string>() { cat }; p.AddRange(path); for (int i = 1; i < p.Count; i++) { cat = String.Join("/", p.Take(i)); } FeatureContainer cont = FeatureContainer.Serializer.Deserialize(reader) as FeatureContainer; List <Feature> feats = cont.Features; if (!context.FeatureContainers.ContainsKey(cat)) { context.FeatureContainers.Add(cat, new List <FeatureContainer>()); } cont.FileName = fullpath; cont.category = cat; cont.Name = Path.GetFileNameWithoutExtension(fullpath); cont.Source = source; context.FeatureContainers[cat].Add(cont); foreach (Feature feat in feats) { feat.Source = cont.Source; foreach (Keyword kw in feat.Keywords) { kw.check(); } feat.Category = cat; if (!context.FeatureCategories.ContainsKey(cat)) { context.FeatureCategories.Add(cat, new List <Feature>()); } Feature other = context.FeatureCategories[cat].Where(ff => string.Equals(ff.Name, feat.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (other != null) { other.ShowSource = true; feat.ShowSource = true; } context.FeatureCategories[cat].Add(feat); if (cat.Equals("Feats/Boons", StringComparison.OrdinalIgnoreCase)) { if (context.BoonsSimple.ContainsKey(feat.Name)) { context.BoonsSimple[feat.Name].ShowSource = true; feat.ShowSource = true; } else { context.BoonsSimple.Add(feat.Name, feat); } if (context.Boons.ContainsKey(feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source)) { ConfigManager.LogError("Duplicate Boon: " + feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source); } else { context.Boons[feat.Name + " " + ConfigManager.SourceSeperator + " " + feat.Source] = feat; } } } foreach (Feature feat in feats) { context.Features.Add(feat); } }
public static void ImportMagicItem(Stream reader, string fullpath, string source, OGLContext context, IEnumerable <String> path) { String cat = context.Config.Magic_Directory; List <String> p = new List <string>() { cat }; p.AddRange(path); for (int i = 1; i < p.Count; i++) { cat = String.Join("/", p.Take(i)); if (!context.MagicCategories.ContainsKey(cat)) { context.MagicCategories.Add(cat, MakeMagicCategory(p.Take(i))); } } MagicProperty mp = ((MagicProperty)MagicProperty.Serializer.Deserialize(reader)); mp.FileName = fullpath; mp.Source = source; foreach (Feature fea in mp.AttunementFeatures) { fea.Source = source; } foreach (Feature fea in mp.CarryFeatures) { fea.Source = source; } foreach (Feature fea in mp.OnUseFeatures) { fea.Source = source; } foreach (Feature fea in mp.EquipFeatures) { fea.Source = source; } mp.Category = cat; context.MagicCategories[cat].Contents.Add(mp); if (context.Magic.ContainsKey(mp.Name + " " + ConfigManager.SourceSeperator + " " + mp.Source)) { throw new Exception("Duplicate Magic Property: " + mp.Name + " " + ConfigManager.SourceSeperator + " " + mp.Source); } if (context.MagicSimple.ContainsKey(mp.Name)) { context.MagicSimple[mp.Name].ShowSource = true; mp.ShowSource = true; } context.Magic.Add(mp.Name + " " + ConfigManager.SourceSeperator + " " + mp.Source, mp); context.MagicSimple[mp.Name] = mp; }
public static void ImportSubClass(Stream reader, string fullpath, string source, OGLContext context, bool applyKeywords = false) { SubClass s = (SubClass)SubClass.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath, applyKeywords); }
public static void Import(Stream reader, String fullpath, String source, String basepath, OGLContext context, bool applyKeywords = false) { IEnumerable <String> path = GetPath(fullpath, basepath, source, out String type); if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Monster_Directory)) { ImportMonster(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Features_Directory)) { ImportFeatureContainer(reader, fullpath, source, context, path); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Items_Directory)) { ImportItem(reader, fullpath, source, context, path); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Magic_Directory)) { ImportMagicItem(reader, fullpath, source, context, path); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Spells_Directory)) { ImportSpell(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Backgrounds_Directory)) { ImportBackground(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Races_Directory)) { ImportRace(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.SubRaces_Directory)) { ImportSubRace(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.SubClasses_Directory)) { ImportSubClass(reader, fullpath, source, context, applyKeywords); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Classes_Directory)) { ImportClass(reader, fullpath, source, context, applyKeywords); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Languages_Directory)) { ImportLanguage(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Skills_Directory)) { ImportSkill(reader, fullpath, source, context); } else if (StringComparer.OrdinalIgnoreCase.Equals(type, context.Config.Conditions_Directory)) { ImportCondition(reader, fullpath, source, context); } else { throw new Exception("Unknown Type: " + type); } }
public static void ImportSpell(Stream reader, string fullpath, string source, OGLContext context) { Spell s = (Spell)Spell.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath); }
public void ApplyKeywords(OGLContext context) { }
public static void ImportBackground(Stream reader, string fullpath, string source, OGLContext context) { { Background s = (Background)Background.Serializer.Deserialize(reader); s.Source = source; foreach (Feature fea in s.Features) { fea.Source = source; } s.Register(context, fullpath); } }
public static void ImportClass(Stream reader, string fullpath, string source, OGLContext context, bool applyKeywords = false) { ClassDefinition s = (ClassDefinition)ClassDefinition.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath, applyKeywords); }
public static void ImportSubRace(Stream reader, string fullpath, string source, OGLContext context) { SubRace s = (SubRace)SubRace.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath); }
public static void ImportMonster(Stream reader, string fullpath, string source, OGLContext context) { Monster s = (Monster)Monster.Serializer.Deserialize(reader); s.Source = source; s.Register(context, fullpath); }