/// <summary> /// Sets the <see cref="PKM"/> property to a non-specific smart value. /// </summary> /// <param name="pk">Pokémon to modify.</param> /// <param name="cmd">Modification</param> /// <returns>True if modified, false if no modifications done.</returns> private static bool SetComplexProperty(PKM pk, StringInstruction cmd) { DateTime parseDate(string val) => DateTime.ParseExact(val, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); if (cmd.PropertyName == nameof(PKM.MetDate)) { pk.MetDate = parseDate(cmd.PropertyValue); } else if (cmd.PropertyName == nameof(PKM.EggMetDate)) { pk.EggMetDate = parseDate(cmd.PropertyValue); } else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == CONST_RAND) { pk.EncryptionConstant = Util.Rand32(); } else if ((cmd.PropertyName == nameof(PKM.Ability) || cmd.PropertyName == nameof(PKM.AbilityNumber)) && cmd.PropertyValue.StartsWith("$")) { pk.RefreshAbility(Convert.ToInt16(cmd.PropertyValue[1]) - 0x30); } else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue == CONST_RAND) { pk.SetPIDGender(pk.Gender); } else if (cmd.PropertyName == nameof(PKM.EncryptionConstant) && cmd.PropertyValue == nameof(PKM.PID)) { pk.EncryptionConstant = pk.PID; } else if (cmd.PropertyName == nameof(PKM.PID) && cmd.PropertyValue == CONST_SHINY) { pk.SetShiny(); } else if (cmd.PropertyName == nameof(PKM.Species) && cmd.PropertyValue == "0") { pk.Data = new byte[pk.Data.Length]; } else if (cmd.PropertyName.StartsWith("IV") && cmd.PropertyValue == CONST_RAND) { SetRandomIVs(pk, cmd); } else if (cmd.PropertyName == nameof(PKM.IsNicknamed) && string.Equals(cmd.PropertyValue, "false", StringComparison.OrdinalIgnoreCase)) { pk.SetDefaultNickname(); } else { return(false); } return(true); }