2016-02-24 03:20:52 +00:00
|
|
|
|
using System.Linq;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public enum Severity
|
|
|
|
|
{
|
|
|
|
|
Indeterminate = -2,
|
|
|
|
|
Invalid = -1,
|
|
|
|
|
Fishy = 0,
|
|
|
|
|
Valid = 1,
|
|
|
|
|
NotImplemented = 2,
|
|
|
|
|
}
|
|
|
|
|
public class LegalityCheck
|
|
|
|
|
{
|
|
|
|
|
public Severity Judgement = Severity.Invalid;
|
|
|
|
|
public string Comment;
|
|
|
|
|
public bool Valid => Judgement >= Severity.Fishy;
|
|
|
|
|
|
|
|
|
|
public LegalityCheck() { }
|
|
|
|
|
public LegalityCheck(Severity s, string c)
|
|
|
|
|
{
|
|
|
|
|
Judgement = s;
|
|
|
|
|
Comment = c;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class LegalityAnalysis
|
|
|
|
|
{
|
|
|
|
|
public bool Valid = false;
|
2016-02-24 03:20:52 +00:00
|
|
|
|
public LegalityCheck EC, Nickname, PID, IDs, IVs, EVs;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
public int[] ValidMoves => Legal.getValidMoves(pk6.Species, pk6.CurrentLevel);
|
|
|
|
|
public int[] ValidRelearnMoves => Legal.getValidRelearn(pk6.Species);
|
2016-02-25 00:36:26 +00:00
|
|
|
|
public bool DexNav => Legal.getDexNavValid(pk6.Species, pk6.Met_Location, pk6.CurrentLevel);
|
2016-02-23 06:52:48 +00:00
|
|
|
|
public string Report => getLegalityReport();
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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++)
|
|
|
|
|
res[i] = Moves[i] != Legal.Struggle && ValidMoves.Concat(RelearnMoves).Contains(Moves[i]);
|
|
|
|
|
}
|
|
|
|
|
if (Moves[0] == 0)
|
|
|
|
|
res[0] = false;
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public bool[] getRelearnValidity(int[] Moves)
|
|
|
|
|
{
|
|
|
|
|
if (Moves.Length != 4)
|
2016-02-24 03:19:25 +00:00
|
|
|
|
return new bool[4];
|
|
|
|
|
|
|
|
|
|
bool[] res = {true, true, true, true};
|
|
|
|
|
if (!pk6.Gen6)
|
|
|
|
|
goto noRelearn;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
2016-02-24 03:19:25 +00:00
|
|
|
|
bool egg = pk6.Egg_Location > 1000 || pk6.Egg_Location == 318;
|
|
|
|
|
bool evnt = pk6.Met_Location > 40000 || pk6.Egg_Location > 40000;
|
|
|
|
|
int[] relearnMoves = ValidRelearnMoves;
|
|
|
|
|
if (evnt)
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
2016-02-24 03:19:25 +00:00
|
|
|
|
// Check Event Info
|
|
|
|
|
// Not Implemented
|
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-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
|
|
|
|
|
for (int i = 1; i < 4; i++)
|
|
|
|
|
res[i] &= Moves[i] == 0;
|
|
|
|
|
if (DexNav)
|
|
|
|
|
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++)
|
|
|
|
|
res[i] &= Moves[i] == 0;
|
|
|
|
|
return res;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
private string getLegalityReport()
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|