Skip to content

Commit

Permalink
Extract SetParsedProvinceRank (#1940) #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored May 8, 2024
1 parent 116d199 commit 3b2f47b
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions ImperatorToCK3/Imperator/Provinces/ProvinceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,7 @@ static Province() {
provinceParser.RegisterKeyword("civilization_value", reader =>
parsedProvince.CivilizationValue = reader.GetDouble()
);
provinceParser.RegisterKeyword("province_rank", reader => {
var provinceRankStr = reader.GetString();
switch (provinceRankStr) {
case "settlement":
parsedProvince.ProvinceRank = ProvinceRank.settlement;
break;
case "city":
parsedProvince.ProvinceRank = ProvinceRank.city;
break;
case "city_metropolis":
parsedProvince.ProvinceRank = ProvinceRank.city_metropolis;
break;
default:
Logger.Warn($"Unknown province rank for province {parsedProvince.Id}: {provinceRankStr}");
break;
}
});
provinceParser.RegisterKeyword("province_rank", SetParsedProvinceRank());
provinceParser.RegisterKeyword("fort", reader =>
parsedProvince.Fort = reader.GetBool()
);
Expand All @@ -71,6 +55,27 @@ static Province() {
});
provinceParser.IgnoreAndStoreUnregisteredItems(IgnoredTokens);
}

private static SimpleDel SetParsedProvinceRank() {
return reader => {
var provinceRankStr = reader.GetString();
switch (provinceRankStr) {
case "settlement":
parsedProvince.ProvinceRank = ProvinceRank.settlement;
break;
case "city":
parsedProvince.ProvinceRank = ProvinceRank.city;
break;
case "city_metropolis":
parsedProvince.ProvinceRank = ProvinceRank.city_metropolis;
break;
default:
Logger.Warn($"Unknown province rank for province {parsedProvince.Id}: {provinceRankStr}");
break;
}
};
}

public static Province Parse(BufferedReader reader, ulong provinceId, StateCollection states, CountryCollection countries) {
parsedStateId = null;
parsedOwnerId = null;
Expand Down

0 comments on commit 3b2f47b

Please sign in to comment.