public static ConversionMap FromHashCollection(LeagueHashCollection col) { var result = new ConversionMap(); var mapping = new Dictionary <string, Dictionary <string, uint> >(); foreach (var entry in col.Hashes) { var hash = entry.Key; var section = entry.Value.First(); var name = section.Value.First(); if (!mapping.ContainsKey(section.Key)) { mapping[section.Key] = new Dictionary <string, uint>(); } mapping[section.Key].Add(name, hash); } foreach (var kvp in mapping) { foreach (var entry in kvp.Value) { var key = new InibinKey(kvp.Key, entry.Key); var hash = entry.Value; result.Add(key, hash); } } return(result); }
static void ExtractSpellData(ArchiveFileManager manager, string hashSourcesPath) { var data = File.ReadAllText(hashSourcesPath); var hashSourceCollection = JsonConvert.DeserializeObject <LeagueHashSourceCollection>(data); var hashCollection = new LeagueHashCollection(hashSourceCollection); var itemHashes = new HashSet <uint>(); //From Data/Spells/NAME.inibin or Data/Shared/NAME.inibin or Data/Characters/CHARACTER/CHARACTER.inibin (no subdirectories) var itemFiles = manager.GetMatchFileEntries(@"Data(|\/Characters\/([^\/]+)|\/Shared)\/Spells\/([^\/]+)\.inibin"); foreach (var entry in itemFiles) { if (!entry.FullName.Contains(".inibin")) { continue; } if (entry.FullName.Contains(".lua")) { continue; } var file = manager.ReadFile(entry.FullName).Uncompress(); var inibin = Inibin.DeserializeInibin(file, entry.FullName); foreach (var kvp in inibin.Content) { if (itemHashes.Contains(kvp.Key)) { continue; } itemHashes.Add(kvp.Key); } } var mapping = new LeagueHashCollection(); foreach (var hash in itemHashes) { if (!hashCollection.Hashes.ContainsKey(hash)) { continue; } mapping.Hashes.Add(hash, hashCollection.Hashes[hash]); } var result = new LeagueHashCollection(); foreach (var hash in mapping.Hashes) { var sectionFilterer = new SectionFilterer(hash.Value); sectionFilterer.ApplyFilter(new FilterPlaintextSections()); sectionFilterer.ApplyFilter(new FilterDuplicateSections()); sectionFilterer.ApplyFilter(new FilterPlaintextKeys()); result.Hashes.Add(hash.Key, sectionFilterer.CurrentSections); } var conflictResolver = new ConflictResolver(); //result = conflictResolver.ResolveConflicts(result); var itemMappingJson = JsonConvert.SerializeObject(result, Formatting.Indented); File.WriteAllText("spellConversionMapDraft.json", itemMappingJson); }
public void UnduplicateDraft() { var map = new LeagueHashCollection(); foreach (var hash in _draft.Hashes) { var section2 = new Dictionary <string, HashSet <string> >(); foreach (var section in hash.Value) { if (!section2.Keys.ToList().Contains(section.Key, StringComparer.OrdinalIgnoreCase)) { var names = new HashSet <string>(); var names2 = new List <string>(); foreach (var name in section.Value) { if (!names2.Contains(name, StringComparer.OrdinalIgnoreCase)) { names.Add(name); names2.Add(name); } } section2.Add(section.Key, names); } } map.Hashes.Add(hash.Key, section2); } _draft = map; }
static void FilterResult() { var hashSourcesPath = "result.json"; var data = File.ReadAllText(hashSourcesPath); var hashSourceCollection = JsonConvert.DeserializeObject <LeagueHashSourceCollection>(data); var hashCollection = new LeagueHashCollection(hashSourceCollection); var result = new LeagueHashCollection(); foreach (var hash in hashCollection.Hashes) { var sectionFilterer = new SectionFilterer(hash.Value); sectionFilterer.ApplyFilter(new FilterPlaintextSections().SetMinimumCount <FilterPlaintextSections>(0)); sectionFilterer.ApplyFilter(new FilterDuplicateSections().SetMinimumCount <FilterDuplicateSections>(0)); sectionFilterer.ApplyFilter(new FilterPlaintextKeys().SetMinimumCount <FilterPlaintextKeys>(0)); if (!(sectionFilterer.CurrentSections.Count > 0)) { continue; } result.Hashes.Add(hash.Key, sectionFilterer.CurrentSections); } var itemMappingJson = JsonConvert.SerializeObject(result, Formatting.Indented); File.WriteAllText("ResultFiltered.json", itemMappingJson); }
public ProgramInterface() { _hashes = new HashSet <uint>(); _manager = null; _files = new List <ReleaseManifestFileEntry>(); _draft = new LeagueHashCollection(); _strings = new List <string>(); _patterns = new List <string>(); }
public LeagueHashCollection ResolveConflicts(LeagueHashCollection hashCollection) { var result = new LeagueHashCollection(); foreach (var hash in hashCollection.Hashes) { var sections = hash.Value; if (sections.Count > 1) { sections = ResolveConflicts(sections); } result.Hashes.Add(hash.Key, sections); } return(result); }
public void DraftMatch() { var map = new LeagueHashCollection(); Console.WriteLine("Starting count: " + _draft.Hashes.Count); foreach (var hash in _draft.Hashes) { if (_hashes.Contains(hash.Key)) { map.Hashes.Add(hash.Key, hash.Value); } } Console.WriteLine("End count: " + map.Hashes.Count); _draft = map; }
public void ImportDraftStrings(LeagueHashCollection col) { foreach (var hash in col.Hashes) { foreach (var section in hash.Value) { if (!_strings.Contains(section.Key, StringComparer.OrdinalIgnoreCase)) { _strings.Add(section.Key); } foreach (var name in section.Value) { if (!_strings.Contains(name, StringComparer.OrdinalIgnoreCase)) { _strings.Add(name); } } } } }
public void HashStrings() { var hashForcer = new HashForcer(true); hashForcer.SetHashes(_hashes); hashForcer.SetSources(_strings); hashForcer.Run(Environment.ProcessorCount); hashForcer.WaitFinish(); var mapping = new LeagueHashCollection(hashForcer.GetResult()); var result = new LeagueHashCollection(); foreach (var hash in mapping.Hashes) { var sectionFilterer = new SectionFilterer(hash.Value); sectionFilterer.ApplyFilter(new FilterPlaintextSections()); sectionFilterer.ApplyFilter(new FilterDuplicateSections()); sectionFilterer.ApplyFilter(new FilterPlaintextKeys()); result.Hashes.Add(hash.Key, sectionFilterer.CurrentSections); } _draft = result; }