Add basic memory checks

Thanks Eskuero. WIP.
This commit is contained in:
Kaphotics
2016-05-05 20:05:22 -07:00
parent 0f69fcb7f8
commit e7e793a2f4
3 changed files with 69 additions and 4 deletions

View File

@@ -10,8 +10,8 @@ public partial class LegalityAnalysis
private object EncounterMatch;
private List<WC6> CardMatch;
private Type EncounterType;
private LegalityCheck ECPID, Nickname, IDs, IVs, EVs, Encounter, Level, Ribbons, Ability, Ball, HandlerMemories, Form, Misc;
private LegalityCheck[] Checks => new[] { Encounter, Level, Form, Ball, Ability, Ribbons, ECPID, Nickname, IVs, EVs, IDs, HandlerMemories, Misc };
private LegalityCheck ECPID, Nickname, IDs, IVs, EVs, Encounter, Level, Ribbons, Ability, Ball, History, OTMemory, HTMemory, Form, Misc;
private LegalityCheck[] Checks => new[] { Encounter, Level, Form, Ball, Ability, Ribbons, ECPID, Nickname, IVs, EVs, IDs, History, OTMemory, HTMemory, Misc };
public bool Valid = true;
public bool SecondaryChecked;
@@ -56,7 +56,9 @@ private void updateChecks()
Ribbons = verifyRibbons();
Ability = verifyAbility();
Ball = verifyBall();
HandlerMemories = verifyHandlerMemories();
History = verifyHistory();
OTMemory = verifyOTMemory();
HTMemory = verifyHTMemory();
Form = verifyForm();
Misc = verifyMisc();
SecondaryChecked = true;

View File

@@ -560,7 +560,7 @@ private LegalityCheck verifyBall()
return new LegalityCheck(Severity.Invalid, "No ball check satisfied, assuming illegal.");
}
private LegalityCheck verifyHandlerMemories()
private LegalityCheck verifyHistory()
{
if (!Encounter.Valid)
return new LegalityCheck(Severity.Valid, "Skipped Memory check due to other check being invalid.");
@@ -628,6 +628,48 @@ private LegalityCheck verifyHandlerMemories()
return new LegalityCheck(Severity.Valid, "History is valid.");
}
private LegalityCheck verifyOTMemory()
{
if (!History.Valid)
return new LegalityCheck(Severity.Valid, "Skipped OT Memory check as History is not valid.");
if (EncounterType == typeof(EncounterTrade))
{
return new LegalityCheck(Severity.Valid, "OT Memory (Ingame Trade) is valid.");
}
if (EncounterType == typeof(WC6))
{
if (pk6.OT_Memory != 0)
return new LegalityCheck(Severity.Invalid, "Event Pokémon should not have an OT memory.");
return new LegalityCheck(Severity.Valid, "OT Memory (Event) is valid.");
}
switch (pk6.OT_Memory)
{
case 4: // {0} became {1}s friend when it arrived via Link Trade at... {2}. {4} that {3}.
return new LegalityCheck(Severity.Invalid, "OT Memory: Link Trade is not a valid first memory.");
}
if (pk6.XY && Legal.Memory_NotXY.Contains(pk6.OT_Memory))
return new LegalityCheck(Severity.Invalid, "OT Memory: OR/AS exclusive memory on X/Y origin.");
if (pk6.AO && Legal.Memory_NotAO.Contains(pk6.OT_Memory))
return new LegalityCheck(Severity.Invalid, "OT Memory: X/Y exclusive memory on OR/AS origin.");
return new LegalityCheck(Severity.Valid, "OT Memory is valid.");
}
private LegalityCheck verifyHTMemory()
{
if (!History.Valid)
return new LegalityCheck(Severity.Valid, "Skipped OT Memory check as History is not valid.");
switch (pk6.HT_Memory)
{
case 1: // {0} met {1} at... {2}. {1} threw a Poké Ball at it, and they started to travel together. {4} that {3}.
return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not capture this.");
case 2: // {0} hatched from an Egg and saw {1} for the first time at... {2}. {4} that {3}.
return new LegalityCheck(Severity.Invalid, "HT Memory: Handling Trainer did not hatch this.");
}
return new LegalityCheck(Severity.Valid, "HT Memory is valid.");
}
private LegalityCheck verifyForm()
{
if (!Encounter.Valid)

View File

@@ -870,5 +870,26 @@ public static partial class Legal
268, 269, // Cascoon Dustox
};
#endregion
#region Memory Table
internal static readonly int[] Memory_NotXY =
{
61, // {0} looked down at the world from a tall tower where it went with {1}. {4} that {3}.
65, // {0} was with {1} when (he/she) built a Secret Base. {4} that {3}.
66, // {0} participated in a contest with {1} and impressed many people. {4} that {3}.
67, // {0} participated in a contest with {1} and won the title. {4} that {3}.
68, // {0} soared through the sky with {1} and went to many different places. {4} that {3}.
69, // {1} asked {0} to dive. Down it went, deep into the ocean, to explore the bottom of the sea. {4} that {3}.
};
internal static readonly int[] Memory_NotAO =
{
5, // {0} went to a Pokémon Center with {1} to buy {2}. {4} that {3}.
11, // {0} went clothes shopping with {1}. {4} that {3}.
43, // {0} was impressed by the speed of the train it took with {1}. {4} that {3}.
44, // {0} encountered {2} with {1} using the Poké Radar. {4} that {3}.
56, // {0} was with {1} when (he/she) went to a boutique and tried on clothes, but (he/she) left the boutique without buying anything. {4} that {3}.
57, // {0} went to a nice restaurant with {1} and ate until it got totally full. {4} that {3}.
62, // {0} saw itself in a mirror in a mirror cave that it went to with {1}. {4} that {3}.
};
#endregion
}
}