From 5879a4950f1cb71d40842c6de2404b66cab73844 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 17 Feb 2019 22:10:48 -0800 Subject: [PATCH] Use RandomGender logic from PKHeX --- pkNX.Structures/Personal/PersonalInfo.cs | 28 ++++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/pkNX.Structures/Personal/PersonalInfo.cs b/pkNX.Structures/Personal/PersonalInfo.cs index 6741cd35..3575c7eb 100644 --- a/pkNX.Structures/Personal/PersonalInfo.cs +++ b/pkNX.Structures/Personal/PersonalInfo.cs @@ -147,15 +147,29 @@ public int FormeIndex(int species, int forme) return FormStatsIndex + forme - 1; } + /// + /// Gets a random valid gender for the entry. + /// public int RandomGender() { - if (Genderless) - return 2; - if (OnlyFemale) - return 1; - if (OnlyMale) - return 0; - return Util.Rand.Next(2); + var fix = FixedGender; + return fix >= 0 ? fix : Util.Rand.Next(2); + } + + public bool IsDualGender => FixedGender < 0; + + public int FixedGender + { + get + { + if (Genderless) + return 2; + if (OnlyFemale) + return 1; + if (OnlyMale) + return 0; + return -1; + } } public bool Genderless => Gender == 255;