public BaseGameReader(string exePath) { BaseFolder = exePath.Replace("hoi4.exe", ""); MapFolder = BaseFolder + "map\\"; CommonFolder = BaseFolder + "common\\"; FlagFolder = BaseFolder + "gfx\\flags\\"; BaseGame = this; LocalisationLookup = new Dictionary <string, string>(); string localisationFolder = BaseFolder + "localisation\\"; ReadLocalisationFile(localisationFolder + "strategic_region_names_l_english.yml"); ReadLocalisationFile(localisationFolder + "state_names_l_english.yml"); ReadLocalisationFile(localisationFolder + "countries_l_english.yml"); ReadLocalisationFile(localisationFolder + "parties_l_english.yml"); StateCategoryLookup = new Dictionary <string, StateCategory>(); foreach (string file in Directory.GetFiles(BaseFolder + "common/state_category/")) { StateCategory newStateCategory = TextParser.CreateStateCategory(file); StateCategoryLookup.Add(newStateCategory.Tag, newStateCategory); Console.WriteLine(newStateCategory.Tag + ": " + newStateCategory.BuildingSlots.ToString()); } ReadProvinceFile(); }
private State(int id) { this.id = id; LocaleKey = $"STATE_{id}"; fileName = ""; name = ""; buildFactor = 1; category = StateCategory.Wasteland; manpower = 0; resources = new ResourceSet(); owner = ""; cores = new HashSet <string>(); provinces = new HashSet <Province>(); infrastructure = 0; militaryFactories = 0; civillianFactories = 0; dockyards = 0; refineries = 0; silos = 0; antiair = 0; reactors = 0; airbases = 0; rockets = 0; radar = 0; impassable = false; }
public static string ConvertStateCategory(this StateCategory c) { return(c switch { StateCategory.Wasteland => "wasteland", StateCategory.Tiny_Island => "tiny_island", StateCategory.Enclave => "enclave", StateCategory.Pastoral => "pastoral", StateCategory.Small_Island => "small_island", StateCategory.Rural => "rural", StateCategory.Town => "town", StateCategory.Large_Town => "large_town", StateCategory.City => "city", StateCategory.Large_City => "large_city", StateCategory.Metropolis => "metropolis", StateCategory.Megalopolis => "megalopolis", _ => null, });
public static StateCategory CreateStateCategory(string file) { StateCategory newStateCat = new StateCategory(); StreamReader sr = new StreamReader(file); string stateCategoryText = GetContentsOfBrackets(sr.ReadToEnd(), "state_categories"); sr.Close(); string tag = stateCategoryText.Split('=')[0].Trim(); string name = tag; string typeText = GetContentsOfBrackets(stateCategoryText, tag); int buildingSlots = Convert.ToInt16(getVariable(typeText, "local_building_slots")); newStateCat.Tag = tag; newStateCat.Name = name; newStateCat.BuildingSlots = buildingSlots; return(newStateCat); }
public override Task <AllStateCategoryTypesResponse> GetAllStateProductCategories( AllStateCategoryTypesRequest request, ServerCallContext context) { AllStateCategoryTypesResponse response; using (var priceContext = new pricecompContext()) { // var categories = priceContext.Stateassignment.ToList(); var categories = from sm in priceContext.Stateassignment select new { Id = sm.Id, Category = sm.Category, State = sm.State }; RepeatedField <StateCategory> categoryDaily = new RepeatedField <StateCategory>(); RepeatedField <StateCategory> categoryMondayAndThursday = new RepeatedField <StateCategory>(); RepeatedField <StateCategory> categoryTuesdayAndFriday = new RepeatedField <StateCategory>(); RepeatedField <StateCategory> categoryWednesdayAndSaturday = new RepeatedField <StateCategory>(); RepeatedField <StateCategory> categoryUnassigned = new RepeatedField <StateCategory>(); foreach (var category in categories) { StateCategory categoryItem = new StateCategory() { Id = category.Id, Name = category.Category, Category = category.State }; int index = Int32.Parse(category.State.Substring(0, 1)); switch (index) { case 0: { categoryDaily.Add(categoryItem); break; } case 1: { categoryMondayAndThursday.Add(categoryItem); break; } case 2: { categoryTuesdayAndFriday.Add(categoryItem); break; } case 3: { categoryWednesdayAndSaturday.Add(categoryItem); break; } default: { categoryUnassigned.Add(categoryItem); break; } } } response = new AllStateCategoryTypesResponse() { CategoryDaily = { categoryDaily }, CategoryMondayAndThursday = { categoryMondayAndThursday }, CategoryTuesdayAndFriday = { categoryTuesdayAndFriday }, CategoryWednesdayAndSaturday = { categoryWednesdayAndSaturday }, CategoryUnassigned = { categoryUnassigned } }; } return(Task.FromResult(response)); }