public static PKM GetLegal(this ITrainerInfo sav, ShowdownSet set, out string res) { var result = sav.GetLegalFromSet(set, out var type); res = type.ToString(); return(result); }
public static PKM GetLegal(this ITrainerInfo sav, IBattleTemplate set, out string res) { var result = sav.GetLegalFromSet(set, out var type); res = type.ToString(); return(result); }
/// <summary> /// Imports a <see cref="set"/> to create a new <see cref="PKM"/> with a context of <see cref="tr"/>. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="set">Set data to import</param> /// <param name="msg">Result code indicating success or failure</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM GetLegalFromSet(this ITrainerInfo tr, IBattleTemplate set, out LegalizationResult msg) { var template = PKMConverter.GetBlank(tr.Generation, (GameVersion)tr.Game); template.ApplySetDetails(set); return(tr.GetLegalFromSet(set, template, out msg)); }
/// <summary> /// Imports a <see cref="set"/> to create a new <see cref="PKM"/> with a context of <see cref="tr"/>. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="set">Set data to import</param> /// <param name="msg">Result code indicating success or failure</param> /// <param name="allowAPI">Use <see cref="Core"/> to find and generate a new pkm</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM GetLegalFromSet(this ITrainerInfo tr, ShowdownSet set, out LegalizationResult msg, bool allowAPI = true) { var template = PKMConverter.GetBlank(tr.Generation, (GameVersion)tr.Game); template.ApplySetDetails(set); return(tr.GetLegalFromSet(set, template, out msg, allowAPI)); }
/// <summary> /// Imports a <see cref="set"/> to create a new <see cref="PKM"/> with a context of <see cref="tr"/>. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="set">Set data to import</param> /// <param name="msg">Result code indicating success or failure</param> /// <returns>Legalized PKM (hopefully legal)</returns> public static PKM GetLegalFromSet(this ITrainerInfo tr, IBattleTemplate set, out LegalizationResult msg) { var template = EntityBlank.GetBlank(tr); if (template.Version == 0) { template.Version = tr.Game; } template.ApplySetDetails(set); return(tr.GetLegalFromSet(set, template, out msg)); }
public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel channel, ITrainerInfo sav, ShowdownSet set) { if (set.Species <= 0) { await channel.SendMessageAsync("Oops! I wasn't able to interpret your message! If you intended to convert something, please double check what you're pasting!").ConfigureAwait(false); return; } var pkm = sav.GetLegalFromSet(set, out var result); var la = new LegalityAnalysis(pkm); var spec = GameInfo.Strings.Species[set.Species]; var msg = la.Valid ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!" : $"Oops! I wasn't able to create something from that. Here's my best attempt for that {spec}!"; await channel.SendPKMAsync(pkm, msg + $"\n{ReusableActions.GetFormattedShowdownText(pkm)}").ConfigureAwait(false); }
/// <summary> /// Imports <see cref="sets"/> to a provided <see cref="arr"/>, with a context of <see cref="tr"/>. /// </summary> /// <param name="tr">Source/Destination trainer</param> /// <param name="sets">Set data to import</param> /// <param name="arr">Current list of data to write to</param> /// <param name="start">Starting offset to place converted details</param> /// <param name="overwrite">Overwrite</param> /// <returns>Result code indicating success or failure</returns> public static AutoModErrorCode ImportToExisting(this ITrainerInfo tr, IReadOnlyList <ShowdownSet> sets, IList <PKM> arr, int start = 0, bool overwrite = true) { var emptySlots = overwrite ? Enumerable.Range(start, sets.Count).ToList() : FindAllEmptySlots(arr, start); if (emptySlots.Count < sets.Count) { return(AutoModErrorCode.NotEnoughSpace); } var generated = 0; var invalidAPISets = new List <ShowdownSet>(); for (int i = 0; i < sets.Count; i++) { var set = sets[i]; if (set.InvalidLines.Count > 0) { return(AutoModErrorCode.InvalidLines); } Debug.WriteLine($"Generating Set: {GameInfo.Strings.Species[set.Species]}"); var pk = tr.GetLegalFromSet(set, out var msg); pk.ResetPartyStats(); if (msg == LegalizationResult.BruteForce) { invalidAPISets.Add(set); } arr[emptySlots[i]] = pk; generated++; } Debug.WriteLine($"API Genned Sets: {generated - invalidAPISets.Count}/{generated}, {invalidAPISets.Count} were not."); foreach (var set in invalidAPISets) { Debug.WriteLine(set.Text); } return(AutoModErrorCode.None); }