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
|
|
|
|
|
{
|
2016-03-14 03:19:04 +00:00
|
|
|
|
public partial class LegalityAnalysis
|
2016-02-23 06:52:48 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly PK6 pk6;
|
2016-03-18 00:25:21 +00:00
|
|
|
|
private object EncounterMatch;
|
2016-03-22 04:31:06 +00:00
|
|
|
|
private LegalityCheck ECPID, Nickname, IDs, IVs, EVs, Encounter, Level, Ribbons, Ability, Ball, HandlerMemories;
|
2016-03-14 03:19:04 +00:00
|
|
|
|
|
2016-03-14 01:09:12 +00:00
|
|
|
|
public bool Valid = true;
|
2016-03-14 03:19:04 +00:00
|
|
|
|
public bool SecondaryChecked;
|
|
|
|
|
public LegalityCheck[] vMoves = new LegalityCheck[4];
|
|
|
|
|
public LegalityCheck[] vRelearn = new LegalityCheck[4];
|
|
|
|
|
public string Report => getLegalityReport();
|
|
|
|
|
|
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 03:19:04 +00:00
|
|
|
|
updateChecks();
|
2016-03-14 01:09:12 +00:00
|
|
|
|
getLegalityReport();
|
2016-03-12 04:56:40 +00:00
|
|
|
|
}
|
2016-03-14 03:19:04 +00:00
|
|
|
|
|
2016-03-12 04:56:40 +00:00
|
|
|
|
public void updateRelearnLegality()
|
|
|
|
|
{
|
2016-03-14 03:19:04 +00:00
|
|
|
|
try { vRelearn = verifyRelearn(); }
|
2016-03-12 17:16:41 +00:00
|
|
|
|
catch { for (int i = 0; i < 4; i++) vRelearn[i] = new LegalityCheck(Severity.Invalid, "Internal error."); }
|
2016-03-14 03:19:04 +00:00
|
|
|
|
SecondaryChecked = false;
|
2016-03-12 04:56:40 +00:00
|
|
|
|
}
|
|
|
|
|
public void updateMoveLegality()
|
|
|
|
|
{
|
2016-03-14 03:19:04 +00:00
|
|
|
|
try { vMoves = verifyMoves(); }
|
2016-03-12 17:16:41 +00:00
|
|
|
|
catch { for (int i = 0; i < 4; i++) vMoves[i] = new LegalityCheck(Severity.Invalid, "Internal error."); }
|
2016-03-14 03:19:04 +00:00
|
|
|
|
SecondaryChecked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateChecks()
|
|
|
|
|
{
|
2016-03-18 00:25:21 +00:00
|
|
|
|
Encounter = verifyEncounter();
|
2016-03-14 03:19:04 +00:00
|
|
|
|
ECPID = verifyECPID();
|
|
|
|
|
Nickname = verifyNickname();
|
|
|
|
|
IDs = verifyID();
|
|
|
|
|
IVs = verifyIVs();
|
|
|
|
|
EVs = verifyEVs();
|
2016-03-19 05:49:21 +00:00
|
|
|
|
Level = verifyLevel();
|
2016-03-20 22:20:11 +00:00
|
|
|
|
Ribbons = verifyRibbons();
|
2016-03-21 15:01:08 +00:00
|
|
|
|
Ability = verifyAbility();
|
|
|
|
|
Ball = verifyBall();
|
2016-03-22 04:31:06 +00:00
|
|
|
|
HandlerMemories = verifyHandlerMemories();
|
2016-03-14 03:19:04 +00:00
|
|
|
|
SecondaryChecked = true;
|
2016-02-23 06:52:48 +00:00
|
|
|
|
}
|
2016-03-09 03:20:26 +00:00
|
|
|
|
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-14 03:19:04 +00:00
|
|
|
|
|
2016-03-22 04:31:06 +00:00
|
|
|
|
var chks = new[] { ECPID, Nickname, IVs, EVs, IDs, Encounter, Level, Ribbons, Ability, Ball, HandlerMemories };
|
2016-03-12 03:43:40 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|