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)); // Hyperspace Fury 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() { // Memory Chooser int memorycount = s.memories.Length - 38; string[] mems = new string[memorycount]; int[] allowed = new int[memorycount]; for (int i = 0; i < memorycount; i++) { mems[i] = s.memories[38 + i]; allowed[i] = i + 1; } Array.Resize(ref allowed, allowed.Length - 1); var memory_list1 = Util.GetCBList(new[] { mems[0] }); Util.AddCBWithOffset(memory_list1, mems, 0, allowed); return memory_list1; } 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 }; } }