2016-11-13 21:11:53 +00:00
using System ;
2018-08-03 03:11:42 +00:00
using System.Collections.Generic ;
2020-08-18 22:39:45 +00:00
using System.Linq ;
2022-01-03 05:35:59 +00:00
using static System . Buffers . Binary . BinaryPrimitives ;
2016-06-20 04:22:43 +00:00
2017-01-08 07:54:09 +00:00
namespace PKHeX.Core
2016-06-20 04:22:43 +00:00
{
2017-10-23 22:45:58 +00:00
/// <summary>
/// Mystery Gift Template File
/// </summary>
2022-01-06 00:46:23 +00:00
public abstract class MysteryGift : IEncounterable , IMoveset , IRelearn
2016-06-20 04:22:43 +00:00
{
2016-10-06 04:06:24 +00:00
/// <summary>
/// Determines whether or not the given length of bytes is valid for a mystery gift.
/// </summary>
/// <param name="len">Length, in bytes, of the data of which to determine validity.</param>
/// <returns>A boolean indicating whether or not the given length is valid for a mystery gift.</returns>
2020-06-17 02:46:22 +00:00
public static bool IsMysteryGift ( long len ) = > Sizes . Contains ( ( int ) len ) ;
2018-08-03 03:11:42 +00:00
2022-02-05 01:35:15 +00:00
private static readonly HashSet < int > Sizes = new ( ) { WA8 . Size , WB8 . Size , WC8 . Size , WC6Full . Size , WC6 . Size , PGF . Size , PGT . Size , PCD . Size } ;
2016-10-06 04:06:24 +00:00
/// <summary>
/// Converts the given data to a <see cref="MysteryGift"/>.
/// </summary>
/// <param name="data">Raw data of the mystery gift.</param>
/// <param name="ext">Extension of the file from which the <paramref name="data"/> was retrieved.</param>
/// <returns>An instance of <see cref="MysteryGift"/> representing the given data, or null if <paramref name="data"/> or <paramref name="ext"/> is invalid.</returns>
2017-06-18 01:37:19 +00:00
/// <remarks>This overload differs from <see cref="GetMysteryGift(byte[])"/> by checking the <paramref name="data"/>/<paramref name="ext"/> combo for validity. If either is invalid, a null reference is returned.</remarks>
2021-01-02 01:08:49 +00:00
public static DataMysteryGift ? GetMysteryGift ( byte [ ] data , string ext ) = > data . Length switch
2016-06-20 04:22:43 +00:00
{
2021-01-02 01:08:49 +00:00
PGT . Size when ext = = ".pgt" = > new PGT ( data ) ,
PCD . Size when ext is ".pcd" or ".wc4" = > new PCD ( data ) ,
PGF . Size when ext = = ".pgf" = > new PGF ( data ) ,
WC6 . Size when ext = = ".wc6" = > new WC6 ( data ) ,
WC7 . Size when ext = = ".wc7" = > new WC7 ( data ) ,
WB7 . Size when ext = = ".wb7" = > new WB7 ( data ) ,
WR7 . Size when ext = = ".wr7" = > new WR7 ( data ) ,
WC8 . Size when ext is ".wc8" or ".wc8full" = > new WC8 ( data ) ,
2021-11-20 02:23:49 +00:00
WB8 . Size when ext is ".wb8" = > new WB8 ( data ) ,
2022-02-05 01:35:15 +00:00
WA8 . Size when ext is ".wa8" = > new WA8 ( data ) ,
2021-01-02 01:08:49 +00:00
WB7 . SizeFull when ext = = ".wb7full" = > new WB7 ( data ) ,
WC6Full . Size when ext = = ".wc6full" = > new WC6Full ( data ) . Gift ,
WC7Full . Size when ext = = ".wc7full" = > new WC7Full ( data ) . Gift ,
2021-08-20 20:49:20 +00:00
_ = > null ,
2021-01-02 01:08:49 +00:00
} ;
2016-10-06 04:06:24 +00:00
/// <summary>
/// Converts the given data to a <see cref="MysteryGift"/>.
/// </summary>
/// <param name="data">Raw data of the mystery gift.</param>
/// <returns>An instance of <see cref="MysteryGift"/> representing the given data, or null if <paramref name="data"/> is invalid.</returns>
2021-01-02 01:08:49 +00:00
public static DataMysteryGift ? GetMysteryGift ( byte [ ] data ) = > data . Length switch
2016-07-24 22:44:44 +00:00
{
2021-01-02 01:08:49 +00:00
PGT . Size = > new PGT ( data ) ,
PCD . Size = > new PCD ( data ) ,
PGF . Size = > new PGF ( data ) ,
WR7 . Size = > new WR7 ( data ) ,
WC8 . Size = > new WC8 ( data ) ,
2021-11-20 02:23:49 +00:00
WB8 . Size = > new WB8 ( data ) ,
2022-02-05 01:35:15 +00:00
WA8 . Size = > new WA8 ( data ) ,
2021-01-02 01:08:49 +00:00
// WC6/WC7: Check year
2022-01-03 05:35:59 +00:00
WC6 . Size = > ReadUInt32LittleEndian ( data . AsSpan ( 0x4C ) ) / 10000 < 2000 ? new WC7 ( data ) : new WC6 ( data ) ,
2021-01-02 01:08:49 +00:00
// WC6Full/WC7Full: 0x205 has 3 * 0x46 for gen6, now only 2.
WC6Full . Size = > data [ 0x205 ] = = 0 ? new WC7Full ( data ) . Gift : new WC6Full ( data ) . Gift ,
2021-08-20 20:49:20 +00:00
_ = > null ,
2021-01-02 01:08:49 +00:00
} ;
2016-06-20 04:22:43 +00:00
2021-06-24 16:16:36 +00:00
public string Extension = > GetType ( ) . Name . ToLowerInvariant ( ) ;
2017-09-30 05:58:25 +00:00
public string FileName = > $"{CardHeader}.{Extension}" ;
2020-12-11 04:42:30 +00:00
public abstract int Generation { get ; }
2016-06-20 04:22:43 +00:00
2020-06-17 02:46:22 +00:00
public PKM ConvertToPKM ( ITrainerInfo sav ) = > ConvertToPKM ( sav , EncounterCriteria . Unrestricted ) ;
public abstract PKM ConvertToPKM ( ITrainerInfo sav , EncounterCriteria criteria ) ;
2018-12-27 09:00:08 +00:00
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
public abstract bool IsMatchExact ( PKM pkm , DexLevel evo ) ;
2018-12-27 09:00:08 +00:00
protected abstract bool IsMatchDeferred ( PKM pkm ) ;
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
protected abstract bool IsMatchPartial ( PKM pkm ) ;
2018-12-27 09:00:08 +00:00
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
public EncounterMatchRating GetMatchRating ( PKM pkm )
2018-12-27 09:00:08 +00:00
{
Fracture the encounter matching checks to allow progressive validation (#3137)
## Issue
We want to discard-but-remember any slots that aren't a perfect fit, on the off chance that a better one exists later in the search space. If there's no better match, then we gotta go with what we got.
## Example:
Wurmple exists in area `X`, and also has a more rare slot for Silcoon, with the same level for both slots.
* We have a Silcoon that we've leveled up a few times.
Was our Silcoon originally a Wurmple, or was it caught as a Silcoon?
* To be sure, we have to check the EC/PID if the Wurmple wouldn't evolve into Cascoon instead.
* We don't want to wholly reject that Wurmple slot, as maybe the Met Level isn't within Silcoon's slot range.
---
Existing implementation would store "deferred" matches in a list; we only need to keep 1 of these matches around (less allocation!). We also want to differentiate between a "good" deferral and a "bad" deferral; I don't think this is necessary but it's currently used by Mystery Gift matching (implemented for the Eeveelution mystery gifts which matter for evolution moves).
The existing logic didn't use inheritance, and instead had static methods being reused across generations. Quite kludgy. Also, the existing logic was a pain to modify the master encounter yield methods, as one generation's quirks had to not impact all other generations that used the method.
---
The new implementation splits out the encounter yielding methods to be separate for each generation / subset. Now, things don't have to check `WasLink` for Gen7 origin, because Pokémon Link wasn't a thing in Gen7.
---
## Future
Maybe refactoring yielders into "GameCores" that expose yielding behaviors / properties, rather than the static logic. As more generations and side-gamegroups get added (thanks LGPE/GO/GameCube), all this switch stuff gets annoying to maintain instead of just overriding/inheritance.
## Conclusion
This shouldn't impact any legality results negatively; if you notice any regressions, report them! This should reduce false flags where we didn't defer-discard an encounter when we should have (wild area mons being confused with raids).
2021-01-30 01:55:27 +00:00
if ( IsMatchPartial ( pkm ) )
return EncounterMatchRating . PartialMatch ;
2018-12-27 09:00:08 +00:00
if ( IsMatchDeferred ( pkm ) )
return EncounterMatchRating . Deferred ;
return EncounterMatchRating . Match ;
}
2017-11-07 06:44:51 +00:00
/// <summary>
/// Creates a deep copy of the <see cref="MysteryGift"/> object data.
/// </summary>
/// <returns></returns>
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
public abstract MysteryGift Clone ( ) ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Gets a friendly name for the underlying <see cref="MysteryGift"/> type.
/// </summary>
2016-08-16 03:47:34 +00:00
public string Type = > GetType ( ) . Name ;
2018-07-27 02:34:27 +00:00
2017-11-07 06:44:51 +00:00
/// <summary>
/// Gets a friendly name for the underlying <see cref="MysteryGift"/> type for the <see cref="IEncounterable"/> interface.
/// </summary>
2020-06-17 02:46:22 +00:00
public string Name = > "Event Gift" ;
2019-03-18 05:19:37 +00:00
/// <summary>
/// Gets a friendly name for the underlying <see cref="MysteryGift"/> type for the <see cref="IEncounterable"/> interface.
/// </summary>
public string LongName = > $"{Name} ({Type})" ;
2016-08-16 03:47:34 +00:00
2020-05-20 04:07:30 +00:00
public virtual GameVersion Version
{
2020-12-11 04:42:30 +00:00
get = > GameUtil . GetVersion ( Generation ) ;
2020-05-20 04:07:30 +00:00
set { }
}
2016-06-20 04:22:43 +00:00
// Properties
2017-05-13 03:32:36 +00:00
public virtual int Species { get = > - 1 ; set { } }
2022-01-09 06:34:04 +00:00
public abstract AbilityPermission Ability { get ; }
2016-06-20 04:22:43 +00:00
public abstract bool GiftUsed { get ; set ; }
public abstract string CardTitle { get ; set ; }
public abstract int CardID { get ; set ; }
public abstract bool IsItem { get ; set ; }
2017-06-18 01:37:19 +00:00
public abstract int ItemID { get ; set ; }
2016-06-20 04:22:43 +00:00
public abstract bool IsPokémon { get ; set ; }
2017-05-13 03:32:36 +00:00
public virtual int Quantity { get = > 1 ; set { } }
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
public virtual bool Empty = > false ;
2016-06-20 04:22:43 +00:00
2017-06-18 01:37:19 +00:00
public virtual string CardHeader = > ( CardID > 0 ? $"Card #: {CardID:0000}" : "N/A" ) + $" - {CardTitle.Replace('\u3000',' ').Trim()}" ;
2019-10-26 19:33:58 +00:00
2016-09-04 17:38:53 +00:00
// Search Properties
2020-01-19 00:46:38 +00:00
public virtual IReadOnlyList < int > Moves { get = > Array . Empty < int > ( ) ; set { } }
public virtual IReadOnlyList < int > Relearn { get = > Array . Empty < int > ( ) ; set { } }
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
public virtual int [ ] IVs { get = > Array . Empty < int > ( ) ; set { } }
2016-09-04 17:38:53 +00:00
public virtual bool IsShiny = > false ;
2022-01-06 00:46:23 +00:00
public virtual Shiny Shiny
{
get = > Shiny . Never ;
init = > throw new InvalidOperationException ( ) ;
}
2017-05-13 03:32:36 +00:00
public virtual bool IsEgg { get = > false ; set { } }
public virtual int HeldItem { get = > - 1 ; set { } }
2018-07-03 03:34:41 +00:00
public virtual int AbilityType { get = > - 1 ; set { } }
2017-11-18 19:34:23 +00:00
public abstract int Gender { get ; set ; }
public abstract int Form { get ; set ; }
public abstract int TID { get ; set ; }
public abstract int SID { get ; set ; }
public abstract string OT_Name { get ; set ; }
2018-01-02 20:00:41 +00:00
public abstract int Location { get ; set ; }
2016-10-23 19:48:49 +00:00
public abstract int Level { get ; set ; }
2017-04-12 03:55:34 +00:00
public int LevelMin = > Level ;
public int LevelMax = > Level ;
2016-10-23 19:48:49 +00:00
public abstract int Ball { get ; set ; }
Gen 1 move analysis improvement. Adapted the valid moves to take into account that move deleter and move reminder do not exits in generation 1 (#1037)
* Fix getMoves with min level, when SkipWhile and TakeWhile is used together the index i in TakeWhile is calculated from the enumerator that results of the SkipWhile function, not the index of the initial array, those giving an incorrect index to check Levels array in the TakeWhile
* Fix getMoves when levelmin or levelmax is above max level in the levels array, TakeWhile and SkipWhile return empty list if the while goes beyond the last element of the array
* Include player hatched egg in the list of possible encounters for parseMoves only if the pokemon was an egg
Also change the valur of WasEgg for gen1,2,3 pokemon if the encounter analyzed is not an egg
add the non egg encounters to the list instead of checking the non-egg encounter inside parseMovesWasEggPreRelearn
* Fix for gen3 egg encounters
Remove non-egg encounters without special moves if there is an egg encounter because egg encounter already cover every possible move combination
Do not add daycare egg encounter for gen3 unhatched egg if there is another encounter, that means is an event or gift egg, not a daycare egg
Remove duplicate encounters
* Gift egg should not allow inherited moves even it they dont have special moves
Those gift eggs are hatched only with the species base moves
* Added getEncounterMoves functions, to be used for generation 1 encounters to find what moves have a pokemon at the moment of being caught because there is no move reminder in generation 1
* Added GBEncounterData, structure for refactor the tuples used in generation 1 and 2 encounters
* Add LevelMin and LevelMax to IEncounterable to get the encounter moves by the min level of the generation 1 EncounterLink
Add iGeneration to difference generation 1 and generation 2 encounters for GB Era pokemon
* Mark generation in gen 1 and 2 encounters
There is no need to mark the generation in gen 3 to 7 encounters because in that generations it match the pokemon generation number
* Add min level for generation 1 moves in getMoves functions
Add function to return the default moves for a GB encounters, for generation 1 games that included both moves from level up table and level 1 moves from personal table
Fix getMoves with min level when the moves list is empty, like Raichu generation 1
* Add maxSpecies to getBaseSpecies function for gen1 pokemon with a gen2 egg encounter
Refactor VC Encounter changing Tuples for GBData class
* Fixed for gen 2 Checks
Also do not search for generation1 encounter if the gen2 pokemon have met location from crystal
* Fix VC wild encounters, should be stored as array or else other verifyEncounter functions wont work
* Add generation 1 parse moves function including default moves
* Clean-up get encounters
* Verify empty moves for generation 1 encounters, in generation 1 does not exits move deleter
That means when a move slot have been used by a level up move or a TM/HM/Tutor move it cant be empty again
Does not apply if generation 2 tradeback is allowed, in generation 2 there is a move deleter
* Added two edge cases for pokemon that learn in red/blue and yellow different moves at the same level, this combinations can not exits until a later level when they learn again one of the levels in the other game, only happen for flareon and vaporeon
* Check incompatible moves between evolution species, it is for species that learn a move in a level as an evolved species and a move at a upper level as a preevolution
Also added most edge cases for the min slots used for generation 1 games, i think every weird combination is already covered
* Fix gen 1 eevee and evolutions move checks
* Cleanup
* Move the code to change valid moves for generation 1 to a function
* Fix getMoveMinLevelGBEncounter
* getUsedMoveSlots, removed wild Butterfree edge case, it is not possible
* Filter the min level of the encounter by the possible games the pokemon could be originated, yellow pikachu and kadabra can be detected
2017-04-09 00:17:20 +00:00
public virtual bool EggEncounter = > IsEgg ;
2018-01-02 20:00:41 +00:00
public abstract int EggLocation { get ; set ; }
2019-05-11 07:59:07 +00:00
2021-08-24 21:03:20 +00:00
public Ball FixedBall = > ( Ball ) Ball ;
2019-05-11 07:59:07 +00:00
public int TrainerID7 = > ( int ) ( ( uint ) ( TID | ( SID < < 16 ) ) % 1000000 ) ;
public int TrainerSID7 = > ( int ) ( ( uint ) ( TID | ( SID < < 16 ) ) / 1000000 ) ;
2020-08-18 22:39:45 +00:00
/// <summary>
/// Checks if the <see cref="PKM"/> has the <see cref="move"/> in its current move list.
/// </summary>
public bool HasMove ( int move ) = > Moves . Contains ( move ) ;
2016-06-20 04:22:43 +00:00
}
}