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 uint GetWurmpleEvoVal(uint encryptionConstant) { var evoVal = encryptionConstant >> 16; return evoVal % 10 / 5; } /// /// Gets the evo chain of Wurmple /// /// Current species /// -1 if not a Wurmple Evo, 0 if Silcoon chain, 1 if Cascoon chain public static int GetWurmpleEvoGroup(int species) { int wIndex = species - (int)Species.Silcoon; if ((wIndex & 3) != wIndex) // Wurmple evo, [0,3] return -1; return 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(int evoVal) { uint result; do result = Util.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 pkm) { uint evoVal = GetWurmpleEvoVal(pkm.EncryptionConstant); int wIndex = GetWurmpleEvoGroup(pkm.Species); return evoVal == wIndex; } } }