public static CardTextCollection ExtractGameData(string ArtifactDir, List <int> sets, Dictionary <string, int> VOMapping) { List <string> LoreFilenames = new List <string>(); List <string> VOFilenames = new List <string>(); List <string> CardFilenames = new List <string>(); foreach (int set in sets) { string setNum = set.ToString("00"); LoreFilenames.Add(Path.Combine(ArtifactDir, $"game/dcg/panorama/localization/dcg_lore_set_{setNum}_english.txt")); CardFilenames.Add(Path.Combine(ArtifactDir, $"game/dcg/resource/card_set_{setNum}_english.txt")); if (set != 0) { VOFilenames.Add(Path.Combine(ArtifactDir, $"game/dcg/panorama/localization/dcg_vo_set_{setNum}_english.txt")); } } CardTextCollection collection = new CardTextCollection(); foreach (string filename in LoreFilenames) { if (File.Exists(filename)) { Console.WriteLine($"Loading {filename}..."); string text = File.ReadAllText(filename); Console.WriteLine("Loading complete. Parsing..."); collection.ParseLoreSet(text); Console.WriteLine("Done."); } else { Console.WriteLine($"Filename {filename} doesn't exist!"); } } foreach (string filename in VOFilenames) { if (File.Exists(filename)) { Console.WriteLine($"Loading {filename}..."); string text = File.ReadAllText(filename); Console.WriteLine("Loading complete. Parsing..."); collection.ParseVOSet(text, VOMapping); Console.WriteLine("Done."); } else { Console.WriteLine($"Filename {filename} doesn't exist!"); } } foreach (string filename in CardFilenames) { if (File.Exists(filename)) { Console.WriteLine($"Loading {filename}..."); string text = File.ReadAllText(filename); Console.WriteLine("Loading complete. Parsing..."); collection.ParseCardSet(text); Console.WriteLine("Done."); } else { Console.WriteLine($"Filename {filename} doesn't exist!"); } } return(collection); }
static void Main(string[] args) { string configLocation = Path.GetFullPath("./config.json"); Config config = LoadConfig(configLocation); string cardCache = ""; Dictionary <int, WikiSet> Sets = null; Dictionary <int, WikiCard> Cards = null; ValveAPIResponseCollection ValveData = null; CardTextCollection GameFileInfo = null; Dictionary <string, int> VOMapping = null; try { string command = null; bool exit = false; while (!exit) { switch (command) { case "valve": ValveData = DownloadValveDefinitions(config.ValveAPIBaseURL, config.ValveCacheLocation); if (Sets == null || Cards == null) { (Sets, Cards) = ConvertValveCardsToWikiCards(ValveData); } break; case "save": if (ValveData == null) { ValveData = DownloadValveDefinitions(config.ValveAPIBaseURL, config.ValveCacheLocation); } DownloadCardImages(ValveData, config.APIImagesLocation); break; case "clear": break; case "load": if (ValveData == null) { ValveData = DownloadValveDefinitions(config.ValveAPIBaseURL, config.ValveCacheLocation); } if (Sets == null || Cards == null) { (Sets, Cards) = ConvertValveCardsToWikiCards(ValveData); } VOMapping = MapCardIDsToVONames(config.ArtifactBaseDir, Sets.Keys.ToList()); ExtractGameData(config.ArtifactBaseDir, Sets.Keys.ToList(), VOMapping); break; case "merge": break; case "extract": ExtractRawCardImages(config.ArtifactBaseDir, config.GameImagesLocation, config.GameImageFormat); break; case "exit": exit = true; break; case null: break; default: Console.WriteLine("Command not recognized. Please try again."); break; } Console.WriteLine("\n\n\nPlease enter one of the following options:\n\n"); Console.WriteLine("valve - retrieve complete card definitions from the official Valve API."); Console.WriteLine("save - retrieve card images from the official Valve API that are not cached."); Console.WriteLine("clear - delete all cached card API images."); Console.WriteLine("load - read card/lore/voiceover data from game files at the configured Artifact game path."); Console.WriteLine("merge - combine card info from the game data at the configured Artifact game path with official API data."); Console.WriteLine("extract - [WARNING: MEMORY HEAVY] extract card images from the game data at the configured Artifact game path."); Console.WriteLine("upload - push all extracted game images and cached API card images to the configured wiki."); Console.WriteLine("backup - download all existing wiki card articles prior to overwriting them."); Console.WriteLine("update - edit or create all card articles with the latest and greatest card info."); Console.WriteLine("exit - exit\n"); command = Console.ReadLine().ToLower(); } } catch (Exception e) { Console.WriteLine($"\n\n\n\n\nERROR\n\nAn exception was encountered while running Artificer. Please provide the following to the maintainer of the bot:\n\n{e.ToString()}"); } Console.WriteLine("\n\n\n\n\nPress Enter to continue..."); Console.Read(); }