Add memory rarity table

This commit is contained in:
Kurt 2018-10-12 17:45:52 -07:00
parent c8d874462c
commit b7acb7fa1d
4 changed files with 71 additions and 43 deletions

View file

@ -146,6 +146,13 @@ namespace PKHeX.Core
return -1; return -1;
} }
/// <summary>
/// Checks if the <see cref="g1"/> version (or subset versions) is equivalent to <see cref="g2"/>.
/// </summary>
/// <param name="g1">Version (set)</param>
/// <param name="g2">Individual version</param>
public static bool Contains(this GameVersion g1, int g2) => g1.Contains((GameVersion) g2);
/// <summary> /// <summary>
/// Checks if the <see cref="g1"/> version (or subset versions) is equivalent to <see cref="g2"/>. /// Checks if the <see cref="g1"/> version (or subset versions) is equivalent to <see cref="g2"/>.
/// </summary> /// </summary>

View file

@ -59,46 +59,55 @@ namespace PKHeX.Core
new[] { 57, 19, 70, 15, 249, 127, 291}, // Move IDs new[] { 57, 19, 70, 15, 249, 127, 291}, // Move IDs
}; };
internal static readonly int[][] LocationsWithPKCenter = internal static readonly int[] LocationsWithPKCenter =
{ {
new[] { // Kalos locations with a PKMN CENTER
// Kalos locations with a PKMN CENTER 18, // Santalune City
18, // Santalune City 22, // Lumiose City
22, // Lumiose City 30, // Camphrier Town
30, // Camphrier Town 40, // Cyllage City
40, // Cyllage City 44, // Ambrette Town
44, // Ambrette Town 52, // Geosenge Towny
52, // Geosenge Towny 58, // Shalour City
58, // Shalour City 64, // Coumarine City
64, // Coumarine City 70, // Laverre City
70, // Laverre City 76, // Dendemille Town
76, // Dendemille Town 86, // Anistar City
86, // Anistar City 90, // Couriway Town
90, // Couriway Town 94, // Snowbelle City
94, // Snowbelle City 106, // Pokémon League (X/Y)
106, // Pokémon League (X/Y)
// Hoenn locations with a PKMN CENTER // Hoenn locations with a PKMN CENTER
172, // Oldale Town 172, // Oldale Town
174, // Dewford Town 174, // Dewford Town
176, // Lavaridge Town 176, // Lavaridge Town
178, // Fallarbor Town 178, // Fallarbor Town
180, // Verdanturf Town 180, // Verdanturf Town
182, // Pacifidlog Town 182, // Pacifidlog Town
184, // Petalburg City 184, // Petalburg City
186, // Slateport City 186, // Slateport City
188, // Mauville City 188, // Mauville City
190, // Rustboro City 190, // Rustboro City
192, // Fortree City 192, // Fortree City
194, // Lilycove City 194, // Lilycove City
196, // Mossdeep City 196, // Mossdeep City
198, // Sootopolis City 198, // Sootopolis City
200, // Ever Grande City 200, // Ever Grande City
202, // Pokémon League (OR/AS) 202, // Pokémon League (OR/AS)
},
new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching
}; };
internal static readonly byte[] MemoryMinIntensity = internal static GameVersion GetGameVersionForPokeCenterIndex(int index)
{
return PokeCenterVersion[index] == 0 ? GameVersion.XY : GameVersion.ORAS;
}
private static readonly int[] PokeCenterVersion = // Region matching
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
private static readonly byte[] MemoryMinIntensity =
{ {
0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
@ -109,7 +118,20 @@ namespace PKHeX.Core
3, 3, 3, 3, 3, 2, 3, 4, 4, 2, 3, 3, 3, 3, 3, 2, 3, 4, 4, 2,
}; };
internal static readonly uint[] MemoryFeelings = public static int GetMemoryRarity(int memory) => (uint) memory >= MemoryRandChance.Length ? -1 : MemoryRandChance[memory];
private static readonly byte[] MemoryRandChance =
{
000, 100, 100, 100, 100, 005, 005, 005, 005, 005,
005, 005, 005, 005, 010, 020, 010, 001, 050, 030,
005, 005, 020, 005, 005, 005, 001, 050, 100, 050,
050, 002, 002, 005, 005, 005, 005, 005, 005, 002,
020, 020, 005, 010, 001, 001, 050, 030, 020, 020,
010, 010, 001, 010, 001, 050, 030, 030, 030, 002,
050, 020, 020, 020, 020, 010, 010, 050, 020, 005,
};
private static readonly uint[] MemoryFeelings =
{ {
0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0, 0x000000, 0x04CBFD, 0x004BFD, 0x04CBFD, 0x04CBFD, 0xFFFBFB, 0x84FFF9, 0x47FFFF, 0xBF7FFA, 0x7660B0,
0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD, 0x80BDF9, 0x88FB7A, 0x083F79, 0x0001FE, 0xCFEFFF, 0x84EBAF, 0xB368B0, 0x091F7E, 0x0320A0, 0x080DDD,

View file

@ -57,7 +57,6 @@ namespace PKHeX.Core
var eabil = GetEncounterFixedAbilityNumber(EncounterMatch); var eabil = GetEncounterFixedAbilityNumber(EncounterMatch);
if (eabil >= 0) if (eabil >= 0)
{ {
if ((data.pkm.AbilityNumber == 4) != (eabil == 4)) if ((data.pkm.AbilityNumber == 4) != (eabil == 4))
return GetInvalid(LAbilityHiddenFail); return GetInvalid(LAbilityHiddenFail);
if (eabil > 0) if (eabil > 0)

View file

@ -207,7 +207,7 @@ namespace PKHeX.Core
switch (m) switch (m)
{ {
case 6 when !Memories.LocationsWithPKCenter[0].Contains(t): case 6 when !Memories.LocationsWithPKCenter.Contains(t):
return GetInvalid(string.Format(LMemoryArgBadPokecenter, tr)); return GetInvalid(string.Format(LMemoryArgBadPokecenter, tr));
// {0} saw {2} carrying {1} on its back. {4} that {3}. // {0} saw {2} carrying {1} on its back. {4} that {3}.
@ -296,11 +296,11 @@ namespace PKHeX.Core
return; return;
case 6: // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}. case 6: // {0} went to the Pokémon Center in {2} with {1} and had its tired body healed there. {4} that {3}.
int matchingOriginGame = Array.IndexOf(Memories.LocationsWithPKCenter[0], pkm.OT_TextVar); int matchingOriginGame = Array.IndexOf(Memories.LocationsWithPKCenter, pkm.OT_TextVar);
if (matchingOriginGame != -1) if (matchingOriginGame != -1)
{ {
int gameID = Memories.LocationsWithPKCenter[1][matchingOriginGame]; var gameID = Memories.GetGameVersionForPokeCenterIndex(matchingOriginGame);
if ((pkm.XY && gameID != 0) || (pkm.AO && gameID != 1)) if (!gameID.Contains((GameVersion)pkm.Version))
data.AddLine(Severity.Invalid, string.Format(LMemoryArgBadLocation, L_XOT), CheckIdentifier.Memory); data.AddLine(Severity.Invalid, string.Format(LMemoryArgBadLocation, L_XOT), CheckIdentifier.Memory);
} }
data.AddLine(VerifyCommonMemory(pkm, 0)); data.AddLine(VerifyCommonMemory(pkm, 0));