namespace PKHeX.Core; /// /// Indicates or coerces values pertaining to and its branched evolutions. /// public static class WurmpleUtil { /// /// Gets the Wurmple Evolution Value for a given /// /// Encryption Constant /// Wurmple Evolution Value public static WurmpleEvolution GetWurmpleEvoVal(uint encryptionConstant) { var evoVal = encryptionConstant >> 16; return (WurmpleEvolution)(evoVal % 10 / 5); } /// /// Gets the evo chain of Wurmple /// /// Current species, must be evolved from Wurmple. public static WurmpleEvolution GetWurmpleEvoGroup(ushort species) { int wIndex = species - (int)Species.Silcoon; if ((wIndex & 3) != wIndex) // Wurmple evo, [0,3] return WurmpleEvolution.None; return (WurmpleEvolution)(wIndex >> 1); // Silcoon, Cascoon } /// /// Gets the Wurmple for a given Evolution Value /// /// Wurmple Evolution Value /// 0 = Silcoon, 1 = Cascoon /// Encryption Constant public static uint GetWurmpleEncryptionConstant(WurmpleEvolution evoVal) { uint result; var rnd = Util.Rand; do result = rnd.Rand32(); while (evoVal != GetWurmpleEvoVal(result)); return result; } /// /// Checks to see if the input , with species being that of Wurmple's evo chain, is valid. /// /// Pokémon data /// True if valid, false if invalid public static bool IsWurmpleEvoValid(PKM pk) { var evoVal = GetWurmpleEvoVal(pk.EncryptionConstant); var wIndex = GetWurmpleEvoGroup(pk.Species); return evoVal == wIndex; } } /// /// Indicates the evolution of Wurmple /// public enum WurmpleEvolution { /// Invalid value None = -1, /// Evolves into Silcoon/Beautifly Silcoon = 0, /// Evolves into Cascoon/Dustox Cascoon = 1, }