From 69e519602bc13a2ec2bd6701f5828cca1f06422c Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 14 Dec 2025 00:31:34 -0600 Subject: [PATCH] Create SizePower9a.cs https: //x.com/Sibuna_Switch/status/2000090054371537099 Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com> --- .../Encounters/Templates/Gen9/SizePower9a.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 PKHeX.Core/Legality/Encounters/Templates/Gen9/SizePower9a.cs diff --git a/PKHeX.Core/Legality/Encounters/Templates/Gen9/SizePower9a.cs b/PKHeX.Core/Legality/Encounters/Templates/Gen9/SizePower9a.cs new file mode 100644 index 000000000..34b3b8f60 --- /dev/null +++ b/PKHeX.Core/Legality/Encounters/Templates/Gen9/SizePower9a.cs @@ -0,0 +1,56 @@ +using System; +using static PKHeX.Core.SizePower9a; + +namespace PKHeX.Core; + +public enum SizePower9a : byte +{ + Normal, + Teensy1, + Teensy2, + Teensy3, + Humungo1, + Humungo2, + Humungo3, +} + +public static class SizePower9aExtensions +{ + /// + /// Gets a random size value for the specified . + /// + /// Size Type + /// RNG to generate value with. + /// Size Value + /// + public static byte GetSizeValue(this SizePower9a type, ref Xoroshiro128Plus rand) => type switch + { + Normal => (byte)(rand.NextInt(0x81) + rand.NextInt(0x80)), // triangular distribution + Teensy1 => (byte)rand.NextInt(128), + Teensy2 => (byte)rand.NextInt(96), + Teensy3 => (byte)rand.NextInt(32), + Humungo1 => (byte)(rand.NextInt(128) + 128), + Humungo2 => (byte)(rand.NextInt(96) + 160), + Humungo3 => (byte)(rand.NextInt(32) + 224), + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; + + /// + /// Checks if the specified value is within the range of the . + /// + /// Size Type + /// Value to check + /// True if the value is within the range of the . + /// + public static bool IsWithinRange(this SizePower9a type, byte value) => type switch + { + Normal => true, + Teensy1 => value < 128, + Teensy2 => value < 96, + Teensy3 => value < 32, + Humungo1 => value >= 128, + Humungo2 => value >= 160, + Humungo3 => value >= 224, + _ => throw new ArgumentOutOfRangeException(nameof(type), type, null), + }; +}