private void AddWordset(IEnumerable <string> words) { var enumerated = words as string[] ?? words.ToArray(); var word = enumerated.First(); WordSetTreeNode nod; if (!_children.TryGetValue(word, out nod)) { nod = new WordSetTreeNode { _word = word, _parent = this, Level = Level + 1 }; _children.Add(word, nod); } if (enumerated.Length > 1) { nod.AddWordset(enumerated.Skip(1)); } else { nod._isLeaf = true; } }
public void AddWordset(IEnumerable <string> words) { string word = words.First(); if (_Children == null) { _Children = new Dictionary <string, WordSetTreeNode>(); } WordSetTreeNode nod = null; _Children.TryGetValue(word, out nod); if (nod == null) { nod = new WordSetTreeNode() { Word = word, Parent = this, _Level = this._Level + 1 }; _Children.Add(word, nod); } if (words.Count() > 1) { nod.AddWordset(words.Skip(1)); } else { nod.IsLeaf = true; } }
private async Task InitializeAsync() { AffixesPerItemType = (from a in await LoadAffixes() group a by a.ItemType into types select types) .ToDictionary(g => g.Key, g => (IReadOnlyList <Affix>) new List <Affix>(g)); ItemBases = (await LoadBases()).ToList(); UniqueBases = (await LoadUniques()).ToList(); ItemBaseDictionary = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name); UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName); _root = new WordSetTreeNode(ItemBases.Select(m => m.Name)); }
private async Task InitializeAsync() { var modsTask = DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods"); var benchOptionsTask = DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options"); var npcMastersTask = DataUtils.LoadRePoEAsync <Dictionary <string, JsonNpcMaster> >("npc_master"); var statTranslationsTask = DataUtils.LoadRePoEAsync <List <JsonStatTranslation> >("stat_translations"); ModDatabase = new ModDatabase(await modsTask, await benchOptionsTask, await npcMastersTask); StatTranslator = new StatTranslator(await statTranslationsTask); ItemBases = (await LoadBases()).ToList(); UniqueBases = (await LoadUniques()).ToList(); ItemBaseDictionary = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name); UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName); _root = new WordSetTreeNode(ItemBases.Select(m => m.Name)); }
private async Task InitializeAsync() { var modsTask = DataUtils.LoadRePoEAsync <Dictionary <string, JsonMod> >("mods", true); var benchOptionsTask = DataUtils.LoadRePoEAsync <JsonCraftingBenchOption[]>("crafting_bench_options", true); var statTranslatorTask = StatTranslators.CreateFromMainFileAsync(true); ModDatabase = new ModDatabase(await modsTask, await benchOptionsTask); ItemBases = await LoadBases(); UniqueBases = await LoadUniques(); StatTranslator = await statTranslatorTask; ItemBaseDictionary = ItemBases.DistinctBy(b => b.Name).ToDictionary(b => b.Name); UniqueBaseDictionary = UniqueBases.DistinctBy(b => b.UniqueName).ToDictionary(b => b.UniqueName); _root = new WordSetTreeNode(ItemBases.Select(m => m.Name)); }
public static string ItemTypeFromTypeline(string typeline) { if (BaseList != null) { if (_root == null) { _root = new WordSetTreeNode(); var allbs = BaseList.Select(m => m.ItemType.Split(' ')).OrderBy(s => s[0]).ToArray(); foreach (var wl in allbs) { _root.AddWordset(wl); } } var wlist = typeline.Split(' '); List <WordSetTreeNode> ms = new List <WordSetTreeNode>(); for (int i = 0; i < wlist.Length; i++) { var m = _root.Match(wlist.Skip(i)).OrderByDescending(n => n.Level).FirstOrDefault(); if (m != null) { ms.Add(m); } } if (ms.Count == 0) { return(typeline); } else if (ms.Count > 1) { throw new NotImplementedException("duplicate type match"); } else { return(ms[0].ToString()); } } return(typeline); }
private async Task InitializeAsync() { AffixesPerItemType = (from a in await LoadAffixes() group a by a.ItemType into types select types) .ToDictionary(g => g.Key, g => (IReadOnlyList<Affix>)new List<Affix>(g)); BaseList = (await LoadBases()).ToList(); var dict = new Dictionary<string, ItemBase>(); foreach (var itemBase in BaseList) { dict[itemBase.Name] = itemBase; } BaseDictionary = dict; _root = new WordSetTreeNode(BaseList.Select(m => m.Name)); }
private async Task InitializeAsync() { AffixesPerItemType = (from a in await LoadAffixes() group a by a.ItemType into types select types) .ToDictionary(g => g.Key, g => (IReadOnlyList <Affix>) new List <Affix>(g)); BaseList = (await LoadBases()).ToList(); var dict = new Dictionary <string, ItemBase>(); foreach (var itemBase in BaseList) { dict[itemBase.Name] = itemBase; } BaseDictionary = dict; _root = new WordSetTreeNode(BaseList.Select(m => m.Name)); }
public EquipmentData(IOptions options) { _options = options; AffixesPerItemType = (from a in LoadAffixes() group a by a.ItemType into types select types) .ToDictionary(g => g.Key, g => (IReadOnlyList <Affix>) new List <Affix>(g)); BaseList = LoadBases().ToList(); var dict = new Dictionary <string, ItemBase>(); foreach (var itemBase in BaseList) { dict[itemBase.Name] = itemBase; } BaseDictionary = dict; _root = new WordSetTreeNode(BaseList.Select(m => m.Name)); }
public void AddWordset(IEnumerable<string> words) { string word = words.First(); if (_Children == null) _Children = new Dictionary<string, WordSetTreeNode>(); WordSetTreeNode nod = null; _Children.TryGetValue(word, out nod); if (nod == null) { nod = new WordSetTreeNode() { Word = word, Parent = this, _Level = this._Level + 1 }; _Children.Add(word, nod); } if (words.Count() > 1) { nod.AddWordset(words.Skip(1)); } else nod.IsLeaf = true; }
public static string ItemTypeFromTypeline(string typeline) { if (BaseList != null) { if (_root == null) { _root = new WordSetTreeNode(); var allbs = BaseList.Select(m => m.ItemType.Split(' ')).OrderBy(s => s[0]).ToArray(); foreach (var wl in allbs) _root.AddWordset(wl); } var wlist = typeline.Split(' '); List<WordSetTreeNode> ms = new List<WordSetTreeNode>(); for (int i = 0; i < wlist.Length; i++) { var m = _root.Match(wlist.Skip(i)).OrderByDescending(n => n.Level).FirstOrDefault(); if (m != null) ms.Add(m); } if (ms.Count == 0) return typeline; else if (ms.Count > 1) throw new NotImplementedException("duplicate type match"); else return ms[0].ToString(); } return typeline; }
private void AddWordset(IEnumerable<string> words) { var enumerated = words as string[] ?? words.ToArray(); var word = enumerated.First(); WordSetTreeNode nod; if (!_children.TryGetValue(word, out nod)) { nod = new WordSetTreeNode { _word = word, _parent = this, Level = Level + 1 }; _children.Add(word, nod); } if (enumerated.Length > 1) nod.AddWordset(enumerated.Skip(1)); else nod._isLeaf = true; }