Misc tweaks

Fix dexnav move being allowed when relearn cleared and not learnable in dest game (duskull destiny bond gen9)
Move farfetch'd check to top of not-nicknamed, add deferral for GO match
This commit is contained in:
Kurt 2024-06-30 19:14:21 -05:00
parent 11b1eeb6c8
commit 298c83bc09
5 changed files with 40 additions and 19 deletions

View file

@ -8,7 +8,7 @@ namespace PKHeX.Core;
public sealed class EncounterGenerator7GG : IEncounterGenerator
{
public static readonly EncounterGenerator7GG Instance = new();
public bool CanGenerateEggs => true;
public bool CanGenerateEggs => false;
public IEnumerable<IEncounterable> GetPossible(PKM _, EvoCriteria[] chain, GameVersion game, EncounterTypeGroup groups)
{

View file

@ -229,11 +229,31 @@ public sealed record EncounterSlot8GO(int StartDate, int EndDate, ushort Species
{
if (IsMatchPartial(pk))
return EncounterMatchRating.PartialMatch;
if (Species is (int)Farfetchd && IsReallySirfetchd(pk))
return EncounterMatchRating.DeferredErrors;
if (!this.GetIVsValid(pk))
return EncounterMatchRating.Deferred;
return EncounterMatchRating.Match;
}
/// <summary>
/// Checks if a Farfetch'd was originally a Sirfetch'd.
/// </summary>
/// <remarks>Only basis we can check with is if it has the bad HOME apostrophe.</remarks>
private static bool IsReallySirfetchd(PKM pk)
{
if (pk.Species != (int)Sirfetchd)
return false;
// Check for the "wrong" apostrophe. If it matches the species name, then it was originally Farfetch'd.
if (pk.IsNicknamed || !SpeciesName.IsApostropheFarfetchdLanguage(pk.Language))
return false; // can't tell if it was originally Farfetch'd
Span<char> name = stackalloc char[pk.TrashCharCountNickname];
pk.LoadString(pk.NicknameTrash, name);
return name is "Sirfetch'd"; // only way to get the bad apostrophe is to originate in HOME with it.
}
public byte OriginalTrainerFriendship => Species switch
{
(int)Timburr when Form == 0 => 70,

View file

@ -64,7 +64,7 @@ public sealed class LearnGroup6 : ILearnGroup
var move = current[i];
if (!dexnav.CanBeDexNavMove(move))
continue;
result[i] = new(new(LearnMethod.Encounter, LearnEnvironment.ORAS), Generation);
result[i] = new(new(LearnMethod.Encounter, LearnEnvironment.ORAS), Generation: Generation);
break;
}
}

View file

@ -106,7 +106,7 @@ public sealed class LearnGroupHOME : ILearnGroup
/// <returns>True if all results are valid.</returns>
private static bool CleanPurge(Span<MoveResult> result, ReadOnlySpan<ushort> current, PKM pk, MoveSourceType types, IHomeSource local, ReadOnlySpan<EvoCriteria> evos)
{
// The logic used to update the results did not check if the move was could be learned in the local game.
// The logic used to update the results did not check if the move could be learned in the local game.
// Double-check the results and remove any that are not valid for the local game.
// SW/SH will continue to iterate downwards to previous groups after HOME is checked, so we can exactly check via Environment.
for (int i = 0; i < result.Length; i++)

View file

@ -256,6 +256,21 @@ public sealed class NicknameVerifier : Verifier
ushort species = pk.Species;
byte format = pk.Format;
int language = pk.Language;
// Farfetchd and Sirfetchd have different apostrophes in HOME, only if transferred from 3DS or GO => HOME.
// HOME doesn't use the right apostrophe. ' vs
if (format >= 8 && species is (int)Species.Farfetchd or (int)Species.Sirfetchd)
{
// Evolving in-game fixes it. Check only un-evolved and affected languages.
if (species == enc.Species && SpeciesName.IsApostropheFarfetchdLanguage(language))
{
if (enc is { Generation: < 8, Context: not EntityContext.Gen7b }) // 3DS -> HOME
return nickname is "Farfetch'd";
if (enc is EncounterSlot8GO) // GO -> HOME
return species is (int)Species.Farfetchd ? nickname is "Farfetch'd" : nickname is "Sirfetch'd";
}
}
ReadOnlySpan<char> expect = SpeciesName.GetSpeciesNameGeneration(species, language, format);
if (nickname.SequenceEqual(expect))
return true;
@ -269,26 +284,12 @@ public sealed class NicknameVerifier : Verifier
if (canHaveAnyLanguage && !SpeciesName.IsNicknamedAnyLanguage(species, nickname, format))
return true;
switch (enc)
{
case ILangNick loc:
if (loc.Language != 0 && !loc.IsNicknamed && !SpeciesName.IsNicknamedAnyLanguage(species, nickname, format))
return true; // fixed language without nickname, nice job event maker!
break;
}
if (enc is ILangNick loc && loc.Language != 0 && !loc.IsNicknamed && !SpeciesName.IsNicknamedAnyLanguage(species, nickname, format))
return true; // fixed language without nickname, nice job event maker!
if (format == 5 && enc.Generation != 5) // transfer
return IsMatch45(nickname, species, expect, language, canHaveAnyLanguage);
if (format >= 8 && enc is { Generation: < 8 } or IPogoSlot) // HOME weirdness
{
// HOME doesn't use the right apostrophe. ' vs
if (pk.Species == (int)Species.Farfetchd)
return nickname is "Farfetch'd";
if (pk.Species == (int)Species.Sirfetchd)
return nickname is "Sirfetch'd";
}
return false;
}