From acff5454b6cf4f0e7e9ea40de543b8c5d9cd893d Mon Sep 17 00:00:00 2001 From: montanon Date: Mon, 16 Mar 2026 18:10:03 -0300 Subject: [PATCH] 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 --- .../ViewModels/PKMEditorViewModel.cs | 79 +++++++++++++++++-- PKHeX.Avalonia/Views/PKMEditorView.axaml | 2 +- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/PKHeX.Avalonia/ViewModels/PKMEditorViewModel.cs b/PKHeX.Avalonia/ViewModels/PKMEditorViewModel.cs index bc0919ee2..3d3b984ed 100644 --- a/PKHeX.Avalonia/ViewModels/PKMEditorViewModel.cs +++ b/PKHeX.Avalonia/ViewModels/PKMEditorViewModel.cs @@ -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)); diff --git a/PKHeX.Avalonia/Views/PKMEditorView.axaml b/PKHeX.Avalonia/Views/PKMEditorView.axaml index c56877f37..877acb657 100644 --- a/PKHeX.Avalonia/Views/PKMEditorView.axaml +++ b/PKHeX.Avalonia/Views/PKMEditorView.axaml @@ -687,7 +687,7 @@ - +