Minor tweaks for api consumers

Indicate Shiny.Random on home shiny-possible gifts
More detailed exception message for GetLearnset/GetPersonal
This commit is contained in:
Kurt 2022-02-12 22:24:48 -08:00
parent 0eece2711a
commit 2267e1a879
4 changed files with 15 additions and 7 deletions

View file

@ -58,7 +58,8 @@ namespace PKHeX.Core
Stadium => Legal.LevelUpY,
Stadium2 => Legal.LevelUpGS,
_ => throw new ArgumentOutOfRangeException(nameof(game)),
_ => throw new ArgumentOutOfRangeException(nameof(game), $"{game} is not a valid entry in the expression."),
};
private static PersonalTable Personal(GameVersion game) => game switch
@ -104,7 +105,7 @@ namespace PKHeX.Core
Stadium => PersonalTable.Y,
Stadium2 => PersonalTable.GS,
_ => throw new ArgumentOutOfRangeException(nameof(game)),
_ => throw new ArgumentOutOfRangeException(nameof(game), $"{game} is not a valid entry in the expression."),
};
}
}

View file

@ -52,7 +52,7 @@ namespace PKHeX.Core
public string Nickname
{
get => StringConverter5.GetString(Data.AsSpan( 0x1E, 11 * 2));
get => StringConverter5.GetString(Data.AsSpan(0x1E, 11 * 2));
set => StringConverter5.SetString(Data.AsSpan(0x1E, 11 * 2), value.AsSpan(), 11, StringConverterOption.ClearFF);
}

View file

@ -88,6 +88,8 @@ namespace PKHeX.Core
var type = PIDType;
if (type is not Shiny.FixedValue)
return type;
if (IsHOMEGift && IsHOMEShinyPossible())
return Shiny.Random;
return GetShinyXor() switch
{
0 => Shiny.AlwaysSquare,
@ -605,9 +607,9 @@ namespace PKHeX.Core
if (!pkm.IsShiny)
return false;
}
else
else // Never or Random (HOME ID specific)
{
if (pkm.IsShiny && !(TID == 0 && SID == 0 && PID != 0))
if (pkm.IsShiny && !IsHOMEShinyPossible())
return false;
}
}
@ -673,6 +675,12 @@ namespace PKHeX.Core
return pkm.PID == GetPID(pkm, type);
}
private bool IsHOMEShinyPossible()
{
// no defined TID/SID and having a fixed PID can cause the player's TID/SID to match the PID's shiny calc.
return TID == 0 && SID == 0 && PID != 0;
}
protected override bool IsMatchDeferred(PKM pkm) => Species != pkm.Species;
protected override bool IsMatchPartial(PKM pkm) => false; // no version compatibility checks yet.

View file

@ -121,14 +121,13 @@ namespace PKHeX.Core
PokeDex = 0;
}
private const int SIZE_RESERVED = 0x8000; // unpacked box data
private readonly SAV1Offsets Offsets;
// Event Flags
protected override int EventFlagMax => 0xA00; // 320 * 8
protected override int EventConstMax => 0;
private const int SIZE_RESERVED = 0x8000; // unpacked box data
protected override byte[] GetFinalData()
{
var capacity = Japanese ? PokeListType.StoredJP : PokeListType.Stored;