Skip to content

Commit

Permalink
Don't throw exception on hairstyles missing from special CK3 genes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Oct 1, 2023
1 parent 68d8b6c commit 83b6d62
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions ImperatorToCK3/CK3/Characters/DNAFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,32 @@ public DNA GenerateDNA(Imperator.Characters.Character irCharacter, PortraitData
// Convert some accessory genes.
var accessoryDNAValues = new Dictionary<string, DNAGeneValue>();

var beardGeneValue = MatchAccessoryGeneValueByObject(
irCharacter,
irPortraitData,
"beards",
ck3GenesDB.SpecialAccessoryGenes["beards"]
);
if (beardGeneValue is not null) {
accessoryDNAValues.Add("beards", beardGeneValue.Value);
if (ck3GenesDB.SpecialAccessoryGenes.TryGetValue("beards", out var beardGene)) {
var beardGeneValue = MatchAccessoryGeneValueByObject(
irCharacter,
irPortraitData,
"beards",
beardGene
);
if (beardGeneValue is not null) {
accessoryDNAValues.Add("beards", beardGeneValue.Value);
}
} else {
Logger.Warn("beards not found in CK3 special accessory genes!");
}

var hairstylesGeneValue = MatchAccessoryGeneValueByObject(
irCharacter,
irPortraitData,
"hairstyles",
ck3GenesDB.SpecialAccessoryGenes["hairstyles"]
);
if (hairstylesGeneValue is not null) {
accessoryDNAValues.Add("hairstyles", hairstylesGeneValue.Value);
if (ck3GenesDB.SpecialAccessoryGenes.TryGetValue("hairstyles", out var hairstylesGene)) {
var hairstylesGeneValue = MatchAccessoryGeneValueByObject(
irCharacter,
irPortraitData,
"hairstyles",
hairstylesGene
);
if (hairstylesGeneValue is not null) {
accessoryDNAValues.Add("hairstyles", hairstylesGeneValue.Value);
}
} else {
Logger.Warn("hairstyles not found in CK3 special accessory genes!");
}

var clothesGeneValue = MatchAccessoryGeneValueByTemplate(irCharacter, irPortraitData, "clothes");
Expand Down

0 comments on commit 83b6d62

Please sign in to comment.