2020-07-18 20:36:30 +00:00
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Trade Encounter data with a fixed Catch Rate
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
2020-07-19 18:32:40 +00:00
|
|
|
|
/// Generation 1 specific value used in detecting unmodified/un-traded Generation 1 Trade Encounter data.
|
|
|
|
|
/// Species & Minimum level (legal) possible to acquire at.
|
2020-07-18 20:36:30 +00:00
|
|
|
|
/// </remarks>
|
|
|
|
|
public sealed class EncounterTrade1 : EncounterTradeGB
|
|
|
|
|
{
|
2020-08-30 22:35:59 +00:00
|
|
|
|
public override int Generation => 1;
|
2020-11-01 23:27:54 +00:00
|
|
|
|
public bool GBEra { private get; set; }
|
2020-09-05 20:06:08 +00:00
|
|
|
|
|
|
|
|
|
public EncounterTrade1(int species, int level, GameVersion game) : base(species, level)
|
|
|
|
|
{
|
|
|
|
|
Version = game;
|
|
|
|
|
TrainerNames = StringConverter12.G1TradeOTName;
|
|
|
|
|
}
|
2020-07-18 20:36:30 +00:00
|
|
|
|
|
|
|
|
|
public byte GetInitialCatchRate()
|
|
|
|
|
{
|
|
|
|
|
var pt = Version == GameVersion.YW ? PersonalTable.Y : PersonalTable.RB;
|
|
|
|
|
return (byte)pt[Species].CatchRate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyDetails(sav, criteria, pk);
|
|
|
|
|
var pk1 = (PK1)pk;
|
|
|
|
|
pk1.Catch_Rate = GetInitialCatchRate();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-19 18:32:40 +00:00
|
|
|
|
internal bool IsEncounterTrade1Valid(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
string ot = pkm.OT_Name;
|
|
|
|
|
if (pkm.Format <= 2)
|
|
|
|
|
return ot == StringConverter12.G1TradeOTStr;
|
|
|
|
|
// Converted string 1/2->7 to language specific value
|
|
|
|
|
var tr = GetOT(pkm.Language);
|
|
|
|
|
return ot == tr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-18 20:36:30 +00:00
|
|
|
|
public override bool IsMatch(PKM pkm)
|
|
|
|
|
{
|
|
|
|
|
if (Level > pkm.CurrentLevel) // minimum required level
|
|
|
|
|
return false;
|
|
|
|
|
|
2020-11-01 23:27:54 +00:00
|
|
|
|
if (Version == GameVersion.BU)
|
|
|
|
|
{
|
|
|
|
|
// Encounters with this version have to originate from the Japanese Blue game.
|
|
|
|
|
if (!pkm.Japanese)
|
|
|
|
|
return false;
|
|
|
|
|
// Stadium 2 can transfer from GSC->RBY without a "Trade", thus allowing un-evolved outsiders
|
|
|
|
|
if (GBEra && !ParseSettings.AllowGBCartEra)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-01 23:58:42 +00:00
|
|
|
|
if (!(pkm is PK1 pk1) || !pkm.Gen1_NotTradeback)
|
|
|
|
|
return true;
|
|
|
|
|
|
2020-07-18 20:36:30 +00:00
|
|
|
|
var req = GetInitialCatchRate();
|
|
|
|
|
return req == pk1.Catch_Rate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|