/// <summary> /// Tries to regenerate the <see cref="pk"/> into a valid pkm. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="pk">Currently invalid pkm data</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM Legalize(this ITrainerInfo tr, PKM pk) { var set = new RegenTemplate(pk) { Ball = (Ball)pk.Ball, ShinyType = pk.ShinyXor == 0 ? Shiny.AlwaysSquare : pk.IsShiny ? Shiny.AlwaysStar : Shiny.Never }; return(tr.GetLegalFromTemplate(pk, set, out _)); }
/// <summary> /// API Legality /// </summary> /// <param name="tr">trainer data</param> /// <param name="set">showdown set to legalize from</param> /// <param name="template">pkm file to legalize</param> /// <param name="pkm">legalized pkm file</param> /// <returns>bool if the pokemon was legalized</returns> public static bool TryAPIConvert(this ITrainerInfo tr, IBattleTemplate set, PKM template, out PKM pkm) { pkm = tr.GetLegalFromTemplate(template, set, out bool satisfied); if (!satisfied) { return(false); } var trainer = TrainerSettings.GetSavedTrainerData(pkm, tr); pkm.SetAllTrainerData(trainer); return(true); }
/// <summary> /// Tries to regenerate the <see cref="pk"/> into a valid pkm. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="pk">Currently invalid pkm data</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM Legalize(this ITrainerInfo tr, PKM pk) { var set = new ShowdownSet(ShowdownSet.GetShowdownText(pk)); var legal = tr.GetLegalFromTemplate(pk, set, out var satisfied); if (satisfied) { return(legal); } var dest = new PokeTrainerDetails(pk.Clone()); var resetForm = ShowdownUtil.IsInvalidForm(set.Form); legal = BruteForce.ApplyDetails(pk, set, resetForm, dest); legal.SetTrainerData(dest); return(legal); }
/// <summary> /// Tries to regenerate the <see cref="pk"/> into a valid pkm. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="pk">Currently invalid pkm data</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM Legalize(this ITrainerInfo tr, PKM pk) { var set = new RegenTemplate(pk) { Ball = (Ball)pk.Ball, ShinyType = pk.ShinyXor == 0 ? Shiny.AlwaysSquare : pk.IsShiny ? Shiny.AlwaysStar : Shiny.Never }; var legal = tr.GetLegalFromTemplate(pk, set, out var satisfied); if (satisfied) { return(legal); } var dest = new PokeTrainerDetails(pk.Clone()); var resetForm = ShowdownUtil.IsInvalidForm(set.Form); legal = BruteForce.ApplyDetails(pk, set, resetForm, dest); legal.SetTrainerData(dest); return(legal); }
/// <summary> /// Tries to regenerate the <see cref="pk"/> into a valid pkm. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="pk">Currently invalid pkm data</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM Legalize(this ITrainerInfo tr, PKM pk) { var set = new RegenTemplate(pk, tr.Generation); return(tr.GetLegalFromTemplate(pk, set, out _)); }