From 467045e95cbddae880fc23ec4c262f6a471dedfd Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 22 Jan 2020 19:04:20 -0800 Subject: [PATCH] Swap rand call order, rename as overload --- PKHeX.Core/MysteryGifts/WC8.cs | 4 ++-- PKHeX.Core/PKM/Shared/PokeSize.cs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PKHeX.Core/MysteryGifts/WC8.cs b/PKHeX.Core/MysteryGifts/WC8.cs index 727b5c96f..ec71b2604 100644 --- a/PKHeX.Core/MysteryGifts/WC8.cs +++ b/PKHeX.Core/MysteryGifts/WC8.cs @@ -390,8 +390,8 @@ public override PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria) SetEggMetData(pk); pk.CurrentFriendship = pk.IsEgg ? pi.HatchCycles : pi.BaseFriendship; - pk.HeightScalar = PokeSizeExtensions.GetRandomPokeSize(); - pk.WeightScalar = PokeSizeExtensions.GetRandomPokeSize(); + pk.HeightScalar = PokeSizeExtensions.GetRandomScalar(); + pk.WeightScalar = PokeSizeExtensions.GetRandomScalar(); pk.RefreshChecksum(); return pk; diff --git a/PKHeX.Core/PKM/Shared/PokeSize.cs b/PKHeX.Core/PKM/Shared/PokeSize.cs index 1fc7d6adc..06d41e5d1 100644 --- a/PKHeX.Core/PKM/Shared/PokeSize.cs +++ b/PKHeX.Core/PKM/Shared/PokeSize.cs @@ -38,10 +38,13 @@ public static int GetRandomScalar(this PokeSize size) PokeSize.AV => (Util.Rand.Next(0xA0) + 0x30), PokeSize.L => (Util.Rand.Next(0x20) + 0xD0), PokeSize.XL => (Util.Rand.Next(0x10) + 0xF0), - _ => GetRandomPokeSize() // Official code sums two randoms for triangular distribution. + _ => GetRandomScalar() }; } - public static int GetRandomPokeSize() => Util.Rand.Next(0x80) + Util.Rand.Next(0x81); + /// + /// Gets a random size scalar with a triangular distribution (copying official implementation). + /// + public static int GetRandomScalar() => Util.Rand.Next(0x81) + Util.Rand.Next(0x80); } } \ No newline at end of file