mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Handle traded BDSP eggs & flag HatchCounter=0
This commit is contained in:
parent
829641d874
commit
1ca1b838c1
5 changed files with 26 additions and 6 deletions
17
PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs
Normal file
17
PKHeX.Core/Legality/Verifiers/Egg/EggStateLegality.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
public static class EggStateLegality
|
||||
{
|
||||
public static int GetMinimumEggHatchCycles(PKM pkm) => pkm switch
|
||||
{
|
||||
PK7 => 0, // pelago can decrement to 0
|
||||
_ => 1, // whenever it hits 0, it hatches, so anything above that is fine.
|
||||
};
|
||||
|
||||
public static bool IsValidHTEgg(PKM pkm) => pkm switch
|
||||
{
|
||||
PB8 { Met_Location: Locations.LinkTrade6NPC } pb8 when pb8.HT_Friendship == PersonalTable.BDSP[pb8.Species].BaseFriendship => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -31,7 +31,8 @@ namespace PKHeX.Core
|
|||
|
||||
if (!pkm.IsUntraded)
|
||||
{
|
||||
if (pkm.IsEgg) // Can't have HT details even as a Link Trade egg
|
||||
// Can't have HT details even as a Link Trade egg, except in some games.
|
||||
if (pkm.IsEgg && !EggStateLegality.IsValidHTEgg(pkm))
|
||||
data.AddLine(GetInvalid(LegalityCheckStrings.LMemoryArgBadHT));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ namespace PKHeX.Core
|
|||
var HatchCycles = enc is EncounterStatic s ? s.EggCycles : 0;
|
||||
if (HatchCycles == 0) // no value set
|
||||
HatchCycles = pkm.PersonalInfo.HatchCycles;
|
||||
if (pkm.OT_Friendship > HatchCycles)
|
||||
if (pkm.OT_Friendship > HatchCycles || pkm.OT_Friendship < EggStateLegality.GetMinimumEggHatchCycles(pkm))
|
||||
data.AddLine(GetInvalid(LEggHatchCycles, Egg));
|
||||
|
||||
if (pkm.Format >= 6 && enc is EncounterEgg && !MovesMatchRelearn(pkm))
|
||||
|
|
|
@ -41,10 +41,12 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (IsEgg)
|
||||
{
|
||||
// Eggs do not have any modifications done if they are traded
|
||||
// Apply link trade data, only if it left the OT (ignore if dumped & imported, or cloned, etc)
|
||||
// if ((tr.OT != OT_Name) || (tr.TID != TID) || (tr.SID != SID) || (tr.Gender != OT_Gender))
|
||||
// SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade6NPC);
|
||||
if ((tr.OT != OT_Name) || (tr.TID != TID) || (tr.SID != SID) || (tr.Gender != OT_Gender))
|
||||
SetLinkTradeEgg(Day, Month, Year, Locations.LinkTrade6NPC);
|
||||
|
||||
// Unfortunately, BDSP doesn't return if it's an egg, and can update the HT details & handler.
|
||||
// Continue to the rest of the method.
|
||||
// return;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace PKHeX.Core
|
|||
if (!TradeOT(tr))
|
||||
TradeHT(tr);
|
||||
}
|
||||
|
||||
|
||||
public int DynamaxType { get => BitConverter.ToUInt16(Data, 0x156); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x156); }
|
||||
|
||||
public void FixMemories()
|
||||
|
|
Loading…
Add table
Reference in a new issue