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) { s = strings; memories = new Lazy>(GetMemories); none = new Lazy>(() => Util.GetCBList([string.Empty])); species = new Lazy>(() => Util.GetCBList(s.specieslist)); item6 = new Lazy>(() => GetItems(EntityContext.Gen6)); item8 = new Lazy>(() => GetItems(EntityContext.Gen8)); genloc = new Lazy>(() => Util.GetCBList(s.genloc)); moves = new Lazy>(() => Util.GetCBList(s.movelist)); specific = new Lazy>(() => Util.GetCBList(s.Gen6.Met0, Locations6.Met0)); } private List GetItems(EntityContext context) { var permit = Memories.GetMemoryItemParams(context); var asInt = permit.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.feeling8 : s.feeling6; 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, }; }