Skip to content

Commit

Permalink
Don't require I:R character DNA string to have exactly 552 characters (
Browse files Browse the repository at this point in the history
…#1683) #patch
  • Loading branch information
IhateTrains authored Jan 2, 2024
1 parent 758480d commit 25febe6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class CharacterTests {
private readonly GenesDB genesDB = new();
[Fact]
public void FieldsCanBeSet() {
var dnaStr = "AAAAAAAAAAAAAAAAAH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==";
var reader = new BufferedReader(
"= {" +
"\tcountry=69" +
Expand Down Expand Up @@ -48,7 +49,7 @@ public void FieldsCanBeSet() {
"\t}\n" +
"\tnickname = \"the Great\"\n" +
"\tattributes={ martial=1 finesse=2 charisma=3 zeal=4 }" +
"\tdna=\"paradoxianDna\"" +
"\tdna=\"" + dnaStr + "\"" +
"\tage=56\n" +
"\tprovince=69" +
"\tprisoner_home=68" +
Expand Down Expand Up @@ -156,7 +157,7 @@ public void FieldsCanBeSet() {
Assert.Equal(2, character.Attributes.Finesse);
Assert.Equal(3, character.Attributes.Charisma);
Assert.Equal(4, character.Attributes.Zeal);
Assert.Equal("paradoxianDna", character.DNA);
Assert.Equal(dnaStr, character.DNA);
Assert.Equal((uint)56, character.Age);
Assert.Equal((ulong)69, character.ProvinceId);
}
Expand Down Expand Up @@ -205,10 +206,10 @@ public void CultureCanBeInheritedFromFamily() {
}

[Fact]
public void PortraitDataIsNotExtractedFromDnaOfWrongLength() {
public void PortraitDataIsNotExtractedFromEmptyDNAString() {
var reader = new BufferedReader(
// ReSharper disable once StringLiteralTypo
"={dna=\"AAAAAAAAAAAAAAAAAH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/AH8AfwB/==\"}"
"={dna=\"\"}"
);
var character = ImperatorToCK3.Imperator.Characters.Character.Parse(reader, "42", genesDB);
Assert.Null(character.PortraitData);
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/Characters/DNAFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public DNA GenerateDNA(Imperator.Characters.Character irCharacter, PortraitData
IntSliderValueRecessive = 128
});
}

return new DNA(id, colorDNAValues, morphDNAValues, accessoryDNAValues);
}

Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Imperator/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static Character Parse(BufferedReader reader, string idString, GenesDB? g
parser.ParseStream(reader);
if (genesDB is null) {
Logger.Warn($"GenesDB is null when parsing character {idString}!");
} else if (parsedCharacter.DNA?.Length == 552) {
} else if (parsedCharacter.DNA?.Length > 0) {
parsedCharacter.PortraitData = new PortraitData(parsedCharacter.DNA, genesDB, parsedCharacter.AgeSex);
}

Expand Down

0 comments on commit 25febe6

Please sign in to comment.