コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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;
        }