Add DexNav move legality checking

This commit is contained in:
Kaphotics
2016-02-24 16:36:26 -08:00
parent 264ae85509
commit 4b7f253a1e
7 changed files with 64 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ public class LegalityAnalysis
public LegalityCheck EC, Nickname, PID, IDs, IVs, EVs;
public int[] ValidMoves => Legal.getValidMoves(pk6.Species, pk6.CurrentLevel);
public int[] ValidRelearnMoves => Legal.getValidRelearn(pk6.Species);
public bool DexNav => Legal.getDexNavValid(pk6.Species, pk6.Met_Location, pk6.CurrentLevel);
public string Report => getLegalityReport();
private readonly PK6 pk6;
@@ -78,15 +79,20 @@ public bool[] getRelearnValidity(int[] Moves)
// Check Event Info
// Not Implemented
}
if (egg)
else if (egg)
{
for (int i = 0; i < 4; i++)
res[i] &= relearnMoves.Contains(Moves[i]);
return res;
}
bool dexnav = false;
if (dexnav) // not implemented
else if (Moves[0] != 0) // DexNav only?
{
// Check DexNav
for (int i = 1; i < 4; i++)
res[i] &= Moves[i] == 0;
if (DexNav)
res[0] = relearnMoves.Contains(Moves[0]);
return res;
}

View File

@@ -14,7 +14,14 @@ public static partial class Legal
private static readonly EggMoves[] EggMoveAO = EggMoves.getArray(Util.unpackMini(Properties.Resources.eggmove_ao, "ao"));
private static readonly Learnset[] LevelUpAO = Learnset.getArray(Util.unpackMini(Properties.Resources.lvlmove_ao, "ao"));
private static readonly Evolutions[] Evolves = Evolutions.getArray(Util.unpackMini(Properties.Resources.evos_ao, "ao"));
private static readonly DexNavLocations[] DexNavAO = DexNavLocations.getArray(Util.unpackMini(Properties.Resources.dexnav_ao, "ao"));
internal static bool getDexNavValid(int species, int location, int level)
{
DexNavLocations[] locs = DexNavAO.Where(l => l.Location == location).ToArray();
return locs.Any(loc => loc.Slots.Any(slot => slot.Species == species && slot.LevelMin <= level));
}
internal static int[] getValidMoves(int species, int level)
{
int[] r = new int[1];

View File

@@ -90,6 +90,39 @@ public static Evolutions[] getArray(byte[][] entries)
return data;
}
}
public class DexNavLocations
{
public readonly int Location;
public readonly EncounterSlot[] Slots = new EncounterSlot[3];
public DexNavLocations(byte[] data)
{
Location = BitConverter.ToUInt16(data, 0);
for (int i = 0; i < Slots.Length; i++)
{
Slots[i] = new EncounterSlot
{
Species = BitConverter.ToUInt16(data, 2 + i*4),
LevelMin = BitConverter.ToUInt16(data, 4 + i*4)
};
}
}
public static DexNavLocations[] getArray(byte[][] entries)
{
DexNavLocations[] data = new DexNavLocations[entries.Length];
for (int i = 0; i < data.Length; i++)
data[i] = new DexNavLocations(entries[i]);
return data;
}
}
public class EncounterSlot
{
public int Species;
public int Form;
public int LevelMin;
public int LevelMax;
}
public class PersonalInfo
{
internal static int SizeAO = 0x50;

View File

@@ -360,6 +360,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="Resources\byte\dexnav_ao.pkl" />
<None Include="Resources\byte\eggmove_ao.pkl" />
<None Include="Resources\byte\eggmove_xy.pkl" />
<None Include="Resources\byte\evos_ao.pkl" />

View File

@@ -9786,6 +9786,16 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] dexnav_ao {
get {
object obj = ResourceManager.GetObject("dexnav_ao", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@@ -5761,4 +5761,7 @@
<data name="warn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\img\warn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="dexnav_ao" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\byte\dexnav_ao.pkl;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

Binary file not shown.