2018-03-31 07:43:41 +00:00
|
|
|
|
using System;
|
2018-04-30 01:26:36 +00:00
|
|
|
|
using System.Linq;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2017-10-24 06:12:58 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Trade Encounter data
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// Trade data is fixed level in all cases except for the first few generations of games.
|
|
|
|
|
/// </remarks>
|
2018-03-30 23:31:40 +00:00
|
|
|
|
public class EncounterTrade : IEncounterable, IMoveset, IGeneration, ILocation, IContestStats, IVersion
|
2016-11-08 16:43:57 +00:00
|
|
|
|
{
|
2017-01-05 06:25:45 +00:00
|
|
|
|
public int Species { get; set; }
|
2017-04-05 05:01:48 +00:00
|
|
|
|
public int[] Moves { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Level { get; set; }
|
2017-04-23 16:18:42 +00:00
|
|
|
|
public int LevelMin => Level;
|
|
|
|
|
public int LevelMax => 100;
|
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 int Generation { get; set; } = -1;
|
2016-11-08 16:43:57 +00:00
|
|
|
|
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Location { get; set; } = -1;
|
|
|
|
|
public int Ability { get; set; }
|
2016-11-08 16:43:57 +00:00
|
|
|
|
public Nature Nature = Nature.Random;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int TID { get; set; }
|
|
|
|
|
public int SID { get; set; }
|
|
|
|
|
public GameVersion Version { get; set; } = GameVersion.Any;
|
2018-03-11 02:03:09 +00:00
|
|
|
|
public int[] IVs { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Form { get; set; }
|
2018-03-17 02:35:55 +00:00
|
|
|
|
public virtual Shiny Shiny { get; set; } = Shiny.Never;
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public int Gender { get; set; } = -1;
|
|
|
|
|
public int OTGender { get; set; } = -1;
|
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 bool EggEncounter => false;
|
2018-01-02 20:00:41 +00:00
|
|
|
|
public int EggLocation { get; set; }
|
2017-06-18 01:37:19 +00:00
|
|
|
|
public bool EvolveOnTrade { get; set; }
|
|
|
|
|
public int Ball { get; set; } = 4;
|
2017-09-21 04:28:29 +00:00
|
|
|
|
public int CurrentLevel { get; set; } = -1;
|
2017-01-04 04:51:33 +00:00
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
public int[] Contest { set => this.SetContestStats(value); }
|
|
|
|
|
public int CNT_Cool { get; set; }
|
|
|
|
|
public int CNT_Beauty { get; set; }
|
|
|
|
|
public int CNT_Cute { get; set; }
|
|
|
|
|
public int CNT_Smart { get; set; }
|
|
|
|
|
public int CNT_Tough { get; set; }
|
|
|
|
|
public int CNT_Sheen { get; set; }
|
|
|
|
|
|
2018-11-11 05:07:31 +00:00
|
|
|
|
public int TID7
|
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
TID = (ushort) value;
|
|
|
|
|
SID = value >> 16;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-18 23:25:40 +00:00
|
|
|
|
private const string _name = "In-game Trade";
|
|
|
|
|
public string Name => _name;
|
2019-03-18 05:19:37 +00:00
|
|
|
|
public string LongName => _name;
|
2017-09-21 04:28:29 +00:00
|
|
|
|
public bool Fateful { get; set; }
|
2017-11-22 16:11:53 +00:00
|
|
|
|
public bool IsNicknamed { get; set; } = true;
|
2017-03-29 07:48:32 +00:00
|
|
|
|
|
2018-03-27 05:23:11 +00:00
|
|
|
|
public string[] Nicknames { get; internal set; }
|
|
|
|
|
public string[] TrainerNames { get; internal set; }
|
2018-04-30 01:26:36 +00:00
|
|
|
|
public string GetNickname(int language) => Nicknames?.Length > language ? Nicknames[language] : null;
|
|
|
|
|
public string GetOT(int language) => TrainerNames?.Length > language ? TrainerNames[language] : null;
|
2018-06-01 02:49:47 +00:00
|
|
|
|
public bool HasNickname => Nicknames != null;
|
2018-03-27 05:23:11 +00:00
|
|
|
|
|
2018-05-12 15:13:39 +00:00
|
|
|
|
public static readonly int[] DefaultMetLocation =
|
2017-03-29 07:48:32 +00:00
|
|
|
|
{
|
2019-05-11 03:46:49 +00:00
|
|
|
|
0,
|
|
|
|
|
Locations.LinkTrade2NPC,
|
|
|
|
|
Locations.LinkTrade3NPC,
|
|
|
|
|
Locations.LinkTrade4NPC,
|
|
|
|
|
Locations.LinkTrade5NPC,
|
|
|
|
|
Locations.LinkTrade6NPC,
|
|
|
|
|
Locations.LinkTrade6NPC, // 7 is same as 6
|
2017-03-29 07:48:32 +00:00
|
|
|
|
};
|
2018-03-29 03:38:07 +00:00
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
public PKM ConvertToPKM(ITrainerInfo SAV) => ConvertToPKM(SAV, EncounterCriteria.Unrestricted);
|
|
|
|
|
|
|
|
|
|
public PKM ConvertToPKM(ITrainerInfo SAV, EncounterCriteria criteria)
|
2018-03-31 07:43:41 +00:00
|
|
|
|
{
|
2018-12-30 06:24:34 +00:00
|
|
|
|
var pk = PKMConverter.GetBlank(Generation, Version);
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SAV.ApplyToPKM(pk);
|
|
|
|
|
|
2018-03-31 07:43:41 +00:00
|
|
|
|
var version = this.GetCompatibleVersion((GameVersion)SAV.Game);
|
|
|
|
|
int lang = (int)Legal.GetSafeLanguage(Generation, (LanguageID)SAV.Language);
|
|
|
|
|
int level = CurrentLevel > 0 ? CurrentLevel : LevelMin;
|
2018-04-30 01:26:36 +00:00
|
|
|
|
if (level == 0)
|
|
|
|
|
level = 25; // avoid some cases
|
2018-12-30 06:24:34 +00:00
|
|
|
|
|
|
|
|
|
int species = Species;
|
|
|
|
|
if (EvolveOnTrade)
|
|
|
|
|
species++;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
pk.EncryptionConstant = Util.Rand32();
|
2018-12-30 06:24:34 +00:00
|
|
|
|
pk.Species = species;
|
2018-05-10 00:50:56 +00:00
|
|
|
|
pk.AltForm = Form;
|
2018-04-30 01:26:36 +00:00
|
|
|
|
pk.Language = lang;
|
2019-03-21 04:50:44 +00:00
|
|
|
|
pk.OT_Name = pk.Format == 1 ? StringConverter12.G1TradeOTStr : GetOT(lang) ?? SAV.OT;
|
2018-04-30 01:26:36 +00:00
|
|
|
|
pk.OT_Gender = GetOT(lang) != null ? Math.Max(0, OTGender) : SAV.Gender;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
pk.SetNickname(GetNickname(lang));
|
2018-12-30 06:24:34 +00:00
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.CurrentLevel = level;
|
|
|
|
|
pk.Version = (int)version;
|
|
|
|
|
pk.TID = TID;
|
|
|
|
|
pk.SID = SID;
|
|
|
|
|
pk.Ball = Ball;
|
|
|
|
|
pk.OT_Friendship = pk.PersonalInfo.BaseFriendship;
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetPINGA(pk, criteria);
|
|
|
|
|
SetMoves(pk, version, level);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
var time = DateTime.Now;
|
2018-12-30 06:24:34 +00:00
|
|
|
|
if (pk.Format != 2 || version == GameVersion.C)
|
|
|
|
|
{
|
|
|
|
|
var location = Location > 0 ? Location : DefaultMetLocation[Generation - 1];
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetMetData(pk, level, location, time);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
if (EggLocation != 0)
|
2019-02-09 19:37:20 +00:00
|
|
|
|
SetEggMetData(pk, time);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
if (pk is PK1 pk1 && this is EncounterTradeCatchRate c)
|
|
|
|
|
pk1.Catch_Rate = (int)c.Catch_Rate;
|
|
|
|
|
|
2018-06-03 04:19:03 +00:00
|
|
|
|
if (pk is IContestStats s)
|
|
|
|
|
this.CopyContestStatsTo(s);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
|
|
|
|
|
if (Fateful)
|
|
|
|
|
pk.FatefulEncounter = true;
|
|
|
|
|
|
2018-05-08 04:16:54 +00:00
|
|
|
|
UpdateEdgeCase(pk);
|
|
|
|
|
|
2018-03-31 07:43:41 +00:00
|
|
|
|
if (pk.Format < 6)
|
|
|
|
|
return pk;
|
|
|
|
|
|
2018-04-30 04:29:34 +00:00
|
|
|
|
SAV.ApplyHandlingTrainerInfo(pk, force: true);
|
2018-03-31 07:43:41 +00:00
|
|
|
|
pk.SetRandomEC();
|
|
|
|
|
|
2018-12-30 06:24:34 +00:00
|
|
|
|
if (pk.Format == 6)
|
|
|
|
|
pk.SetRandomMemory6();
|
|
|
|
|
else if (pk.Format == 7)
|
2018-04-30 01:26:36 +00:00
|
|
|
|
SetSMOTMemory(pk);
|
|
|
|
|
|
2018-03-31 07:43:41 +00:00
|
|
|
|
return pk;
|
|
|
|
|
}
|
2018-04-30 01:26:36 +00:00
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
protected virtual void SetPINGA(PKM pk, EncounterCriteria criteria)
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
int gender = criteria.GetGender(Gender, pk.PersonalInfo);
|
|
|
|
|
int nature = (int)criteria.GetNature(Nature);
|
|
|
|
|
int ability = Ability >> 1;
|
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
PIDGenerator.SetRandomWildPID(pk, Generation, nature, ability, gender);
|
|
|
|
|
pk.Nature = nature;
|
|
|
|
|
pk.Gender = gender;
|
|
|
|
|
pk.RefreshAbility(ability);
|
|
|
|
|
|
|
|
|
|
SetIVs(pk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SetIVs(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
if (IVs != null)
|
|
|
|
|
pk.SetRandomIVs(IVs, 0);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
else
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.SetRandomIVs(flawless: 3);
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetMoves(PKM pk, GameVersion version, int level)
|
|
|
|
|
{
|
|
|
|
|
var moves = Moves ?? MoveLevelUp.GetEncounterMoves(pk, level, version);
|
|
|
|
|
if (pk.Format == 1 && moves.All(z => z == 0))
|
|
|
|
|
moves = ((PersonalInfoG1)PersonalTable.RB[Species]).Moves;
|
|
|
|
|
pk.Moves = moves;
|
|
|
|
|
pk.SetMaximumPPCurrent(moves);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
private void SetEggMetData(PKM pk, DateTime time)
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
pk.Egg_Location = EggLocation;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.EggMetDate = time;
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-09 19:37:20 +00:00
|
|
|
|
private static void SetMetData(PKM pk, int level, int location, DateTime time)
|
2018-12-30 06:24:34 +00:00
|
|
|
|
{
|
|
|
|
|
pk.Met_Level = level;
|
|
|
|
|
pk.Met_Location = location;
|
2019-02-09 19:37:20 +00:00
|
|
|
|
pk.MetDate = time;
|
2018-12-30 06:24:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-30 01:26:36 +00:00
|
|
|
|
private void UpdateEdgeCase(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
switch (Generation)
|
|
|
|
|
{
|
|
|
|
|
case 3 when Species == 124 && pkm.Version == (int) GameVersion.LG && pkm.Language == (int) LanguageID.Italian:
|
|
|
|
|
// Italian LG Jynx untranslated from English name
|
|
|
|
|
pkm.OT_Name = GetOT(2);
|
|
|
|
|
pkm.SetNickname(GetNickname(2));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4 when Version == GameVersion.DPPt && Species == 129: // Meister Magikarp
|
|
|
|
|
// Has German Language ID for all except German origin, which is English
|
|
|
|
|
pkm.Language = (int)(pkm.Language == (int)LanguageID.German ? LanguageID.English : LanguageID.German);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4 when Version == GameVersion.DPPt && (pkm.Version == (int)GameVersion.D || pkm.Version == (int)GameVersion.P):
|
|
|
|
|
// DP English origin are Japanese lang
|
|
|
|
|
pkm.Language = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 4 when Version == GameVersion.HGSS && Species == 25: // Pikachu
|
|
|
|
|
// Has English Language ID for all except English origin, which is French
|
|
|
|
|
pkm.Language = (int)(pkm.Language == (int)LanguageID.English ? LanguageID.French : LanguageID.English);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5 when Version == GameVersion.BW && pkm.Language == 1:
|
|
|
|
|
// Trades for JPN games have language ID of 0, not 1.
|
|
|
|
|
pkm.Language = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetSMOTMemory(PKM pk)
|
|
|
|
|
{
|
|
|
|
|
pk.OT_Memory = 1;
|
|
|
|
|
pk.OT_Intensity = 3;
|
|
|
|
|
pk.OT_TextVar = 40;
|
|
|
|
|
pk.OT_Feeling = 5;
|
|
|
|
|
}
|
2018-12-27 09:00:08 +00:00
|
|
|
|
|
|
|
|
|
public bool IsMatch(PKM pkm, int lvl)
|
|
|
|
|
{
|
|
|
|
|
if (IVs != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
|
{
|
|
|
|
|
if (IVs[i] != -1 && IVs[i] != pkm.GetIV(i))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this is EncounterTradePID p)
|
|
|
|
|
{
|
|
|
|
|
if (p.PID != pkm.EncryptionConstant)
|
|
|
|
|
return false;
|
|
|
|
|
if (Nature != Nature.Random && (int)Nature != pkm.Nature) // gen5 BW only
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!Shiny.IsValid(pkm))
|
|
|
|
|
return false;
|
|
|
|
|
if (Nature != Nature.Random && (int)Nature != pkm.Nature)
|
|
|
|
|
return false;
|
|
|
|
|
if (Gender != -1 && Gender != pkm.Gender)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (TID != pkm.TID)
|
|
|
|
|
return false;
|
|
|
|
|
if (SID != pkm.SID)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pkm.HasOriginalMetLocation)
|
|
|
|
|
{
|
|
|
|
|
var loc = Location > 0 ? Location : DefaultMetLocation[Generation - 1];
|
|
|
|
|
if (loc != pkm.Met_Location)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pkm.Format < 5)
|
|
|
|
|
{
|
|
|
|
|
if (Level > lvl)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if (Level != lvl)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Level > lvl)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CurrentLevel != -1 && CurrentLevel > pkm.CurrentLevel)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (Form != pkm.AltForm && !Legal.IsFormChangeable(pkm, pkm.Species))
|
|
|
|
|
return false;
|
|
|
|
|
if (OTGender != -1 && OTGender != pkm.OT_Gender)
|
|
|
|
|
return false;
|
|
|
|
|
if (EggLocation != pkm.Egg_Location)
|
|
|
|
|
return false;
|
|
|
|
|
// if (z.Ability == 4 ^ pkm.AbilityNumber == 4) // defer to Ability
|
|
|
|
|
// countinue;
|
|
|
|
|
if (!Version.Contains((GameVersion)pkm.Version))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (pkm is IContestStats s && s.IsContestBelow(this))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsMatchVC1(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (Level > pkm.CurrentLevel) // minimum required level
|
|
|
|
|
return false;
|
|
|
|
|
if (pkm.Format != 1 || !pkm.Gen1_NotTradeback)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Even if the in game trade uses the tables with source pokemon allowing generation 2 games, the traded pokemon could be a non-tradeback pokemon
|
|
|
|
|
var rate = (pkm as PK1)?.Catch_Rate;
|
|
|
|
|
if (this is EncounterTradeCatchRate r)
|
|
|
|
|
{
|
|
|
|
|
if (rate != r.Catch_Rate)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (Version == GameVersion.YW && rate != PersonalTable.Y[Species].CatchRate)
|
|
|
|
|
return false;
|
|
|
|
|
if (Version != GameVersion.YW && rate != PersonalTable.RB[Species].CatchRate)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsMatchVC2(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (Level > pkm.CurrentLevel) // minimum required level
|
|
|
|
|
return false;
|
|
|
|
|
if (TID != pkm.TID)
|
|
|
|
|
return false;
|
2019-01-05 18:51:41 +00:00
|
|
|
|
if (pkm.Format <= 2)
|
|
|
|
|
{
|
|
|
|
|
if (Gender >= 0 && Gender != pkm.Gender)
|
|
|
|
|
return false;
|
|
|
|
|
if (IVs != null && !Legal.GetIsFixedIVSequenceValidNoRand(IVs, pkm)) return false;
|
|
|
|
|
}
|
2018-12-27 09:00:08 +00:00
|
|
|
|
if (pkm.Met_Location != 0 && pkm.Format == 2 && pkm.Met_Location != 126)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return IsValidTradeOT12(pkm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsValidTradeOT12(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
var OT = pkm.OT_Name;
|
|
|
|
|
if (pkm.Japanese)
|
|
|
|
|
return TrainerNames[(int)LanguageID.Japanese] == OT;
|
|
|
|
|
if (pkm.Korean)
|
|
|
|
|
return TrainerNames[(int)LanguageID.Korean] == OT;
|
|
|
|
|
|
|
|
|
|
const int start = (int)LanguageID.English;
|
|
|
|
|
const int end = (int)LanguageID.Italian;
|
2019-01-03 23:47:41 +00:00
|
|
|
|
var index = Array.FindIndex(TrainerNames, start, end - start + 1, w => w == OT);
|
2018-12-27 09:00:08 +00:00
|
|
|
|
return index >= 0;
|
|
|
|
|
}
|
2016-11-08 16:43:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|