Fix remaining edge cases: egg dates, Gen 9 version, Unown PID

Egg toggle improvements:
- Reset met date to 2000-01-01 when becoming egg
- Gen 9 (PK9): version reset to 0 for eggs
- Gen 4+: egg met location based on OT trade detection
- Use EggStateLegality.IsNicknameFlagSet for nickname flag
- Use Entity.ClearMemories() for comprehensive memory clear
- Suggest hatch location when un-egging

Form change:
- Unown Gen 3 special: SetPIDUnown3 to match form letter

XAML: explicit Grid.Row on Walking Mood TextBlock
This commit is contained in:
montanon 2026-03-16 18:10:03 -03:00
parent 9b87292055
commit acff5454b6
2 changed files with 72 additions and 9 deletions

View File

@ -704,6 +704,10 @@ private void UpdateRegionNames()
BaseST = pi.HP + pi.ATK + pi.DEF + pi.SPA + pi.SPD + pi.SPE;
}
// Special Unown handling: Gen 3 PID must match form
if (Entity.Species == (int)PKHeX.Core.Species.Unown && Entity is G3PKM)
Entity.SetPIDUnown3(Entity.Form);
// Sanitize gender
Entity.Gender = Entity.GetSaneGender();
_isPopulating = true;
@ -2226,6 +2230,45 @@ private async Task ShowFullLegalityReport()
// Set met as egg
MetAsEgg = true;
// Reset met date to 2000-01-01 (egg has no met date yet)
_isPopulating = true;
try
{
MetYear = 0; MetMonth = 1; MetDay = 1;
Entity.MetYear = 0; Entity.MetMonth = 1; Entity.MetDay = 1;
}
finally { _isPopulating = false; }
// Set met location based on trade status (Gen 4+)
if (Entity.Format >= 4 && _sav is not null)
{
bool isTraded = _sav.OT != Entity.OriginalTrainerName || _sav.TID16 != Entity.TID16 || _sav.SID16 != Entity.SID16;
var loc = isTraded
? Locations.TradedEggLocation(_sav.Generation, _sav.Version)
: LocationEdits.GetNoneLocation(Entity);
_isPopulating = true;
try
{
MetLocation = loc;
Entity.MetLocation = loc;
SelectedMetLocation = MetLocationList.FirstOrDefault(x => x.Value == loc);
}
finally { _isPopulating = false; }
}
// Gen 9 eggs have Version = 0 until hatched
if (Entity is PK9)
{
_isPopulating = true;
try
{
Entity.Version = 0;
Version = 0;
SelectedVersion = VersionList.FirstOrDefault(x => x.Value == 0);
}
finally { _isPopulating = false; }
}
// Update nickname to egg name
var eggName = SpeciesName.GetEggName(Entity.Language, Entity.Format);
_isPopulating = true;
@ -2233,18 +2276,14 @@ private async Task ShowFullLegalityReport()
{
Nickname = eggName;
Entity.Nickname = eggName;
IsNicknamed = true;
Entity.IsNicknamed = true;
IsNicknamed = EggStateLegality.IsNicknameFlagSet(Entity);
Entity.IsNicknamed = IsNicknamed;
}
finally { _isPopulating = false; }
// Clear memories for Gen 6+
if (Entity is ITrainerMemories mem)
{
mem.HandlingTrainerMemory = 0;
mem.HandlingTrainerMemoryFeeling = 0;
mem.HandlingTrainerMemoryIntensity = 0;
}
if (Entity.Format >= 6)
Entity.ClearMemories();
}
else // No longer an egg
{
@ -2263,6 +2302,30 @@ private async Task ShowFullLegalityReport()
// Set base friendship
Friendship = Entity.PersonalInfo.BaseFriendship;
Entity.CurrentFriendship = (byte)Friendship;
// If no egg location, set reasonable defaults for no-longer-egg
if (EggLocation == 0)
{
_isPopulating = true;
try
{
MetAsEgg = false;
}
finally { _isPopulating = false; }
}
else
{
// Has egg location — set met date/location to match hatching
_isPopulating = true;
try
{
var hatchLoc = EncounterSuggestion.GetSuggestedEggMetLocation(Entity);
MetLocation = hatchLoc;
Entity.MetLocation = hatchLoc;
SelectedMetLocation = MetLocationList.FirstOrDefault(x => x.Value == hatchLoc);
}
finally { _isPopulating = false; }
}
}
OnPropertyChanged(nameof(FriendshipLabel));

View File

@ -687,7 +687,7 @@
<StackPanel IsVisible="{Binding HasWalkingMood}" Spacing="0">
<TextBlock Text="Walking" FontWeight="SemiBold" Margin="0,2,0,2" />
<Grid RowDefinitions="27" ColumnDefinitions="104,*">
<TextBlock Text="Mood:" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,6,0" />
<TextBlock Grid.Row="0" Grid.Column="0" Text="Mood:" TextAlignment="Right" VerticalAlignment="Center" Margin="0,0,6,0" />
<NumericUpDown Grid.Column="1" Value="{Binding WalkingMood}" Minimum="-127" Maximum="127" Height="25" Width="60" HorizontalAlignment="Left" />
</Grid>
</StackPanel>