using System;
using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core
{
///
/// Localizing Memory strings
///
///
/// and parameters build strings.
///
public sealed class MemoryStrings
{
private readonly GameStrings s;
public MemoryStrings(GameStrings strings, int format)
{
s = strings;
memories = new Lazy>(GetMemories);
none = new Lazy>(() => Util.GetCBList(new[] {string.Empty}));
species = new Lazy>(() => Util.GetCBList(s.specieslist));
item6 = new Lazy>(() => GetItems(6));
item8 = new Lazy>(() => GetItems(8));
genloc = new Lazy>(() => Util.GetCBList(s.genloc));
moves = new Lazy>(() => Util.GetCBList(s.movelist));
specific = new Lazy>(() => Util.GetCBList(s.metXY_00000, Legal.Met_XY_0));
}
private List GetItems(int format)
{
var permit = Memories.GetMemoryItemParams(format);
var asInt = permit.Select(z => (int) z).ToArray();
return Util.GetCBList(s.itemlist, asInt);
}
private readonly Lazy> memories;
private readonly Lazy> none, species, item6, item8, genloc, moves, specific;
public List Memory => memories.Value;
public List None => none.Value;
public List Moves => moves.Value;
public List Items6 => item6.Value;
public List Items8 => item8.Value;
public List GeneralLocations => genloc.Value;
public List SpecificLocations => specific.Value;
public List Species => species.Value;
private List GetMemories()
{
var mems = s.memories.AsSpan(0);
var list = new List {new(mems[0], 0)}; // none at top
Util.AddCBWithOffset(list, mems[1..], 1); // sorted the rest
return list;
}
public ReadOnlySpan GetMemoryQualities() => s.intensity;
public ReadOnlySpan GetMemoryFeelings(int memoryGen) => memoryGen >= 8 ? s.feeling.AsSpan(0, 25) : s.feeling.AsSpan(1, 24); // empty line for 0 in gen8+
public List GetArgumentStrings(MemoryArgType type, int memoryGen) => type switch
{
MemoryArgType.Species => Species,
MemoryArgType.GeneralLocation => GeneralLocations,
MemoryArgType.Item => memoryGen == 6 ? Items6 : Items8,
MemoryArgType.Move => Moves,
MemoryArgType.SpecificLocation => SpecificLocations,
_ => None,
};
}
}