2016-03-12 03:43:40 +00:00
|
|
|
|
using System;
|
2016-03-05 04:43:00 +00:00
|
|
|
|
using System.Linq;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public class LegalityAnalysis
|
|
|
|
|
{
|
|
|
|
|
private readonly PK6 pk6;
|
2016-03-14 01:09:12 +00:00
|
|
|
|
public bool Valid = true;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
public LegalityAnalysis(PK6 pk)
|
|
|
|
|
{
|
|
|
|
|
pk6 = pk;
|
2016-03-12 04:56:40 +00:00
|
|
|
|
updateRelearnLegality();
|
|
|
|
|
updateMoveLegality();
|
2016-03-14 01:09:12 +00:00
|
|
|
|
getLegalityReport();
|
2016-03-12 04:56:40 +00:00
|
|
|
|
}
|
|
|
|
|
public void updateRelearnLegality()
|
|
|
|
|
{
|
2016-03-12 17:16:41 +00:00
|
|
|
|
try { vRelearn = LegalityCheck.verifyRelearn(pk6); }
|
|
|
|
|
catch { for (int i = 0; i < 4; i++) vRelearn[i] = new LegalityCheck(Severity.Invalid, "Internal error."); }
|
|
|
|
|
|
2016-03-12 04:56:40 +00:00
|
|
|
|
}
|
|
|
|
|
public void updateMoveLegality()
|
|
|
|
|
{
|
2016-03-12 17:16:41 +00:00
|
|
|
|
try { vMoves = LegalityCheck.verifyMoves(pk6); }
|
|
|
|
|
catch { for (int i = 0; i < 4; i++) vMoves[i] = new LegalityCheck(Severity.Invalid, "Internal error."); }
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
2016-03-12 04:56:40 +00:00
|
|
|
|
|
2016-03-12 03:43:40 +00:00
|
|
|
|
public LegalityCheck EC, Nickname, PID, IDs, IVs, EVs, Encounter;
|
2016-03-12 17:16:41 +00:00
|
|
|
|
public LegalityCheck[] vMoves = new LegalityCheck[4];
|
|
|
|
|
public LegalityCheck[] vRelearn = new LegalityCheck[4];
|
2016-03-09 03:20:26 +00:00
|
|
|
|
public string Report => getLegalityReport();
|
|
|
|
|
private string getLegalityReport()
|
|
|
|
|
{
|
2016-03-12 03:57:33 +00:00
|
|
|
|
if (!pk6.Gen6)
|
2016-03-12 04:56:40 +00:00
|
|
|
|
return "Analysis only available for Pokémon that originate from X/Y & OR/AS.";
|
2016-03-12 03:57:33 +00:00
|
|
|
|
|
2016-03-11 04:36:32 +00:00
|
|
|
|
EC = LegalityCheck.verifyECPID(pk6);
|
|
|
|
|
Nickname = LegalityCheck.verifyNickname(pk6);
|
|
|
|
|
PID = LegalityCheck.verifyECPID(pk6);
|
|
|
|
|
IVs = LegalityCheck.verifyIVs(pk6);
|
|
|
|
|
EVs = LegalityCheck.verifyEVs(pk6);
|
2016-03-12 03:43:40 +00:00
|
|
|
|
IDs = LegalityCheck.verifyID(pk6);
|
|
|
|
|
Encounter = LegalityCheck.verifyEncounter(pk6);
|
|
|
|
|
|
|
|
|
|
var chks = new[] {EC, Nickname, PID, IVs, EVs, IDs, Encounter};
|
|
|
|
|
|
2016-03-12 04:56:40 +00:00
|
|
|
|
string r = "";
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-12 17:16:41 +00:00
|
|
|
|
if (!vMoves[i].Valid)
|
|
|
|
|
r += $"{vMoves[i].Judgement} Move {i + 1}: {vMoves[i].Comment}" + Environment.NewLine;
|
2016-03-12 04:56:40 +00:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2016-03-12 17:16:41 +00:00
|
|
|
|
if (!vRelearn[i].Valid)
|
|
|
|
|
r += $"{vRelearn[i].Judgement} Relearn Move {i + 1}: {vRelearn[i].Comment}" + Environment.NewLine;
|
2016-03-12 04:56:40 +00:00
|
|
|
|
|
|
|
|
|
if (r.Length == 0 && chks.All(chk => chk.Valid))
|
2016-03-12 03:43:40 +00:00
|
|
|
|
return "Legal!";
|
|
|
|
|
|
2016-03-14 01:09:12 +00:00
|
|
|
|
Valid = false;
|
2016-03-12 03:43:40 +00:00
|
|
|
|
// Build result string...
|
2016-03-12 04:56:40 +00:00
|
|
|
|
r += chks.Where(chk => !chk.Valid).Aggregate("", (current, chk) => current + $"{chk.Judgement}: {chk.Comment}{Environment.NewLine}");
|
|
|
|
|
|
|
|
|
|
return r;
|
2016-03-09 03:20:26 +00:00
|
|
|
|
}
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|