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)); item = new Lazy>(() => GetItems(format)); 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, item, genloc, moves, specific; public List Memory => memories.Value; public List None => none.Value; public List Moves => moves.Value; public List Items => item.Value; public List GeneralLocations => genloc.Value; public List SpecificLocations => specific.Value; public List Species => species.Value; private List GetMemories() { const int offset = 38; var mems = s.memories.AsSpan(offset); 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.memories.AsSpan(2, 7); public ReadOnlySpan GetMemoryFeelings(int format) => format >= 8 ? s.memories.AsSpan(9, 25) : s.memories.AsSpan(10, 24); // empty line for 0 in gen8+ public List GetArgumentStrings(MemoryArgType type) => type switch { MemoryArgType.Species => Species, MemoryArgType.GeneralLocation => GeneralLocations, MemoryArgType.Item => Items, MemoryArgType.Move => Moves, MemoryArgType.SpecificLocation => SpecificLocations, _ => None }; } }