using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core
{
///
/// Miscellaneous setup utility for legality checking data sources.
///
internal static class EncounterUtil
{
///
/// Gets the relevant objects that appear in the relevant game.
///
/// Table of valid encounters that appear for the game pairing
/// Game to filter for
/// Array of encounter objects that can be encountered in the input game
internal static T[] GetEncounters(IEnumerable source, GameVersion game) where T : IVersion
{
return source.Where(s => s.Version.Contains(game)).ToArray();
}
internal static void MarkEncounterTradeStrings(T[] table, string[][] strings) where T : EncounterTrade
{
int half = strings[1].Length / 2;
for (int i = 0; i < half; i++)
{
var t = table[i];
t.Nicknames = getNames(i, strings);
t.TrainerNames = getNames(i + half, strings);
}
string[] getNames(int i, IEnumerable names) => names.Select(z => z.Length > i ? z[i] : string.Empty).ToArray();
}
}
}