PKHeX/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade5.cs

68 lines
2.1 KiB
C#
Raw Normal View History

2018-03-09 05:18:32 +00:00
namespace PKHeX.Core
{
/// <summary>
/// Generation 5 Trade Encounter
/// </summary>
/// <inheritdoc cref="EncounterTrade"/>
public sealed record EncounterTrade5(GameVersion Version) : EncounterTrade(Version)
{
public override int Generation => 5;
public override int Location => Locations.LinkTrade5NPC;
}
public sealed record EncounterTrade5PID : EncounterTrade
2018-03-09 05:18:32 +00:00
{
public override int Generation => 5;
public override int Location => Locations.LinkTrade5NPC;
/// <summary>
/// Fixed <see cref="PKM.PID"/> value the encounter must have.
/// </summary>
public readonly uint PID;
public EncounterTrade5PID(GameVersion game, uint pid) : base(game)
2020-12-21 22:40:34 +00:00
{
PID = pid;
Shiny = Shiny.FixedValue;
}
protected override void ApplyDetails(ITrainerInfo sav, EncounterCriteria criteria, PKM pk)
{
base.ApplyDetails(sav, criteria, pk);
// Trades for JPN games have language ID of 0, not 1.
if (pk.Language == (int) LanguageID.Japanese)
pk.Language = 0;
}
protected override void SetPINGA(PKM pk, EncounterCriteria criteria)
{
2020-06-21 23:16:34 +00:00
var pi = pk.PersonalInfo;
int gender = criteria.GetGender(PKX.GetGenderFromPID(Species, PID), pi);
int nature = (int)criteria.GetNature(Nature);
int ability = criteria.GetAbilityFromNumber(Ability);
pk.PID = PID;
pk.Nature = nature;
pk.Gender = gender;
pk.RefreshAbility(ability);
SetIVs(pk);
}
2019-11-16 01:34:18 +00:00
protected override bool IsMatchNatureGenderShiny(PKM pkm)
{
if (PID != pkm.EncryptionConstant)
2019-11-16 01:34:18 +00:00
return false;
if (Nature != Nature.Random && (int)Nature != pkm.Nature) // gen5 BW only
return false;
return true;
}
2021-02-03 19:33:09 +00:00
public static bool IsValidMissingLanguage(PKM pkm)
{
return pkm.Format == 5 && pkm.BW;
}
2018-03-09 05:18:32 +00:00
}
}