mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 04:23:12 +00:00
Minor updates
increase readability, simplifly some expressions relocate hot path for legality report string creation
This commit is contained in:
parent
332784d34b
commit
21e7f4317e
7 changed files with 195 additions and 190 deletions
|
@ -81,9 +81,7 @@ namespace PKHeX.Core
|
|||
return _allSuggestedRelearnMoves;
|
||||
if (Error || Info == null)
|
||||
return new int[4];
|
||||
var gender = pkm.PersonalInfo.Gender;
|
||||
var inheritLvlMoves = (gender > 0 && gender < 255) || Legal.MixedGenderBreeding.Contains(Info.EncounterMatch.Species);
|
||||
return _allSuggestedRelearnMoves = Legal.GetValidRelearn(pkm, Info.EncounterMatch.Species, inheritLvlMoves).ToArray();
|
||||
return _allSuggestedRelearnMoves = Legal.GetValidRelearn(pkm, Info.EncounterMatch.Species, (GameVersion)pkm.Version).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +128,7 @@ namespace PKHeX.Core
|
|||
&& Info.Moves.All(m => m.Valid)
|
||||
&& Info.Relearn.All(m => m.Valid);
|
||||
|
||||
if (pkm.FatefulEncounter && Info.Relearn.Any(chk => !chk.Valid) && EncounterMatch is EncounterInvalid)
|
||||
if (!Valid && pkm.FatefulEncounter && Info.Relearn.Any(chk => !chk.Valid) && EncounterMatch is EncounterInvalid)
|
||||
AddLine(Severity.Indeterminate, LFatefulGiftMissing, CheckIdentifier.Fateful);
|
||||
}
|
||||
#if SUPPRESS
|
||||
|
@ -299,6 +297,8 @@ namespace PKHeX.Core
|
|||
|
||||
private string GetLegalityReport()
|
||||
{
|
||||
if (Valid)
|
||||
return L_ALegal;
|
||||
if (!Parsed || Info == null)
|
||||
return L_AnalysisUnavailable;
|
||||
|
||||
|
@ -308,7 +308,7 @@ namespace PKHeX.Core
|
|||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (!vMoves[i].Valid)
|
||||
lines.Add(string.Format(L_F0_M_1_2, vMoves[i].Rating, i + 1, vMoves[i].Comment));
|
||||
lines.Add(vMoves[i].Format(L_F0_M_1_2, i + 1));
|
||||
}
|
||||
|
||||
if (pkm.Format >= 6)
|
||||
|
@ -316,19 +316,13 @@ namespace PKHeX.Core
|
|||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (!vRelearn[i].Valid)
|
||||
lines.Add(string.Format(L_F0_RM_1_2, vRelearn[i].Rating, i + 1, vRelearn[i].Comment));
|
||||
lines.Add(vRelearn[i].Format(L_F0_RM_1_2, i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (lines.Count == 0 && Parse.All(chk => chk.Valid) && Valid)
|
||||
return L_ALegal;
|
||||
|
||||
// Build result string...
|
||||
var outputLines = Parse.Where(chk => !chk.Valid); // Only invalid
|
||||
lines.AddRange(outputLines.Select(chk => string.Format(L_F0_1, chk.Rating, chk.Comment)));
|
||||
|
||||
if (lines.Count == 0)
|
||||
return L_AError;
|
||||
var outputLines = Parse.Where(chk => !chk.Valid);
|
||||
lines.AddRange(outputLines.Select(chk => chk.Format(L_F0_1)));
|
||||
|
||||
return string.Join(Environment.NewLine, lines);
|
||||
}
|
||||
|
@ -351,7 +345,7 @@ namespace PKHeX.Core
|
|||
var move = vMoves[i];
|
||||
if (!move.Valid)
|
||||
continue;
|
||||
var msg = string.Format(L_F0_M_1_2, move.Rating, i + 1, move.Comment);
|
||||
var msg = move.Format(L_F0_M_1_2, i + 1);
|
||||
if (pkm.Format != move.Generation)
|
||||
msg += $" [Gen{move.Generation}]";
|
||||
lines.Add(msg);
|
||||
|
@ -362,7 +356,7 @@ namespace PKHeX.Core
|
|||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (vRelearn[i].Valid)
|
||||
lines.Add(string.Format(L_F0_RM_1_2, vRelearn[i].Rating, i + 1, vRelearn[i].Comment));
|
||||
lines.Add(vRelearn[i].Format(L_F0_RM_1_2, i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +364,7 @@ namespace PKHeX.Core
|
|||
lines.Add(br[1]);
|
||||
|
||||
var outputLines = Parse.Where(chk => chk?.Valid == true && chk.Comment != L_AValid).OrderBy(chk => chk.Judgement); // Fishy sorted to top
|
||||
lines.AddRange(outputLines.Select(chk => string.Format(L_F0_1, chk.Rating, chk.Comment)));
|
||||
lines.AddRange(outputLines.Select(chk => chk.Format(L_F0_1)));
|
||||
|
||||
lines.AddRange(br);
|
||||
lines.Add(string.Format(L_FEncounterType_0, EncounterName));
|
||||
|
|
|
@ -99,9 +99,14 @@ namespace PKHeX.Core
|
|||
return GetValidMoves(pkm, version, evoChain, generation, minLvLG1: minLvLG1, minLvLG2: minLvLG2, LVL: LVL, Relearn: false, Tutor: Tutor, Machine: Machine, MoveReminder: MoveReminder, RemoveTransferHM: RemoveTransferHM);
|
||||
}
|
||||
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
return GetValidRelearn(pkm, species, GetCanInheritMoves(species), version);
|
||||
}
|
||||
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, bool inheritlvlmoves, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
List<int> r = new List<int> { 0 };
|
||||
var r = new List<int> { 0 };
|
||||
if (pkm.GenNumber < 6)
|
||||
return r;
|
||||
|
||||
|
@ -707,7 +712,7 @@ namespace PKHeX.Core
|
|||
|
||||
private static IEnumerable<int> GetValidMoves(PKM pkm, GameVersion Version, IReadOnlyList<IReadOnlyList<EvoCriteria>> vs, int minLvLG1 = 1, int minLvLG2 = 1, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false, bool MoveReminder = true, bool RemoveTransferHM = true)
|
||||
{
|
||||
List<int> r = new List<int> { 0 };
|
||||
var r = new List<int> { 0 };
|
||||
if (Relearn && pkm.Format >= 6)
|
||||
r.AddRange(pkm.RelearnMoves);
|
||||
|
||||
|
@ -722,7 +727,7 @@ namespace PKHeX.Core
|
|||
|
||||
private static IEnumerable<int> GetValidMoves(PKM pkm, GameVersion Version, IReadOnlyList<EvoCriteria> vs, int generation, int minLvLG1 = 1, int minLvLG2 = 1, bool LVL = false, bool Relearn = false, bool Tutor = false, bool Machine = false, bool MoveReminder = true, bool RemoveTransferHM = true)
|
||||
{
|
||||
List<int> r = new List<int> { 0 };
|
||||
var r = new List<int> { 0 };
|
||||
if (vs.Count == 0)
|
||||
return r;
|
||||
int species = pkm.Species;
|
||||
|
@ -802,7 +807,7 @@ namespace PKHeX.Core
|
|||
|
||||
private static IEnumerable<int> GetMoves(PKM pkm, int species, int minlvlG1, int minlvlG2, int lvl, int form, bool moveTutor, GameVersion Version, bool LVL, bool specialTutors, bool Machine, bool MoveReminder, bool RemoveTransferHM, int generation)
|
||||
{
|
||||
List<int> r = new List<int>();
|
||||
var r = new List<int>();
|
||||
if (LVL)
|
||||
r.AddRange(MoveLevelUp.GetMovesLevelUp(pkm, species, minlvlG1, minlvlG2, lvl, form, Version, MoveReminder, generation));
|
||||
if (Machine)
|
||||
|
|
|
@ -12,11 +12,11 @@ namespace PKHeX
|
|||
/// </summary>
|
||||
internal static class GBRestrictions
|
||||
{
|
||||
internal static readonly int[] G1CaterpieMoves = { 33, 81 };
|
||||
internal static readonly int[] G1WeedleMoves = { 40, 81 };
|
||||
internal static readonly int[] G1MetapodMoves = G1CaterpieMoves.Concat(new[] { 106 }).ToArray();
|
||||
internal static readonly int[] G1KakunaMoves = G1WeedleMoves.Concat(new[] { 106 }).ToArray();
|
||||
internal static readonly int[] G1Exeggcute_IncompatibleMoves = { 78, 77, 79 };
|
||||
private static readonly int[] G1CaterpieMoves = { 33, 81 };
|
||||
private static readonly int[] G1WeedleMoves = { 40, 81 };
|
||||
private static readonly int[] G1MetapodMoves = { 33, 81, 106 };
|
||||
private static readonly int[] G1KakunaMoves = { 40, 81, 106 };
|
||||
private static readonly int[] G1Exeggcute_IncompatibleMoves = { 78, 77, 79 };
|
||||
|
||||
internal static readonly int[] Stadium_CatchRate =
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ namespace PKHeX
|
|||
168, // Gorgeous Box
|
||||
};
|
||||
|
||||
internal static readonly HashSet<int> Stadium_GiftSpecies = new HashSet<int>
|
||||
private static readonly HashSet<int> Stadium_GiftSpecies = new HashSet<int>
|
||||
{
|
||||
001, // Bulbasaur
|
||||
004, // Charmander
|
||||
|
@ -37,12 +37,14 @@ namespace PKHeX
|
|||
140, // Kabuto
|
||||
};
|
||||
|
||||
internal static readonly HashSet<int> SpecialMinMoveSlots = new HashSet<int>
|
||||
private static readonly HashSet<int> SpecialMinMoveSlots = new HashSet<int>
|
||||
{
|
||||
25, 26, 29, 30, 31, 32, 33, 34, 36, 38, 40, 59, 91, 103, 114, 121,
|
||||
};
|
||||
|
||||
internal static readonly HashSet<int> Types_Gen1 = new HashSet<int>
|
||||
internal static bool TypeIDExists(int type) => Types_Gen1.Contains(type);
|
||||
|
||||
private static readonly HashSet<int> Types_Gen1 = new HashSet<int>
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 7, 8, 20, 21, 22, 23, 24, 25, 26
|
||||
};
|
||||
|
|
|
@ -25,5 +25,8 @@
|
|||
Comment = c;
|
||||
Identifier = i;
|
||||
}
|
||||
|
||||
public string Format(string format) => string.Format(format, Rating, Comment);
|
||||
public string Format(string format, int index) => string.Format(format, Rating, index, Comment);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using static PKHeX.Core.LegalityCheckStrings;
|
||||
using static PKHeX.Core.CheckIdentifier;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -9,7 +10,7 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public sealed class MiscVerifier : Verifier
|
||||
{
|
||||
protected override CheckIdentifier Identifier => CheckIdentifier.Misc;
|
||||
protected override CheckIdentifier Identifier => Misc;
|
||||
|
||||
public override void Verify(LegalityAnalysis data)
|
||||
{
|
||||
|
@ -19,21 +20,21 @@ namespace PKHeX.Core
|
|||
VerifyMiscEggCommon(data);
|
||||
|
||||
if (pkm is IContestStats s && s.HasContestStats())
|
||||
data.AddLine(GetInvalid(LEggContest, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggContest, Egg));
|
||||
|
||||
switch (pkm)
|
||||
{
|
||||
case PK5 pk5 when pk5.PokeStarFame != 0 && pk5.IsEgg:
|
||||
data.AddLine(GetInvalid(LEggShinyPokeStar, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggShinyPokeStar, Egg));
|
||||
break;
|
||||
case PK4 pk4 when pk4.ShinyLeaf != 0:
|
||||
data.AddLine(GetInvalid(LEggShinyLeaf, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggShinyLeaf, Egg));
|
||||
break;
|
||||
case PK4 pk4 when pk4.PokéathlonStat != 0:
|
||||
data.AddLine(GetInvalid(LEggPokeathlon, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggPokeathlon, Egg));
|
||||
break;
|
||||
case PK3 _ when pkm.Language != 1: // All Eggs are Japanese and flagged specially for localized string
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, LanguageID.Japanese, (LanguageID)pkm.Language), CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, LanguageID.Japanese, (LanguageID)pkm.Language), Egg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +54,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
VerifyMiscEggCommon(data);
|
||||
if (pkm.PKRS_Cured || pkm.PKRS_Infected)
|
||||
data.AddLine(GetInvalid(LEggPokerus, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggPokerus, Egg));
|
||||
}
|
||||
|
||||
if (!(pkm is PK1 pk1))
|
||||
|
@ -67,14 +68,14 @@ namespace PKHeX.Core
|
|||
{
|
||||
var Type_A = pk1.Type_A;
|
||||
var Type_B = pk1.Type_B;
|
||||
if (pk1.Species == 137) // Porygon
|
||||
if (pk1.Species == (int)Species.Porygon)
|
||||
{
|
||||
// Can have any type combination of any species by using Conversion.
|
||||
if (!GBRestrictions.Types_Gen1.Contains(Type_A))
|
||||
if (!GBRestrictions.TypeIDExists(Type_A))
|
||||
{
|
||||
data.AddLine(GetInvalid(LG1TypePorygonFail1));
|
||||
}
|
||||
else if (!GBRestrictions.Types_Gen1.Contains(Type_B))
|
||||
if (!GBRestrictions.TypeIDExists(Type_B))
|
||||
{
|
||||
data.AddLine(GetInvalid(LG1TypePorygonFail2));
|
||||
}
|
||||
|
@ -166,35 +167,35 @@ namespace PKHeX.Core
|
|||
VerifyFatefulMysteryGift(data, g);
|
||||
return;
|
||||
case EncounterStatic s when s.Fateful: // ingame fateful
|
||||
case EncounterSlot _ when pkm.Version == 15: // ingame pokespot
|
||||
case EncounterSlot x when x.Version == GameVersion.XD: // ingame pokespot
|
||||
case EncounterTrade t when t.Fateful:
|
||||
VerifyFatefulIngameActive(data);
|
||||
return;
|
||||
}
|
||||
if (pkm.FatefulEncounter)
|
||||
data.AddLine(GetInvalid(LFatefulInvalid, CheckIdentifier.Fateful));
|
||||
data.AddLine(GetInvalid(LFatefulInvalid, Fateful));
|
||||
}
|
||||
|
||||
private static void VerifyMiscEggCommon(LegalityAnalysis data)
|
||||
{
|
||||
var pkm = data.pkm;
|
||||
if (pkm.Move1_PPUps > 0 || pkm.Move2_PPUps > 0 || pkm.Move3_PPUps > 0 || pkm.Move4_PPUps > 0)
|
||||
data.AddLine(GetInvalid(LEggPPUp, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggPPUp, Egg));
|
||||
if (pkm.Move1_PP != pkm.GetMovePP(pkm.Move1, 0) || pkm.Move2_PP != pkm.GetMovePP(pkm.Move2, 0) || pkm.Move3_PP != pkm.GetMovePP(pkm.Move3, 0) || pkm.Move4_PP != pkm.GetMovePP(pkm.Move4, 0))
|
||||
data.AddLine(GetInvalid(LEggPP, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggPP, Egg));
|
||||
|
||||
var EncounterMatch = data.EncounterOriginal;
|
||||
var HatchCycles = (EncounterMatch as EncounterStatic)?.EggCycles;
|
||||
if (HatchCycles == 0 || HatchCycles == null)
|
||||
HatchCycles = pkm.PersonalInfo.HatchCycles;
|
||||
if (pkm.CurrentFriendship > HatchCycles)
|
||||
data.AddLine(GetInvalid(LEggHatchCycles, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(LEggHatchCycles, Egg));
|
||||
|
||||
if (pkm.Format >= 6 && EncounterMatch is EncounterEgg && !pkm.Moves.SequenceEqual(pkm.RelearnMoves))
|
||||
{
|
||||
var moves = string.Join(", ", LegalityAnalysis.GetMoveNames(pkm.Moves));
|
||||
var msg = string.Format(LMoveFExpect_0, moves);
|
||||
data.AddLine(GetInvalid(msg, CheckIdentifier.Egg));
|
||||
data.AddLine(GetInvalid(msg, Egg));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,12 +207,12 @@ namespace PKHeX.Core
|
|||
var Info = data.Info;
|
||||
Info.PIDIV = MethodFinder.Analyze(pkm);
|
||||
if (Info.PIDIV.Type != PIDType.G5MGShiny && pkm.Egg_Location != Locations.LinkTrade5)
|
||||
data.AddLine(GetInvalid(LPIDTypeMismatch, CheckIdentifier.PID));
|
||||
data.AddLine(GetInvalid(LPIDTypeMismatch, PID));
|
||||
}
|
||||
|
||||
var result = pkm.FatefulEncounter != pkm.WasLink
|
||||
? GetValid(LFatefulMystery, CheckIdentifier.Fateful)
|
||||
: GetInvalid(LFatefulMysteryMissing, CheckIdentifier.Fateful);
|
||||
? GetValid(LFatefulMystery, Fateful)
|
||||
: GetInvalid(LFatefulMysteryMissing, Fateful);
|
||||
data.AddLine(result);
|
||||
}
|
||||
|
||||
|
@ -222,13 +223,13 @@ namespace PKHeX.Core
|
|||
{
|
||||
case WC6 wc6 when !wc6.CanBeReceivedByVersion(pkm.Version) && !pkm.WasTradedEgg:
|
||||
case WC7 wc7 when !wc7.CanBeReceivedByVersion(pkm.Version) && !pkm.WasTradedEgg:
|
||||
data.AddLine(GetInvalid(LEncGiftVersionNotDistributed, CheckIdentifier.GameOrigin));
|
||||
data.AddLine(GetInvalid(LEncGiftVersionNotDistributed, GameOrigin));
|
||||
return;
|
||||
case WC6 wc6 when wc6.RestrictLanguage != 0 && wc6.Language != wc6.RestrictLanguage:
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc6.RestrictLanguage, pkm.Language), CheckIdentifier.Language));
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc6.RestrictLanguage, pkm.Language), Language));
|
||||
return;
|
||||
case WC7 wc7 when wc7.RestrictLanguage != 0 && wc7.Language != wc7.RestrictLanguage:
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc7.RestrictLanguage, pkm.Language), CheckIdentifier.Language));
|
||||
data.AddLine(GetInvalid(string.Format(LOTLanguage, wc7.RestrictLanguage, pkm.Language), Language));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +238,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
// check for shiny locked gifts
|
||||
if (!g3.Shiny.IsValid(data.pkm))
|
||||
data.AddLine(GetInvalid(LEncGiftShinyMismatch, CheckIdentifier.Fateful));
|
||||
data.AddLine(GetInvalid(LEncGiftShinyMismatch, Fateful));
|
||||
}
|
||||
|
||||
private static void VerifyFatefulIngameActive(LegalityAnalysis data)
|
||||
|
@ -247,14 +248,14 @@ namespace PKHeX.Core
|
|||
{
|
||||
// can't have fateful until traded away, which clears ShadowID
|
||||
if (xk3.FatefulEncounter && xk3.ShadowID != 0 && data.EncounterMatch is EncounterStaticShadow)
|
||||
data.AddLine(GetInvalid(LFatefulInvalid, CheckIdentifier.Fateful));
|
||||
data.AddLine(GetInvalid(LFatefulInvalid, Fateful));
|
||||
|
||||
return; // fateful is set when transferred away
|
||||
}
|
||||
|
||||
var result = pkm.FatefulEncounter
|
||||
? GetValid(LFateful, CheckIdentifier.Fateful)
|
||||
: GetInvalid(LFatefulMissing, CheckIdentifier.Fateful);
|
||||
? GetValid(LFateful, Fateful)
|
||||
: GetInvalid(LFatefulMissing, Fateful);
|
||||
data.AddLine(result);
|
||||
}
|
||||
|
||||
|
@ -273,7 +274,7 @@ namespace PKHeX.Core
|
|||
bool Sun() => pkm.Version == (int)GameVersion.SN || pkm.Version == (int)GameVersion.US;
|
||||
bool Moon() => pkm.Version == (int)GameVersion.MN || pkm.Version == (int)GameVersion.UM;
|
||||
if (pkm.IsUntraded)
|
||||
data.AddLine(GetInvalid(LEvoTradeRequired, CheckIdentifier.Evolution));
|
||||
data.AddLine(GetInvalid(LEvoTradeRequired, Evolution));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -282,18 +283,18 @@ namespace PKHeX.Core
|
|||
{
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
|
||||
if (!IsCloseEnough(pb7.HeightAbsolute, pb7.CalcHeightAbsolute))
|
||||
data.AddLine(GetInvalid(LStatIncorrectHeight, CheckIdentifier.Encounter));
|
||||
data.AddLine(GetInvalid(LStatIncorrectHeight, Encounter));
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator -- THESE MUST MATCH EXACTLY
|
||||
if (!IsCloseEnough(pb7.WeightAbsolute, pb7.CalcWeightAbsolute))
|
||||
data.AddLine(GetInvalid(LStatIncorrectWeight, CheckIdentifier.Encounter));
|
||||
data.AddLine(GetInvalid(LStatIncorrectWeight, Encounter));
|
||||
if (pb7.Stat_CP != pb7.CalcCP && !IsStarter(pb7))
|
||||
data.AddLine(GetInvalid(LStatIncorrectCP, CheckIdentifier.Encounter));
|
||||
data.AddLine(GetInvalid(LStatIncorrectCP, Encounter));
|
||||
|
||||
if (IsTradeEvoRequired7b(data.EncounterOriginal, pb7))
|
||||
{
|
||||
var unevolved = LegalityAnalysis.SpeciesStrings[pb7.Species];
|
||||
var evolved = LegalityAnalysis.SpeciesStrings[pb7.Species + 1];
|
||||
data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved), CheckIdentifier.Evolution));
|
||||
data.AddLine(GetInvalid(string.Format(LEvoTradeReqOutsider, unevolved, evolved), Evolution));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,17 +6,17 @@ namespace PKHeX.Core
|
|||
{
|
||||
public static partial class Legal
|
||||
{
|
||||
private struct CountryTable
|
||||
private class CountryTable
|
||||
{
|
||||
public byte countryID;
|
||||
public byte mainform;
|
||||
public FormSubregionTable[] otherforms;
|
||||
public byte CountryID;
|
||||
public byte BaseForm;
|
||||
public FormSubregionTable[] SubRegionForms;
|
||||
}
|
||||
|
||||
private struct FormSubregionTable
|
||||
private class FormSubregionTable
|
||||
{
|
||||
public byte form;
|
||||
public int[] region;
|
||||
public byte Form;
|
||||
public int[] Regions;
|
||||
}
|
||||
|
||||
private static readonly int[][] VivillonCountryTable =
|
||||
|
@ -45,204 +45,204 @@ namespace PKHeX.Core
|
|||
private static readonly CountryTable[] RegionFormTable =
|
||||
{
|
||||
new CountryTable{
|
||||
countryID = 001, // Japan
|
||||
mainform = 05, // Elegant
|
||||
otherforms = new[]
|
||||
CountryID = 001, // Japan
|
||||
BaseForm = 05, // Elegant
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 02, region = new[] {03,04} },
|
||||
new FormSubregionTable { form = 13, region = new[] {48} },
|
||||
new FormSubregionTable { Form = 02, Regions = new[] {03,04} },
|
||||
new FormSubregionTable { Form = 13, Regions = new[] {48} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 049, // USA
|
||||
mainform = 07, // Modern
|
||||
otherforms = new[]
|
||||
CountryID = 049, // USA
|
||||
BaseForm = 07, // Modern
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 01, region = new[] {03,09,21,23,24,32,33,36,40,41,48,50} },
|
||||
new FormSubregionTable { form = 09, region = new[] {53} },
|
||||
new FormSubregionTable { form = 10, region = new[] {06,07,08,15,28,34,35,39,46,49} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {03,09,21,23,24,32,33,36,40,41,48,50} },
|
||||
new FormSubregionTable { Form = 09, Regions = new[] {53} },
|
||||
new FormSubregionTable { Form = 10, Regions = new[] {06,07,08,15,28,34,35,39,46,49} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 018, // Canada
|
||||
mainform = 01, // Polar
|
||||
otherforms = new[]
|
||||
CountryID = 018, // Canada
|
||||
BaseForm = 01, // Polar
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 00, region = new[] {12,13,14} },
|
||||
new FormSubregionTable { form = 07, region = new[] {05} },
|
||||
new FormSubregionTable { form = 10, region = new[] {04} },
|
||||
new FormSubregionTable { Form = 00, Regions = new[] {12,13,14} },
|
||||
new FormSubregionTable { Form = 07, Regions = new[] {05} },
|
||||
new FormSubregionTable { Form = 10, Regions = new[] {04} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 016, // Brazil
|
||||
mainform = 14, // Savanna
|
||||
otherforms = new[]
|
||||
CountryID = 016, // Brazil
|
||||
BaseForm = 14, // Savanna
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 17, region = new[] {03,06} },
|
||||
new FormSubregionTable { Form = 17, Regions = new[] {03,06} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 010, // Argentina
|
||||
mainform = 14, // Savanna
|
||||
otherforms = new[]
|
||||
CountryID = 010, // Argentina
|
||||
BaseForm = 14, // Savanna
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 01, region = new[] {21,24} },
|
||||
new FormSubregionTable { form = 03, region = new[] {16} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {21,24} },
|
||||
new FormSubregionTable { Form = 03, Regions = new[] {16} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 020, // Chile
|
||||
mainform = 08, // Marine
|
||||
otherforms = new[]
|
||||
CountryID = 020, // Chile
|
||||
BaseForm = 08, // Marine
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 01, region = new[] {12} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {12} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 036, // Mexico
|
||||
mainform = 15, // Sun
|
||||
otherforms = new[]
|
||||
CountryID = 036, // Mexico
|
||||
BaseForm = 15, // Sun
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 09, region = new[] {32} },
|
||||
new FormSubregionTable { form = 10, region = new[] {04,08,09,12,15,19,20,23,26,27,29} },
|
||||
new FormSubregionTable { Form = 09, Regions = new[] {32} },
|
||||
new FormSubregionTable { Form = 10, Regions = new[] {04,08,09,12,15,19,20,23,26,27,29} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 052, // Venezuela
|
||||
mainform = 09, // Archipelago
|
||||
otherforms = new[]
|
||||
CountryID = 052, // Venezuela
|
||||
BaseForm = 09, // Archipelago
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 17, region = new[] {17} },
|
||||
new FormSubregionTable { Form = 17, Regions = new[] {17} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 065, // Australia
|
||||
mainform = 09, // River
|
||||
otherforms = new[]
|
||||
CountryID = 065, // Australia
|
||||
BaseForm = 09, // River
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 04, region = new[] {07} },
|
||||
new FormSubregionTable { form = 15, region = new[] {04} },
|
||||
new FormSubregionTable { Form = 04, Regions = new[] {07} },
|
||||
new FormSubregionTable { Form = 15, Regions = new[] {04} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 066, // Austria
|
||||
mainform = 08, // Marine
|
||||
otherforms = new[]
|
||||
CountryID = 066, // Austria
|
||||
BaseForm = 08, // Marine
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 06, region = new[] {10} },
|
||||
new FormSubregionTable { Form = 06, Regions = new[] {10} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 073, // Czecg Republic
|
||||
mainform = 08, // Marine
|
||||
otherforms = new[]
|
||||
CountryID = 073, // Czecg Republic
|
||||
BaseForm = 08, // Marine
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 03, region = new[] {03} },
|
||||
new FormSubregionTable { Form = 03, Regions = new[] {03} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 076, // Finland
|
||||
mainform = 00, // Icy Snow
|
||||
otherforms = new[]
|
||||
CountryID = 076, // Finland
|
||||
BaseForm = 00, // Icy Snow
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 01, region = new[] {27} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {27} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 077, // France
|
||||
mainform = 06, // Meadow
|
||||
otherforms = new[]
|
||||
CountryID = 077, // France
|
||||
BaseForm = 06, // Meadow
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 03, region = new[] {18} },
|
||||
new FormSubregionTable { form = 08, region = new[] {04,06,08,19} },
|
||||
new FormSubregionTable { form = 16, region = new[] {27} },
|
||||
new FormSubregionTable { Form = 03, Regions = new[] {18} },
|
||||
new FormSubregionTable { Form = 08, Regions = new[] {04,06,08,19} },
|
||||
new FormSubregionTable { Form = 16, Regions = new[] {27} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 078, // Germany
|
||||
mainform = 03, // Continental
|
||||
otherforms = new[]
|
||||
CountryID = 078, // Germany
|
||||
BaseForm = 03, // Continental
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 06, region = new[] {04,13} },
|
||||
new FormSubregionTable { form = 08, region = new[] {05} },
|
||||
new FormSubregionTable { Form = 06, Regions = new[] {04,13} },
|
||||
new FormSubregionTable { Form = 08, Regions = new[] {05} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 078, // Italy
|
||||
mainform = 08, // Marine
|
||||
otherforms = new[]
|
||||
CountryID = 078, // Italy
|
||||
BaseForm = 08, // Marine
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 06, region = new[] {04,06} },
|
||||
new FormSubregionTable { Form = 06, Regions = new[] {04,06} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 085, // Lesotho
|
||||
mainform = 09, // Archipelago ??
|
||||
otherforms = new[]
|
||||
CountryID = 085, // Lesotho
|
||||
BaseForm = 09, // Archipelago ??
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 12, region = new[] {04} },
|
||||
new FormSubregionTable { Form = 12, Regions = new[] {04} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 096, // Norway
|
||||
mainform = 03, // Continental ??
|
||||
otherforms = new[]
|
||||
CountryID = 096, // Norway
|
||||
BaseForm = 03, // Continental ??
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 00, region = new[] {11} },
|
||||
new FormSubregionTable { form = 01, region = new[] {12,15,16,17,20,22} },
|
||||
new FormSubregionTable { form = 02, region = new[] {13,14} },
|
||||
new FormSubregionTable { Form = 00, Regions = new[] {11} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {12,15,16,17,20,22} },
|
||||
new FormSubregionTable { Form = 02, Regions = new[] {13,14} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 097, // Poland
|
||||
mainform = 03, // Continental
|
||||
otherforms = new[]
|
||||
CountryID = 097, // Poland
|
||||
BaseForm = 03, // Continental
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 04, region = new[] {11} },
|
||||
new FormSubregionTable { Form = 04, Regions = new[] {11} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 100, // Russia
|
||||
mainform = 01, // Polar
|
||||
otherforms = new[]
|
||||
CountryID = 100, // Russia
|
||||
BaseForm = 01, // Polar
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 00, region = new[] {14,22,34,38,40,52,66,88} },
|
||||
new FormSubregionTable { form = 03, region = new[] {29,46,51,69} },
|
||||
new FormSubregionTable { form = 10, region = new[] {20,24,25,28,33,71,73} },
|
||||
new FormSubregionTable { Form = 00, Regions = new[] {14,22,34,38,40,52,66,88} },
|
||||
new FormSubregionTable { Form = 03, Regions = new[] {29,46,51,69} },
|
||||
new FormSubregionTable { Form = 10, Regions = new[] {20,24,25,28,33,71,73} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 104, //South Africa
|
||||
mainform = 12, // River ??
|
||||
otherforms = new[]
|
||||
CountryID = 104, //South Africa
|
||||
BaseForm = 12, // River ??
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 03, region = new[] {03,05} },
|
||||
new FormSubregionTable { Form = 03, Regions = new[] {03,05} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 105, // Spain
|
||||
mainform = 08, // Marine
|
||||
otherforms = new[]
|
||||
CountryID = 105, // Spain
|
||||
BaseForm = 08, // Marine
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 06, region = new[] {11} },
|
||||
new FormSubregionTable { form = 12, region = new[] {07} },
|
||||
new FormSubregionTable { Form = 06, Regions = new[] {11} },
|
||||
new FormSubregionTable { Form = 12, Regions = new[] {07} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 107, // Sweden
|
||||
mainform = 03, // Continental
|
||||
otherforms = new[]
|
||||
CountryID = 107, // Sweden
|
||||
BaseForm = 03, // Continental
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 00, region = new[] {11,21} },
|
||||
new FormSubregionTable { form = 01, region = new[] {09,13} },
|
||||
new FormSubregionTable { Form = 00, Regions = new[] {11,21} },
|
||||
new FormSubregionTable { Form = 01, Regions = new[] {09,13} },
|
||||
}
|
||||
},
|
||||
new CountryTable{
|
||||
countryID = 169, // India
|
||||
mainform = 13, // Monsoon ??
|
||||
otherforms = new[]
|
||||
CountryID = 169, // India
|
||||
BaseForm = 13, // Monsoon ??
|
||||
SubRegionForms = new[]
|
||||
{
|
||||
new FormSubregionTable { form = 17, region = new[] {12} },
|
||||
new FormSubregionTable { Form = 17, Regions = new[] {12} },
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -259,14 +259,14 @@ namespace PKHeX.Core
|
|||
if (!VivillonCountryTable[form].Contains(country))
|
||||
return false; // Country mismatch
|
||||
|
||||
var ct = Array.Find(RegionFormTable, t => t.countryID == country);
|
||||
if (ct.otherforms == null) // empty struct = no forms referenced
|
||||
var ct = Array.Find(RegionFormTable, t => t.CountryID == country);
|
||||
if (ct.SubRegionForms == null) // empty struct = no forms referenced
|
||||
return true; // No subregion table
|
||||
|
||||
if (ct.mainform == form)
|
||||
return !ct.otherforms.Any(e => e.region.Contains(region)); //true if Mainform not in other specific region
|
||||
if (ct.BaseForm == form)
|
||||
return !ct.SubRegionForms.Any(e => e.Regions.Contains(region)); //true if Mainform not in other specific region
|
||||
|
||||
return ct.otherforms.Any(e => e.form == form && e.region.Contains(region));
|
||||
return ct.SubRegionForms.Any(e => e.Form == form && e.Regions.Contains(region));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -276,17 +276,17 @@ namespace PKHeX.Core
|
|||
/// <param name="region">Console Region ID</param>
|
||||
public static int GetVivillonPattern(int country, int region)
|
||||
{
|
||||
var ct = Array.Find(RegionFormTable, t => t.countryID == country);
|
||||
if (ct.otherforms == null) // empty struct = no forms referenced
|
||||
return ct.mainform; // No subregion table
|
||||
var ct = Array.Find(RegionFormTable, t => t.CountryID == country);
|
||||
if (ct.SubRegionForms == null) // empty struct = no forms referenced
|
||||
return ct.BaseForm; // No subregion table
|
||||
|
||||
foreach (var sub in ct.otherforms)
|
||||
foreach (var sub in ct.SubRegionForms)
|
||||
{
|
||||
if (sub.region.Contains(region))
|
||||
return sub.form;
|
||||
if (sub.Regions.Contains(region))
|
||||
return sub.Form;
|
||||
}
|
||||
|
||||
return ct.mainform;
|
||||
return ct.BaseForm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace PKHeX.Core
|
|||
public InventoryItem Clone() => (InventoryItem) MemberwiseClone();
|
||||
|
||||
// Check Pouch Compatibility
|
||||
public bool Valid(ushort[] LegalItems, bool HaX, int MaxItemID)
|
||||
public bool Valid(IList<ushort> LegalItems, bool HaX, int MaxItemID)
|
||||
{
|
||||
if (Index == 0)
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue