namespace PKHeX.Core { public static class WurmpleUtil { /// /// Gets the Wurmple Evolution Value for a given /// /// Encryption Constant /// Wurmple Evolution Value public static uint GetWurmpleEvoVal(uint EC) { var evoVal = EC >> 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 GetWurmpleEC(int evoVal) { uint EC; do EC = Util.Rand32(); while (evoVal != GetWurmpleEvoVal(EC)); return EC; } /// /// 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; } } }