예제 #1
0
        public async Task InitAsync(string baseDataUrl, string itemTableUrl)
        {
            string baseDataJsonString = await this.HttpClient.GetStringAsync(baseDataUrl);

            this.BaseData = BaseData.FromJson(baseDataJsonString);

            string itemTableJsonString = await this.HttpClient.GetStringAsync(itemTableUrl);

            this.ItemTable = ItemTable.FromJson(itemTableJsonString);
        }
예제 #2
0
        private static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.Unicode;

            if (args.Length < 1)
            {
                DisplayHelp();
                return;
            }

            string buildingDataJsonPath;

            if (args.Length >= 2)
            {
                buildingDataJsonPath = args[1];
            }
            else
            {
                buildingDataJsonPath = @"GameData\building_data.json";
            }

            try
            {
                var baseData = BaseData.FromJson(File.ReadAllText(buildingDataJsonPath));

                if (args[0] == "all")
                {
                    DisplayAllThemes(baseData.CustomData);
                    return;
                }

                if (!baseData.CustomData.Themes.TryGetValue(args[0], out Theme theme))
                {
                    Console.WriteLine("theme id not found");
                    Console.WriteLine("looking for theme by name");

                    theme = baseData.CustomData.Themes.Values.FirstOrDefault(t => t.Name.Contains(args[0], StringComparison.OrdinalIgnoreCase));
                    if (theme == null)
                    {
                        Console.WriteLine("theme name not found");
                        Console.WriteLine();
                        DisplayHelp();
                        return;
                    }
                }

                DisplayTheme(baseData.CustomData, theme);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine();
                DisplayHelp();
            }
        }
예제 #3
0
        private static void Main(string[] args)
        {
            string exportFolder;

            if (args.Length >= 1)
            {
                exportFolder = args[0];
            }
            else
            {
                exportFolder = Directory.GetCurrentDirectory();
            }

            string buildingDataJsonPath;

            if (args.Length >= 2)
            {
                buildingDataJsonPath = args[1];
            }
            else
            {
                buildingDataJsonPath = @"GameData\building_data.json";
            }

            try
            {
                Directory.CreateDirectory(exportFolder);
                var baseData   = BaseData.FromJson(File.ReadAllText(buildingDataJsonPath));
                var customData = baseData.CustomData;

                using var themesWriter = new StreamWriter(File.OpenWrite(Path.Combine(exportFolder, "themes.csv")));
                themesWriter.WriteCsvRow("Name", "Total Ambience", "Total Cost");
                foreach (var theme in customData.Themes.Values)
                {
                    themesWriter.WriteCsvRow(theme.Name, CalculateAmbience(customData, theme), CalculateCost(customData, theme));
                }

                using var setsWriter = new StreamWriter(File.OpenWrite(Path.Combine(exportFolder, "sets.csv")));
                setsWriter.WriteCsvRow("Name", "Ambience", "Total Ambience", "Total Cost");
                foreach (var group in customData.Groups.Values)
                {
                    var theme = customData.Themes[group.ThemeId];

                    setsWriter.WriteCsvRow(group.Name, group.Comfort, CalculateAmbience(customData, group), CalculateCost(customData, group));
                }

                using var furnituresWriter = new StreamWriter(File.OpenWrite(Path.Combine(exportFolder, "furnitures.csv")));
                furnituresWriter.WriteCsvRow("Name", "Set Name", "Theme Name", "Ambience", "Set Ambience", "Cost", "Location", "Rarity");
                foreach (var furniture in customData.Furnitures.Values)
                {
                    var set         = GetSet(customData, furniture);
                    var theme       = GetTheme(customData, furniture);
                    int setAmbience = set?.Comfort ?? 0;

                    furnituresWriter.WriteCsvRow(furniture.Name, set?.Name ?? "No Set", theme?.Name ?? "No Theme", furniture.Comfort, setAmbience, CalculateCost(furniture), furniture.Location, furniture.Rarity);
                }

                using var furnituresDumpWriter = new StreamWriter(File.OpenWrite(Path.Combine(exportFolder, "furnitures_dump.csv")));
                furnituresDumpWriter.WriteCsvRow("Name", "Location", "Type", "Category", "Rarity", "Ambience", "Cost");
                foreach (var furniture in customData.Furnitures.Values)
                {
                    furnituresDumpWriter.WriteCsvRow(furniture.Name, furniture.Location, furniture.Type, furniture.Category, furniture.Rarity, furniture.Comfort, CalculateCost(furniture));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine();
                DisplayHelp();
            }
        }