Skip to content

Commit

Permalink
Remove redundant CultureMappingRule constructor (#320) #patch
Browse files Browse the repository at this point in the history
* Fix text file copying on publish

* Remove redundant CultureMappingRule constructor
  • Loading branch information
IhateTrains authored Sep 19, 2021
1 parent fc1576a commit ae2e7fc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
2 changes: 2 additions & 0 deletions ImperatorToCK3/ImperatorToCK3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
</Target>

<Target Name="CopyCustomContentOnPublish" AfterTargets="Publish">
<Copy SourceFiles="@(FronterConfigurationFiles)" DestinationFolder="$(PublishDir)/../Configuration" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(Configurables)" DestinationFolder="$(PublishDir)/configurables" SkipUnchangedFiles="true" />
<Copy SourceFiles="@(ConverterGlobals)" DestinationFolder="$(PublishDir)/.." SkipUnchangedFiles="true" />
<Copy SourceFiles="@(BlankMod)" DestinationFolder="$(PublishDir)\blankMod\%(RecursiveDir)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Retries="3" RetryDelayMilliseconds="300" />
</Target>

Expand Down
65 changes: 33 additions & 32 deletions ImperatorToCK3/Mappers/Culture/CultureMappingRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,6 @@

namespace ImperatorToCK3.Mappers.Culture {
public class CultureMappingRule {
public CultureMappingRule() { }
private static readonly Parser parser = new();
private static CultureMappingRule mappingToReturn = new();
static CultureMappingRule() {
parser.RegisterKeyword("ck3", reader => {
mappingToReturn.destinationCulture = ParserHelpers.GetString(reader);
});
parser.RegisterKeyword("imp", reader => {
mappingToReturn.cultures.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("religion", reader => {
mappingToReturn.religions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("owner", reader => {
mappingToReturn.owners.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("ck3Region", reader => {
mappingToReturn.ck3Regions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("impRegion", reader => {
mappingToReturn.imperatorRegions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("ck3Province", reader => {
mappingToReturn.ck3Provinces.Add(ParserHelpers.GetULong(reader));
});
parser.RegisterKeyword("impProvince", reader => {
mappingToReturn.imperatorProvinces.Add(ParserHelpers.GetULong(reader));
});
parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
}
public static CultureMappingRule Parse(BufferedReader reader) {
mappingToReturn = new CultureMappingRule();
parser.ParseStream(reader);
Expand Down Expand Up @@ -123,11 +93,12 @@ string CK3ownerTitle
ulong ck3ProvinceID,
ulong impProvinceID,
string CK3ownerTitle
) {
) {
// This is a non religious match. We need a mapping without any religion, so if the
// mapping rule has any religious qualifiers it needs to fail.
if (religions.Count > 0)
if (religions.Count > 0) {
return null;
}

// Otherwise, as usual.
return Match(impCulture, CK3religion, ck3ProvinceID, impProvinceID, CK3ownerTitle);
Expand All @@ -141,5 +112,35 @@ string CK3ownerTitle
private readonly SortedSet<ulong> ck3Provinces = new();
private readonly SortedSet<string> imperatorRegions = new();
private readonly SortedSet<string> ck3Regions = new();

static CultureMappingRule() {
parser.RegisterKeyword("ck3", reader => {
mappingToReturn.destinationCulture = ParserHelpers.GetString(reader);
});
parser.RegisterKeyword("imp", reader => {
mappingToReturn.cultures.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("religion", reader => {
mappingToReturn.religions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("owner", reader => {
mappingToReturn.owners.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("ck3Region", reader => {
mappingToReturn.ck3Regions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("impRegion", reader => {
mappingToReturn.imperatorRegions.Add(ParserHelpers.GetString(reader));
});
parser.RegisterKeyword("ck3Province", reader => {
mappingToReturn.ck3Provinces.Add(ParserHelpers.GetULong(reader));
});
parser.RegisterKeyword("impProvince", reader => {
mappingToReturn.imperatorProvinces.Add(ParserHelpers.GetULong(reader));
});
parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
}
private static readonly Parser parser = new();
private static CultureMappingRule mappingToReturn = new();
}
}

0 comments on commit ae2e7fc

Please sign in to comment.