Add gen6 key item arg logic

This commit is contained in:
Kurt 2021-01-31 10:53:41 -08:00
parent fd4034272b
commit 09e5dde609
2 changed files with 27 additions and 2 deletions

View File

@ -156,7 +156,17 @@ public static bool GetHasPokeCenterLocation(GameVersion game, int loc)
private static readonly HashSet<int> MemoryItem = new() { 5, 15, 26, 34, 40, 51, 84, 88 };
private static readonly HashSet<int> MemorySpecies = new() { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60, 70, 71, 72, 75, 82, 83, 87 };
private static readonly Dictionary<int, ushort[]> KeyItemMemoryArgs = new()
internal static readonly Dictionary<int, ushort[]> KeyItemMemoryArgsGen6 = new()
{
{(int) Species.Shaymin, new ushort[] {466}}, // Gracidea
{(int) Species.Tornadus, new ushort[] {638}}, // Reveal Glass
{(int) Species.Thundurus, new ushort[] {638}}, // Reveal Glass
{(int) Species.Landorus, new ushort[] {638}}, // Reveal Glass
{(int) Species.Kyurem, new ushort[] {628, 629}}, // DNA Splicers
{(int) Species.Hoopa, new ushort[] {765}}, // Prison Bottle
};
internal static readonly Dictionary<int, ushort[]> KeyItemMemoryArgsGen8 = new()
{
{(int) Species.Rotom, new ushort[] {1278}}, // Rotom Catalog
{(int) Species.Kyurem, new ushort[] {628, 629}}, // DNA Splicers
@ -164,7 +174,7 @@ public static bool GetHasPokeCenterLocation(GameVersion game, int loc)
{(int) Species.Calyrex, new ushort[] {1590, 1591}}, // Reigns of Unity
};
public static IEnumerable<ushort> KeyItemArgValues => KeyItemMemoryArgs.Values.SelectMany(z => z);
public static IEnumerable<ushort> KeyItemArgValues => KeyItemMemoryArgsGen6.Values.Concat(KeyItemMemoryArgsGen8.Values).SelectMany(z => z).Distinct();
public static MemoryArgType GetMemoryArgType(int memory, int format)
{

View File

@ -30,14 +30,29 @@ public static bool CanPlantBerry(int generation, int item)
public static bool CanUseItemGeneric(int generation, int item)
{
if (generation == 6)
{
// Key Item usage while in party on another species.
if (Memories.KeyItemMemoryArgsGen6.Values.Any(z => z.Contains((ushort) item)))
return true;
}
return true; // todo
}
public static bool CanUseItem(int generation, int item, int species)
{
if (IsUsedKeyItem(generation, item, species))
return true;
return true; // todo
}
private static bool IsUsedKeyItem(int generation, int item, int species) => generation switch
{
6 => Memories.KeyItemMemoryArgsGen6.TryGetValue(species, out var value) && value.Contains((ushort) item),
8 => Memories.KeyItemMemoryArgsGen8.TryGetValue(species, out var value) && value.Contains((ushort) item),
_ => false
};
public static bool CanBuyItem(int generation, int item)
{
return true; // todo