mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-26 02:18:40 -05:00
Add overloads to get localized showdown sets
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.Species;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
@@ -154,8 +153,29 @@ public static string GetShowdownText(PKM pk)
|
||||
/// Fetches ShowdownSet lines from the input <see cref="PKM"/> data.
|
||||
/// </summary>
|
||||
/// <param name="data">Pokémon data to summarize.</param>
|
||||
/// <param name="lang">Localization setting</param>
|
||||
/// <returns>Consumable list of <see cref="ShowdownSet.Text"/> lines.</returns>
|
||||
public static IEnumerable<string> GetShowdownSets(IEnumerable<PKM> data) => data.Where(p => p.Species != 0).Select(GetShowdownText);
|
||||
public static IEnumerable<string> GetShowdownText(IEnumerable<PKM> data, string lang = ShowdownSet.DefaultLanguage)
|
||||
{
|
||||
var sets = GetShowdownSets(data);
|
||||
foreach (var set in sets)
|
||||
yield return set.LocalizedText(lang);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches ShowdownSet lines from the input <see cref="PKM"/> data.
|
||||
/// </summary>
|
||||
/// <param name="data">Pokémon data to summarize.</param>
|
||||
/// <returns>Consumable list of <see cref="ShowdownSet.Text"/> lines.</returns>
|
||||
public static IEnumerable<ShowdownSet> GetShowdownSets(IEnumerable<PKM> data)
|
||||
{
|
||||
foreach (var pk in data)
|
||||
{
|
||||
if (pk.Species == 0)
|
||||
continue;
|
||||
yield return new ShowdownSet(pk);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fetches ShowdownSet lines from the input <see cref="PKM"/> data, and combines it into one string.
|
||||
@@ -163,7 +183,7 @@ public static string GetShowdownText(PKM pk)
|
||||
/// <param name="data">Pokémon data to summarize.</param>
|
||||
/// <param name="separator">Splitter between each set.</param>
|
||||
/// <returns>Single string containing all <see cref="ShowdownSet.Text"/> lines.</returns>
|
||||
public static string GetShowdownSets(IEnumerable<PKM> data, string separator) => string.Join(separator, GetShowdownSets(data));
|
||||
public static string GetShowdownSets(IEnumerable<PKM> data, string separator) => string.Join(separator, GetShowdownText(data));
|
||||
|
||||
/// <summary>
|
||||
/// Gets a localized string preview of the provided <see cref="pk"/>.
|
||||
|
||||
@@ -17,7 +17,8 @@ public sealed class ShowdownSet : IBattleTemplate
|
||||
private static readonly char[] ParenJunk = { '(', ')', '[', ']' };
|
||||
private static readonly ushort[] DashedSpecies = {782, 783, 784, 250, 032, 029}; // Kommo-o, Ho-Oh, Nidoran-M, Nidoran-F
|
||||
private const int MAX_SPECIES = (int)MAX_COUNT - 1;
|
||||
private static readonly GameStrings DefaultStrings = GameInfo.GetStrings(GameLanguage.DefaultLanguage);
|
||||
internal const string DefaultLanguage = GameLanguage.DefaultLanguage;
|
||||
private static readonly GameStrings DefaultStrings = GameInfo.GetStrings(DefaultLanguage);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int Species { get; private set; } = -1;
|
||||
@@ -247,7 +248,7 @@ private bool ParseDynamax(string value)
|
||||
/// Gets the localized Text representation of the set details.
|
||||
/// </summary>
|
||||
/// <param name="lang">2 character language code</param>
|
||||
public string LocalizedText(string lang) => LocalizedText(GameLanguage.GetLanguageIndex(lang));
|
||||
public string LocalizedText(string lang = DefaultLanguage) => LocalizedText(GameLanguage.GetLanguageIndex(lang));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the localized Text representation of the set details.
|
||||
|
||||
Reference in New Issue
Block a user