2016-03-05 04:43:00 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public class LegalityAnalysis
|
|
|
|
|
{
|
|
|
|
|
private readonly PK6 pk6;
|
|
|
|
|
public LegalityAnalysis(PK6 pk)
|
|
|
|
|
{
|
|
|
|
|
pk6 = pk;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool[] getMoveValidity(int[] Moves, int[] RelearnMoves)
|
|
|
|
|
{
|
|
|
|
|
if (Moves.Length != 4)
|
2016-02-24 03:19:25 +00:00
|
|
|
|
return new bool[4];
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
2016-02-24 03:19:25 +00:00
|
|
|
|
bool[] res = { true, true, true, true };
|
2016-02-23 06:52:48 +00:00
|
|
|
|
if (!pk6.Gen6)
|
2016-02-24 03:19:25 +00:00
|
|
|
|
return res;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
2016-03-04 06:12:22 +00:00
|
|
|
|
int[] validMoves = Legal.getValidMoves(pk6);
|
2016-02-23 06:52:48 +00:00
|
|
|
|
if (pk6.Species == 235)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
res[i] = !Legal.InvalidSketch.Contains(Moves[i]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-04 06:12:22 +00:00
|
|
|
|
res[i] = Moves[i] != Legal.Struggle && validMoves.Concat(RelearnMoves).Contains(Moves[i]);
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
if (Moves[0] == 0)
|
|
|
|
|
res[0] = false;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public bool[] getRelearnValidity(int[] Moves)
|
|
|
|
|
{
|
2016-02-24 03:19:25 +00:00
|
|
|
|
bool[] res = {true, true, true, true};
|
|
|
|
|
if (!pk6.Gen6)
|
|
|
|
|
goto noRelearn;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
2016-03-05 04:43:00 +00:00
|
|
|
|
if (Moves.Length != 4)
|
|
|
|
|
return new bool[4];
|
|
|
|
|
|
2016-03-06 19:19:09 +00:00
|
|
|
|
bool link = pk6.Met_Location == 30011;
|
|
|
|
|
if (link)
|
|
|
|
|
{
|
|
|
|
|
if (pk6.FatefulEncounter) // Should NOT be Fateful
|
|
|
|
|
return new bool[4]; // False
|
|
|
|
|
int[] moves = Legal.getLinkMoves(pk6);
|
|
|
|
|
return moves.SequenceEqual(Moves) ? res : new bool[4];
|
|
|
|
|
}
|
2016-02-26 00:19:59 +00:00
|
|
|
|
bool egg = Legal.EggLocations.Contains(pk6.Egg_Location) && pk6.Met_Level == 1;
|
|
|
|
|
bool evnt = pk6.FatefulEncounter && pk6.Met_Location > 40000;
|
|
|
|
|
bool eventEgg = pk6.FatefulEncounter && (pk6.Egg_Location > 40000 || pk6.Egg_Location == 30002) && pk6.Met_Level == 1;
|
2016-02-26 15:52:08 +00:00
|
|
|
|
int[] relearnMoves = Legal.getValidRelearn(pk6, 0);
|
2016-02-26 00:19:59 +00:00
|
|
|
|
if (evnt || eventEgg)
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-03-05 04:43:00 +00:00
|
|
|
|
// Get WC6's that match
|
|
|
|
|
IEnumerable<WC6> vwc6 = Legal.getValidWC6s(pk6);
|
|
|
|
|
if (vwc6.Any(wc6 => wc6.RelearnMoves.SequenceEqual(Moves)))
|
|
|
|
|
return res; // all true
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
2016-02-25 00:36:26 +00:00
|
|
|
|
else if (egg)
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-02-26 15:52:08 +00:00
|
|
|
|
if (Legal.SplitBreed.Contains(pk6.Species))
|
2016-02-26 00:19:59 +00:00
|
|
|
|
{
|
2016-02-26 15:52:08 +00:00
|
|
|
|
res = new bool[4];
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
res[i] = relearnMoves.Contains(Moves[i]);
|
|
|
|
|
if (!res.Any(move => !move))
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
// Try Next Species up
|
|
|
|
|
Legal.getValidRelearn(pk6, 1);
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
res[i] = relearnMoves.Contains(Moves[i]);
|
|
|
|
|
return res;
|
2016-02-26 00:19:59 +00:00
|
|
|
|
}
|
2016-02-26 15:52:08 +00:00
|
|
|
|
|
|
|
|
|
if (Legal.LightBall.Contains(pk6.Species))
|
|
|
|
|
relearnMoves = relearnMoves.Concat(new[] {344}).ToArray();
|
2016-02-24 03:19:25 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
res[i] &= relearnMoves.Contains(Moves[i]);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
2016-02-25 00:36:26 +00:00
|
|
|
|
else if (Moves[0] != 0) // DexNav only?
|
2016-02-24 03:19:25 +00:00
|
|
|
|
{
|
2016-02-25 00:36:26 +00:00
|
|
|
|
// Check DexNav
|
2016-02-26 00:19:59 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-02-25 00:36:26 +00:00
|
|
|
|
res[i] &= Moves[i] == 0;
|
2016-03-04 06:12:22 +00:00
|
|
|
|
if (Legal.getDexNavValid(pk6))
|
2016-02-25 00:36:26 +00:00
|
|
|
|
res[0] = relearnMoves.Contains(Moves[0]);
|
|
|
|
|
|
2016-02-24 03:19:25 +00:00
|
|
|
|
return res;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-24 03:19:25 +00:00
|
|
|
|
// Should have no relearn moves.
|
|
|
|
|
noRelearn:
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-02 23:46:22 +00:00
|
|
|
|
res[i] = Moves[i] == 0;
|
2016-02-24 03:19:25 +00:00
|
|
|
|
return res;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|