2016-07-18 05:39:18 +00:00
using System ;
2017-07-02 02:43:51 +00:00
using System.Diagnostics ;
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
using System.Linq ;
2016-07-18 05:39:18 +00:00
2017-01-08 07:54:09 +00:00
namespace PKHeX.Core
2016-07-18 05:39:18 +00:00
{
2017-10-24 06:12:58 +00:00
/// <summary>
/// <see cref="PersonalInfo"/> table (array).
/// </summary>
/// <remarks>
/// Serves as the main object that is accessed for stat data in a particular generation/game format.
/// </remarks>
2016-07-18 05:39:18 +00:00
public class PersonalTable
{
2019-09-23 23:56:47 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.SWSH"/>.
/// </summary>
2020-12-24 01:14:38 +00:00
public static readonly PersonalTable SWSH = GetTable ( "swsh" , GameVersion . SWSH ) ;
2019-09-23 23:56:47 +00:00
2018-11-11 21:11:07 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.GG"/>.
/// </summary>
public static readonly PersonalTable GG = GetTable ( "gg" , GameVersion . GG ) ;
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.USUM"/>.
/// </summary>
2017-11-08 19:31:04 +00:00
public static readonly PersonalTable USUM = GetTable ( "uu" , GameVersion . USUM ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.SM"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable SM = GetTable ( "sm" , GameVersion . SM ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.ORAS"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable AO = GetTable ( "ao" , GameVersion . ORAS ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.XY"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable XY = GetTable ( "xy" , GameVersion . XY ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.B2W2"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable B2W2 = GetTable ( "b2w2" , GameVersion . B2W2 ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.BW"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable BW = GetTable ( "bw" , GameVersion . BW ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.HGSS"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable HGSS = GetTable ( "hgss" , GameVersion . HGSS ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.Pt"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable Pt = GetTable ( "pt" , GameVersion . Pt ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.DP"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable DP = GetTable ( "dp" , GameVersion . DP ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.LG"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable LG = GetTable ( "lg" , GameVersion . LG ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.FR"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable FR = GetTable ( "fr" , GameVersion . FR ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.E"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable E = GetTable ( "e" , GameVersion . E ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.RS"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable RS = GetTable ( "rs" , GameVersion . RS ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.C"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable C = GetTable ( "c" , GameVersion . C ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.GS"/>.
/// </summary>
2017-07-29 18:54:52 +00:00
public static readonly PersonalTable GS = GetTable ( "c" , GameVersion . GS ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.RB"/>.
/// </summary>
2019-01-22 04:06:02 +00:00
public static readonly PersonalTable RB = GetTable ( "rb" , GameVersion . RB ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Personal Table used in <see cref="GameVersion.YW"/>.
/// </summary>
2019-01-22 04:06:02 +00:00
public static readonly PersonalTable Y = GetTable ( "y" , GameVersion . YW ) ;
2018-07-27 02:34:27 +00:00
2017-07-29 18:54:52 +00:00
private static PersonalTable GetTable ( string game , GameVersion format )
{
2020-12-22 01:17:56 +00:00
return new ( Util . GetBinaryResource ( $"personal_{game}" ) , format ) ;
2017-07-29 18:54:52 +00:00
}
2016-07-18 05:39:18 +00:00
2021-01-02 01:08:49 +00:00
private static Func < byte [ ] , PersonalInfo > GetConstructor ( GameVersion format ) = > format switch
2016-07-18 05:39:18 +00:00
{
2021-01-02 01:08:49 +00:00
GameVersion . RB or GameVersion . YW = > z = > new PersonalInfoG1 ( z ) ,
GameVersion . GS or GameVersion . C = > z = > new PersonalInfoG2 ( z ) ,
GameVersion . RS or GameVersion . E or GameVersion . FR or GameVersion . LG = > z = > new PersonalInfoG3 ( z ) ,
GameVersion . DP or GameVersion . Pt or GameVersion . HGSS = > z = > new PersonalInfoG4 ( z ) ,
GameVersion . BW = > z = > new PersonalInfoBW ( z ) ,
GameVersion . B2W2 = > z = > new PersonalInfoB2W2 ( z ) ,
GameVersion . XY = > z = > new PersonalInfoXY ( z ) ,
GameVersion . ORAS = > z = > new PersonalInfoORAS ( z ) ,
GameVersion . SM or GameVersion . USUM = > z = > new PersonalInfoSM ( z ) ,
GameVersion . GG = > z = > new PersonalInfoGG ( z ) ,
_ = > z = > new PersonalInfoSWSH ( z ) ,
} ;
private static int GetEntrySize ( GameVersion format ) = > format switch
2017-06-18 20:02:02 +00:00
{
2021-01-02 01:08:49 +00:00
GameVersion . RB or GameVersion . YW = > PersonalInfoG1 . SIZE ,
GameVersion . GS or GameVersion . C = > PersonalInfoG2 . SIZE ,
GameVersion . RS or GameVersion . E or GameVersion . FR or GameVersion . LG = > PersonalInfoG3 . SIZE ,
GameVersion . DP or GameVersion . Pt or GameVersion . HGSS = > PersonalInfoG4 . SIZE ,
GameVersion . BW = > PersonalInfoBW . SIZE ,
GameVersion . B2W2 = > PersonalInfoB2W2 . SIZE ,
GameVersion . XY = > PersonalInfoXY . SIZE ,
GameVersion . ORAS = > PersonalInfoORAS . SIZE ,
GameVersion . SM or GameVersion . USUM or GameVersion . GG = > PersonalInfoSM . SIZE ,
GameVersion . SWSH = > PersonalInfoSWSH . SIZE ,
_ = > - 1 ,
} ;
2018-07-27 02:34:27 +00:00
2017-07-29 18:54:52 +00:00
static PersonalTable ( ) // Finish Setup
{
2017-09-06 16:12:56 +00:00
FixPersonalTableG1 ( ) ;
2017-07-29 18:54:52 +00:00
PopulateGen3Tutors ( ) ;
PopulateGen4Tutors ( ) ;
2019-11-16 01:34:18 +00:00
CopyDexitGenders ( ) ;
2017-07-29 18:54:52 +00:00
}
2018-07-27 02:34:27 +00:00
2017-09-06 16:12:56 +00:00
private static void FixPersonalTableG1 ( )
2017-07-29 18:54:52 +00:00
{
2017-09-06 16:12:56 +00:00
// Load Gen2 Gender Ratios into Gen1
2021-01-01 23:24:11 +00:00
PersonalInfo [ ] rb = RB . Table , y = Y . Table , gs = GS . Table ;
2021-07-27 06:33:56 +00:00
for ( int i = Legal . MaxSpeciesID_1 ; i > = 0 ; i - - )
2021-01-01 23:24:11 +00:00
rb [ i ] . Gender = y [ i ] . Gender = gs [ i ] . Gender ;
2017-07-29 18:54:52 +00:00
}
2018-07-27 02:34:27 +00:00
2017-07-29 18:54:52 +00:00
private static void PopulateGen3Tutors ( )
{
// Update Gen3 data with Emerald's data, FR/LG is a subset of Emerald's compatibility.
2020-06-17 02:46:22 +00:00
var machine = BinLinker . Unpack ( Util . GetBinaryResource ( "hmtm_g3.pkl" ) , "g3" ) ;
2020-03-20 22:18:59 +00:00
var tutors = BinLinker . Unpack ( Util . GetBinaryResource ( "tutors_g3.pkl" ) , "g3" ) ;
2021-01-01 23:24:11 +00:00
var table = E . Table ;
2021-07-27 06:33:56 +00:00
for ( int i = Legal . MaxSpeciesID_3 ; i > = 0 ; i - - )
2017-07-29 18:54:52 +00:00
{
2021-07-27 06:33:56 +00:00
var entry = table [ i ] ;
entry . AddTMHM ( machine [ i ] ) ;
entry . AddTypeTutors ( tutors [ i ] ) ;
2017-07-29 18:54:52 +00:00
}
}
2018-07-27 02:34:27 +00:00
2017-07-29 18:54:52 +00:00
private static void PopulateGen4Tutors ( )
{
2020-03-20 22:18:59 +00:00
var tutors = BinLinker . Unpack ( Util . GetBinaryResource ( "tutors_g4.pkl" ) , "g4" ) ;
2021-01-01 23:24:11 +00:00
var table = HGSS . Table ;
2017-08-27 18:04:31 +00:00
for ( int i = 0 ; i < tutors . Length ; i + + )
2021-01-01 23:24:11 +00:00
table [ i ] . AddTypeTutors ( tutors [ i ] ) ;
2017-07-29 18:54:52 +00:00
}
2016-07-18 05:39:18 +00:00
2019-11-16 01:34:18 +00:00
/// <summary>
/// Sword/Shield do not contain personal data (stubbed) for all species that are not allowed to visit the game.
/// Copy all the genders from <see cref="USUM"/>'s table for all past species, since we need it for <see cref="PKX.Personal"/> gender lookups for all generations.
/// </summary>
private static void CopyDexitGenders ( )
{
2021-01-01 23:24:11 +00:00
var swsh = SWSH . Table ;
var usum = USUM . Table ;
2020-09-19 14:52:35 +00:00
for ( int i = 1 ; i < = Legal . MaxSpeciesID_7_USUM ; i + + )
2019-11-16 01:34:18 +00:00
{
2020-09-19 14:52:35 +00:00
var ss = swsh [ i ] ;
2019-11-16 01:34:18 +00:00
if ( ss . HP = = 0 )
2020-09-19 14:52:35 +00:00
ss . Gender = usum [ i ] . Gender ;
2019-11-16 01:34:18 +00:00
}
}
2018-03-18 03:05:35 +00:00
public PersonalTable ( byte [ ] data , GameVersion format )
2017-06-18 20:02:02 +00:00
{
2018-07-27 02:34:27 +00:00
var get = GetConstructor ( format ) ;
2017-06-18 20:02:02 +00:00
int size = GetEntrySize ( format ) ;
2019-09-23 23:56:47 +00:00
byte [ ] [ ] entries = data . Split ( size ) ;
2021-01-01 23:24:11 +00:00
var table = new PersonalInfo [ entries . Length ] ;
for ( int i = 0 ; i < table . Length ; i + + )
table [ i ] = get ( entries [ i ] ) ;
2018-06-18 04:52:52 +00:00
2021-01-01 23:24:11 +00:00
Table = table ;
2018-06-18 04:52:52 +00:00
MaxSpeciesID = format . GetMaxSpeciesID ( ) ;
2019-01-22 04:06:02 +00:00
Game = format ;
2017-06-18 20:02:02 +00:00
}
2018-07-27 02:34:27 +00:00
2016-07-18 05:39:18 +00:00
private readonly PersonalInfo [ ] Table ;
2017-11-07 06:44:51 +00:00
/// <summary>
/// Gets an index from the inner <see cref="Table"/> array.
/// </summary>
/// <remarks>Has built in length checks; returns empty (0) entry if out of range.</remarks>
/// <param name="index">Index to retrieve</param>
/// <returns>Requested index entry</returns>
2016-07-18 05:39:18 +00:00
public PersonalInfo this [ int index ]
{
2016-10-24 04:57:43 +00:00
get
{
2021-01-01 23:24:11 +00:00
var table = Table ;
if ( ( uint ) index > = table . Length )
return table [ 0 ] ;
return table [ index ] ;
2016-10-24 04:57:43 +00:00
}
set
{
2021-01-01 23:24:11 +00:00
var table = Table ;
if ( ( uint ) index > = table . Length )
2016-10-24 04:57:43 +00:00
return ;
2021-01-01 23:24:11 +00:00
table [ index ] = value ;
2016-10-24 04:57:43 +00:00
}
2016-07-18 05:39:18 +00:00
}
2016-07-18 06:04:39 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
2020-12-11 04:42:30 +00:00
/// Gets the <see cref="PersonalInfo"/> entry index for a given <see cref="PKM.Species"/> and <see cref="PKM.Form"/>.
2017-11-07 06:44:51 +00:00
/// </summary>
/// <param name="species"><see cref="PKM.Species"/></param>
2020-12-11 04:42:30 +00:00
/// <param name="form"><see cref="PKM.Form"/></param>
2017-11-07 06:44:51 +00:00
/// <returns>Entry index for the input criteria</returns>
2020-12-11 04:42:30 +00:00
public int GetFormIndex ( int species , int form )
2016-07-18 06:04:39 +00:00
{
2021-01-01 23:24:11 +00:00
if ( ( uint ) species < = MaxSpeciesID )
return Table [ species ] . FormIndex ( species , form ) ;
Debug . WriteLine ( $"Requested out of bounds {nameof(species)}: {species} (max={MaxSpeciesID})" ) ;
return 0 ;
2016-07-18 06:04:39 +00:00
}
2017-11-07 06:44:51 +00:00
/// <summary>
2020-12-11 04:42:30 +00:00
/// Gets the <see cref="PersonalInfo"/> entry for a given <see cref="PKM.Species"/> and <see cref="PKM.Form"/>.
2017-11-07 06:44:51 +00:00
/// </summary>
/// <param name="species"><see cref="PKM.Species"/></param>
2020-12-11 04:42:30 +00:00
/// <param name="form"><see cref="PKM.Form"/></param>
2017-11-07 06:44:51 +00:00
/// <returns>Entry for the input criteria</returns>
2020-12-11 04:42:30 +00:00
public PersonalInfo GetFormEntry ( int species , int form )
2016-07-18 06:04:39 +00:00
{
2020-12-11 04:42:30 +00:00
return this [ GetFormIndex ( species , form ) ] ;
2016-07-18 06:04:39 +00:00
}
2016-11-12 18:19:17 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
2021-03-24 00:05:15 +00:00
/// Count of entries in the table, which includes default species entries and their separate <see cref="PKM.Form"/> entries.
2017-11-07 06:44:51 +00:00
/// </summary>
2016-11-12 18:19:17 +00:00
public int TableLength = > Table . Length ;
2017-11-07 06:44:51 +00:00
2018-06-25 04:55:00 +00:00
/// <summary>
/// Maximum Species ID for the Table.
/// </summary>
2018-06-18 04:52:52 +00:00
public readonly int MaxSpeciesID ;
2019-01-22 04:06:02 +00:00
/// <summary>
/// Game(s) the <see cref="Table"/> originated from.
/// </summary>
public readonly GameVersion Game ;
2017-11-07 06:44:51 +00:00
/// <summary>
/// Gets form names for every species.
/// </summary>
/// <param name="species">Raw string resource (Species) for the corresponding table.</param>
/// <param name="MaxSpecies">Max Species ID (<see cref="PKM.Species"/>)</param>
/// <returns>Array of species containing an array of form names for that species.</returns>
2017-06-18 01:37:19 +00:00
public string [ ] [ ] GetFormList ( string [ ] species , int MaxSpecies )
2016-11-12 18:19:17 +00:00
{
string [ ] [ ] FormList = new string [ MaxSpecies + 1 ] [ ] ;
2017-07-29 18:54:52 +00:00
for ( int i = 0 ; i < FormList . Length ; i + + )
2016-11-12 18:19:17 +00:00
{
2020-12-11 04:42:30 +00:00
int FormCount = this [ i ] . FormCount ;
2016-11-12 18:19:17 +00:00
FormList [ i ] = new string [ FormCount ] ;
2019-09-10 07:21:51 +00:00
if ( FormCount < = 0 )
continue ;
2016-11-12 18:19:17 +00:00
FormList [ i ] [ 0 ] = species [ i ] ;
for ( int j = 1 ; j < FormCount ; j + + )
2017-09-30 05:58:25 +00:00
FormList [ i ] [ j ] = $"{species[i]} {j}" ;
2016-11-12 18:19:17 +00:00
}
return FormList ;
}
2017-11-07 06:44:51 +00:00
/// <summary>
2020-12-11 04:42:30 +00:00
/// Gets an arranged list of Form names and indexes for use with the individual <see cref="PersonalInfo"/> <see cref="PKM.Form"/> values.
2017-11-07 06:44:51 +00:00
/// </summary>
2020-12-11 04:42:30 +00:00
/// <param name="forms">Raw string resource (Forms) for the corresponding table.</param>
2017-11-07 06:44:51 +00:00
/// <param name="species">Raw string resource (Species) for the corresponding table.</param>
/// <param name="MaxSpecies">Max Species ID (<see cref="PKM.Species"/>)</param>
/// <param name="baseForm">Pointers for base form IDs</param>
/// <param name="formVal">Pointers for table indexes for each form</param>
/// <returns>Sanitized list of species names, and outputs indexes for various lookup purposes.</returns>
2020-12-11 04:42:30 +00:00
public string [ ] GetPersonalEntryList ( string [ ] [ ] forms , string [ ] species , int MaxSpecies , out int [ ] baseForm , out int [ ] formVal )
2016-11-12 18:19:17 +00:00
{
string [ ] result = new string [ Table . Length ] ;
baseForm = new int [ result . Length ] ;
formVal = new int [ result . Length ] ;
for ( int i = 0 ; i < = MaxSpecies ; i + + )
{
result [ i ] = species [ i ] ;
2020-12-11 04:42:30 +00:00
if ( forms [ i ] . Length = = 0 )
2019-10-04 05:21:33 +00:00
continue ;
2020-06-17 02:46:22 +00:00
int basePtr = this [ i ] . FormStatsIndex ;
if ( basePtr < = 0 )
2019-10-04 05:21:33 +00:00
continue ;
2020-12-11 04:42:30 +00:00
for ( int j = 1 ; j < forms [ i ] . Length ; j + + )
2016-11-12 18:19:17 +00:00
{
2020-06-17 02:46:22 +00:00
int ptr = basePtr + j - 1 ;
2016-11-12 18:19:17 +00:00
baseForm [ ptr ] = i ;
formVal [ ptr ] = j ;
2020-12-11 04:42:30 +00:00
result [ ptr ] = forms [ i ] [ j ] ;
2016-11-12 18:19:17 +00:00
}
}
return result ;
}
2017-11-07 06:44:51 +00:00
/// <summary>
/// Checks to see if either of the input type combinations exist in the table.
/// </summary>
/// <remarks>Only useful for checking Generation 1 <see cref="PK1.Type_A"/> and <see cref="PK1.Type_B"/> properties.</remarks>
2020-06-17 02:46:22 +00:00
/// <param name="type1">First type</param>
/// <param name="type2">Second type</param>
2017-11-07 06:44:51 +00:00
/// <returns>Indication that the combination exists in the table.</returns>
2020-06-17 02:46:22 +00:00
public bool IsValidTypeCombination ( int type1 , int type2 )
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
{
2020-06-17 02:46:22 +00:00
return Table . Any ( p = > p . IsValidTypeCombination ( type1 , type2 ) ) ;
Generation 1 and 2 legal Improvements (#1099)
* Refactor parseMovesForEncounter to gather valid moves for species encounter, some Pokemon can have valid encounters with different source species from the encounter, the valid moves change if the encounter species change because some preevolutions moves are illegal if pokemon caught already evolved.
Example, generation 1 Pikachu that can have a RBY Pikachu encounter and GSC Pichu encounter, the valid moves for the first encounters should not have any Pichu exclusive evolution moves
Also assign the encounter match from gb when parsing moves like the variable Encounter Match, to store the encounter that is valid for the pokemon moves instead the first encounter.
Store the species encounter, this will be needed to check if the evolution is valid for species that evolve leveling with a given learned move
* Add Tradeback Status to the pokemon, this variable for generations 1 and 2 use data like the catch rate to determine if trade between generations 1 and 2 was possible.
If analysis is for VC games tradeback have value NotTradeback for every gen 1 pokemon, but for cart saves some pokemon can be determine that have not been tradeback, if catch rate match species catch rate but do not match a valid generation 2 held item that means the pokemon habe been never traded to generation 2 games, that allow to discart encounters and moves from generation 2.
Also if is not tradeback catch rate is used to filter encounters, catch rate determine in what species was captured the pokemon discarting some preevolutions moves
Also add option for generation 1 cart save analysis to check legal status not allowing generation 2 games, like VC games but with Stadium allowed, like the generation 1 non tradeback rules from Smogon
Also change evolution chains to included generation 2 preevolutions for gen 1 pokemon if tradeback was possible, it is needed to avoid parsemoves to check illegal pokemon like Hitmonchan with Tyrogue level up moves
* Check legal values of generation 1 type and catch rate
Replace pokemon catch rate after changind pokemon species always if pokemon was not tradeback from generation 2, the catch rate will keep unchanged only if it can be a held item and do not match species catch rate (default item)
Also if catch rate is changed use base species catch rate to avoid legal errors if the catch rate of the evolution species if is not possible with the current moves
* Filter ingame trades and static encounters with catch rate for generation 1 non tradeback
* Fix min moves for generation 1 metapod encounter
* Clean up
* Fix encounter level for generation 1, valid moves are those with one level after the encounter level, pokemon can not learn a new move until level up
Clean up type validation
Fix generation 3 fatefull encounter eggs, the pokemon lost the fatefull mark when it hatch
* Clean-up
* Use new variable EncounterSpecies when it is needed to detect the species of the encounter, the old code wont work if the encounter is a wild slots array
* Fix generation 1 evolution chains and catch rate as default held item
* Fix Generation 1 Yellow Pikachu and Kadabra catch rates
2017-04-27 04:27:59 +00:00
}
2016-07-18 05:39:18 +00:00
}
}