Skip to content

Commit

Permalink
Tweaks for Codacy (#326) #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Sep 22, 2021
1 parent 5803ac5 commit 35e78da
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
7 changes: 4 additions & 3 deletions ImperatorToCK3/Imperator/Countries/CountryFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ static Country() {
var governmentStr = ParserHelpers.GetString(reader);
country.Government = governmentStr;
// set government type
if (monarchyGovernments.Contains(governmentStr))
if (monarchyGovernments.Contains(governmentStr)) {
country.GovernmentType = GovernmentType.monarchy;
else if (republicGovernments.Contains(governmentStr))
} else if (republicGovernments.Contains(governmentStr)) {
country.GovernmentType = GovernmentType.republic;
else if (tribalGovernments.Contains(governmentStr))
} else if (tribalGovernments.Contains(governmentStr)) {
country.GovernmentType = GovernmentType.tribal;
}
});
parser.RegisterKeyword("family", reader =>
country.Families.Add(ParserHelpers.GetULong(reader), null)
Expand Down
62 changes: 31 additions & 31 deletions ImperatorToCK3/Mappers/CoA/CoaMapper.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
using System.Collections.Generic;
using commonItems;
using commonItems;
using System.Collections.Generic;
using System.IO;

namespace ImperatorToCK3.Mappers.CoA {
public class CoaMapper : Parser {
public CoaMapper(Configuration theConfiguration) {
var coasPath = Path.Combine(theConfiguration.ImperatorPath, "game", "common", "coat_of_arms", "coat_of_arms");
var fileNames = SystemUtils.GetAllFilesInFolderRecursive(coasPath);
Logger.Info("Parsing CoAs.");
RegisterKeys();
foreach (var fileName in fileNames) {
ParseFile(Path.Combine(coasPath, fileName));
}
ClearRegisteredRules();
Logger.Info("Loaded " + coasMap.Count + " coats of arms.");
}
public CoaMapper(string coaFilePath) {
RegisterKeys();
ParseFile(coaFilePath);
ClearRegisteredRules();
}
private void RegisterKeys() {
RegisterKeyword("template", ParserHelpers.IgnoreItem); // we don't need templates, we need CoAs!
RegisterRegex(CommonRegexes.Catchall, (reader, flagName) => {
coasMap.Add(flagName, new StringOfItem(reader).String);
});
}
public class CoaMapper : Parser {
public CoaMapper(Configuration theConfiguration) {
var coasPath = Path.Combine(theConfiguration.ImperatorPath, "game", "common", "coat_of_arms", "coat_of_arms");
var fileNames = SystemUtils.GetAllFilesInFolderRecursive(coasPath);
Logger.Info("Parsing CoAs.");
RegisterKeys();
foreach (var fileName in fileNames) {
ParseFile(Path.Combine(coasPath, fileName));
}
ClearRegisteredRules();
Logger.Info("Loaded " + coasMap.Count + " coats of arms.");
}
public CoaMapper(string coaFilePath) {
RegisterKeys();
ParseFile(coaFilePath);
ClearRegisteredRules();
}
private void RegisterKeys() {
RegisterKeyword("template", ParserHelpers.IgnoreItem); // we don't need templates, we need CoAs!
RegisterRegex(CommonRegexes.Catchall, (reader, flagName) => {
coasMap.Add(flagName, new StringOfItem(reader).String);
});
}

public string? GetCoaForFlagName(string impFlagName) {
bool contains = coasMap.TryGetValue(impFlagName, out string? value);
return contains ? value : null;
}
public string? GetCoaForFlagName(string impFlagName) {
bool contains = coasMap.TryGetValue(impFlagName, out string? value);
return contains ? value : null;
}

private Dictionary<string, string> coasMap = new();
}
private readonly Dictionary<string, string> coasMap = new();
}
}

0 comments on commit 35e78da

Please sign in to comment.