mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Handle traded BDSP egg transfers
This commit is contained in:
parent
528a377f84
commit
e700a0e3e6
3 changed files with 24 additions and 7 deletions
|
@ -58,7 +58,7 @@ public sealed record EncounterStatic8b : EncounterStatic, IStaticCorrelation8b
|
|||
if (EggLocation > 60000 && pk.Egg_Location == Locations.HOME_SWSHBDSPEgg)
|
||||
return true;
|
||||
// >60000 can be reset to Link Trade (30001), then altered differently.
|
||||
return Locations.IsValidMetBDSP(pk.Egg_Location, pk.Version);
|
||||
return Locations.IsValidMetBDSP(pk.Egg_Location, pk.Version) && pk.Egg_Location == pk.Met_Location;
|
||||
}
|
||||
|
||||
// Hatched
|
||||
|
|
|
@ -102,7 +102,14 @@ internal static class EncounterGenerator8b
|
|||
if (ctr != 0) yield break;
|
||||
}
|
||||
|
||||
if (pk.Egg_Location == Locations.HOME_SWSHBDSPEgg && pk.Met_Level == 1)
|
||||
var wasEgg = pk.Egg_Location switch
|
||||
{
|
||||
Locations.HOME_SWSHBDSPEgg => true, // Regular hatch location (not link trade)
|
||||
Locations.HOME_SWBD => pk.Met_Location == Locations.HOME_SWBD, // Link Trade transferred over must match Met Location
|
||||
Locations.HOME_SHSP => pk.Met_Location == Locations.HOME_SHSP, // Link Trade transferred over must match Met Location
|
||||
_ => false,
|
||||
};
|
||||
if (wasEgg && pk.Met_Level == 1)
|
||||
{
|
||||
foreach (var z in GenerateEggs(pk, 8))
|
||||
{ yield return z; ++ctr; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PKHeX.Core;
|
||||
|
@ -132,14 +132,24 @@ public sealed class PB8 : G8PKM
|
|||
public PK8 ConvertToPK8()
|
||||
{
|
||||
var pk = ConvertTo<PK8>();
|
||||
if (pk.Egg_Location == Locations.Default8bNone)
|
||||
pk.Egg_Location = 0;
|
||||
else
|
||||
pk.Egg_Location = Locations.HOME_SWSHBDSPEgg;
|
||||
pk.SanitizeImport();
|
||||
pk.Egg_Location = GetEggLocationPK8();
|
||||
return pk;
|
||||
}
|
||||
|
||||
private int GetEggLocationPK8()
|
||||
{
|
||||
var egg = Egg_Location;
|
||||
if (egg == Locations.Default8bNone)
|
||||
return 0;
|
||||
return Version switch
|
||||
{
|
||||
(int)GameVersion.BD => egg is Locations.LinkTrade6NPC ? Locations.HOME_SWBD : Locations.HOME_SWSHBDSPEgg,
|
||||
(int)GameVersion.SH => egg is Locations.LinkTrade6NPC ? Locations.HOME_SHSP : Locations.HOME_SWSHBDSPEgg,
|
||||
_ => egg,
|
||||
};
|
||||
}
|
||||
|
||||
public override PA8 ConvertToPA8()
|
||||
{
|
||||
var pk = base.ConvertToPA8();
|
||||
|
|
Loading…
Add table
Reference in a new issue