mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-28 11:31:38 -05:00
Misc fixes
Pokewalker: defer match if shiny Jacq egg: recognize unhatched egg, traded sv-pokedex-old: don't add rows for >1010 species (out of range) static9: correctly flag scale mismatch SAV4HGSS: expose pokegear #'s as span instead of alloc
This commit is contained in:
@@ -6,18 +6,19 @@ namespace PKHeX.Core;
|
||||
internal static class Encounters2GBEra
|
||||
{
|
||||
private static readonly string[] PCNYx = { "PCNYa", "PCNYb", "PCNYc", "PCNYd" };
|
||||
private static readonly string[] Stadium2 = { "Stade", "Stadion", "Stadio", "Estadio" };
|
||||
|
||||
internal static readonly EncounterGift2[] StaticEventsGB =
|
||||
{
|
||||
// Stadium 2 Baton Pass Farfetch'd
|
||||
new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2000, OT_Name = "スタジアム"},
|
||||
new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2000, OT_Name = "Stadium", Language = International},
|
||||
new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2001, OT_Names = new[]{"Stade", "Stadion", "Stadio", "Estadio"}, Language = International},
|
||||
new(083, 05, C) {Moves = new(226, 14, 97, 163), Location = 127, TID16 = 2001, OT_Names = Stadium2, Language = International},
|
||||
|
||||
// Stadium 2 Earthquake Gligar
|
||||
new(207, 05, C) {Moves = new(89, 68, 17), Location = 127, TID16 = 2000, OT_Name = "スタジアム"},
|
||||
new(207, 05, C) {Moves = new(89, 68, 17), Location = 127, TID16 = 2000, OT_Name = "Stadium", Language = International},
|
||||
new(207, 05, C) {Moves = new(89, 68, 17), Location = 127, TID16 = 2001, OT_Names = new[]{"Stade", "Stadion", "Stadio", "Estadio"}, Language = International},
|
||||
new(207, 05, C) {Moves = new(89, 68, 17), Location = 127, TID16 = 2001, OT_Names = Stadium2, Language = International},
|
||||
|
||||
//New York Pokémon Center Events
|
||||
|
||||
|
||||
@@ -165,6 +165,8 @@ public EncounterMatchRating GetMatchRating(PKM pk)
|
||||
{
|
||||
if (IsMatchPartial(pk))
|
||||
return EncounterMatchRating.PartialMatch;
|
||||
if (pk.IsShiny)
|
||||
return EncounterMatchRating.DeferredErrors;
|
||||
return EncounterMatchRating.Match;
|
||||
}
|
||||
|
||||
|
||||
@@ -168,8 +168,22 @@ public bool IsMatchExact(PKM pk, EvoCriteria evo)
|
||||
|
||||
private bool IsMatchEggLocation(PKM pk)
|
||||
{
|
||||
var expect = pk is PB8 ? Locations.Default8bNone : EggLocation;
|
||||
return pk.Egg_Location == expect;
|
||||
var eggloc = pk.Egg_Location;
|
||||
if (!EggEncounter)
|
||||
{
|
||||
var expect = pk is PB8 ? Locations.Default8bNone : EggLocation;
|
||||
return eggloc == expect;
|
||||
}
|
||||
|
||||
if (!pk.IsEgg) // hatched
|
||||
return eggloc == EggLocation || eggloc == Locations.LinkTrade6;
|
||||
|
||||
// Unhatched:
|
||||
if (eggloc != EggLocation)
|
||||
return false;
|
||||
if (pk.Met_Location is not (0 or Locations.LinkTrade6))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsMatchLocation(PKM pk)
|
||||
@@ -191,7 +205,7 @@ public EncounterMatchRating GetMatchRating(PKM pk)
|
||||
|
||||
private bool IsMatchLocationExact(PKM pk)
|
||||
{
|
||||
if (EggEncounter && !pk.IsEgg)
|
||||
if (EggEncounter)
|
||||
return true;
|
||||
return pk.Met_Location == Location;
|
||||
}
|
||||
@@ -249,7 +263,7 @@ private bool IsMatchPartial(PKM pk)
|
||||
}
|
||||
var current = pk is IScaledSize3 size3 ? size3.Scale : v.HeightScalar;
|
||||
if (current != Size)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pk is { AbilityNumber: 4 } && this.IsPartialMatchHidden(pk.Species, Species))
|
||||
|
||||
@@ -105,7 +105,6 @@ private void InitializeFilters()
|
||||
BatchFiltersMeta = meta;
|
||||
}
|
||||
|
||||
|
||||
private IEnumerable<PKM> SearchInner(IEnumerable<PKM> list)
|
||||
{
|
||||
foreach (var pk in list)
|
||||
|
||||
@@ -189,17 +189,17 @@ public int Badges16
|
||||
public PokegearNumber GetCallerAtIndex(int index) => (PokegearNumber)General[OFS_GearRolodex + index];
|
||||
public void SetCallerAtIndex(int index, PokegearNumber caller) => General[OFS_GearRolodex + index] = (byte)caller;
|
||||
|
||||
public PokegearNumber[] GetPokeGearRoloDex()
|
||||
public Span<PokegearNumber> GetPokeGearRoloDex()
|
||||
{
|
||||
var arr = General.Slice(OFS_GearRolodex, GearMaxCallers);
|
||||
return MemoryMarshal.Cast<byte, PokegearNumber>(arr).ToArray();
|
||||
return MemoryMarshal.Cast<byte, PokegearNumber>(arr);
|
||||
}
|
||||
|
||||
public void SetPokeGearRoloDex(ReadOnlySpan<PokegearNumber> value)
|
||||
{
|
||||
if (value.Length > GearMaxCallers)
|
||||
throw new ArgumentOutOfRangeException(nameof(value));
|
||||
MemoryMarshal.Cast<PokegearNumber, byte>(value).CopyTo(General.Slice(OFS_GearRolodex, GearMaxCallers));
|
||||
MemoryMarshal.AsBytes(value).CopyTo(General.Slice(OFS_GearRolodex, GearMaxCallers));
|
||||
}
|
||||
|
||||
public void PokeGearUnlockAllCallers()
|
||||
@@ -210,31 +210,32 @@ public void PokeGearUnlockAllCallers()
|
||||
|
||||
public void PokeGearClearAllCallers(int start = 0)
|
||||
{
|
||||
for (int i = start; i < GearMaxCallers; i++)
|
||||
SetCallerAtIndex(i, PokegearNumber.None);
|
||||
var dex = GetPokeGearRoloDex();
|
||||
dex[start..].Fill(PokegearNumber.None);
|
||||
}
|
||||
|
||||
private static ReadOnlySpan<PokegearNumber> NotTrainers => new[]
|
||||
{
|
||||
PokegearNumber.Mother,
|
||||
PokegearNumber.Professor_Elm,
|
||||
PokegearNumber.Professor_Oak,
|
||||
PokegearNumber.Ethan,
|
||||
PokegearNumber.Lyra,
|
||||
PokegearNumber.Kurt,
|
||||
PokegearNumber.Daycare_Man,
|
||||
PokegearNumber.Daycare_Lady,
|
||||
PokegearNumber.Bill,
|
||||
PokegearNumber.Bike_Shop,
|
||||
PokegearNumber.Baoba,
|
||||
};
|
||||
|
||||
public void PokeGearUnlockAllCallersNoTrainers()
|
||||
{
|
||||
var nonTrainers = new[]
|
||||
{
|
||||
PokegearNumber.Mother,
|
||||
PokegearNumber.Professor_Elm,
|
||||
PokegearNumber.Professor_Oak,
|
||||
PokegearNumber.Ethan,
|
||||
PokegearNumber.Lyra,
|
||||
PokegearNumber.Kurt,
|
||||
PokegearNumber.Daycare_Man,
|
||||
PokegearNumber.Daycare_Lady,
|
||||
PokegearNumber.Bill,
|
||||
PokegearNumber.Bike_Shop,
|
||||
PokegearNumber.Baoba,
|
||||
};
|
||||
for (int i = 0; i < nonTrainers.Length; i++)
|
||||
SetCallerAtIndex(i, nonTrainers[i]);
|
||||
var dex = GetPokeGearRoloDex();
|
||||
NotTrainers.CopyTo(dex);
|
||||
|
||||
// clear remaining callers
|
||||
PokeGearClearAllCallers(nonTrainers.Length);
|
||||
PokeGearClearAllCallers(NotTrainers.Length);
|
||||
}
|
||||
|
||||
// Apricorn Pouch
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using PKHeX.Core;
|
||||
|
||||
@@ -20,7 +20,7 @@ public void Initialize(SAV4HGSS sav)
|
||||
|
||||
private void RefreshList()
|
||||
{
|
||||
PG_Rolodex.SelectedObject = Rolodex = SAV.GetPokeGearRoloDex();
|
||||
PG_Rolodex.SelectedObject = Rolodex = SAV.GetPokeGearRoloDex().ToArray();
|
||||
PG_Rolodex.Refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,9 @@ public SAV_PokedexSV(SAV9SV sav)
|
||||
CB_Species.Items.Clear();
|
||||
|
||||
// Fill List
|
||||
const int maxSpecies = (int)Species.IronLeaves; // 1010 -- no DLC species
|
||||
CB_Species.InitializeBinding();
|
||||
var species = GameInfo.SpeciesDataSource.Where(z => SAV.Personal.IsSpeciesInGame((ushort)z.Value)).ToArray();
|
||||
var species = GameInfo.SpeciesDataSource.Where(z => SAV.Personal.IsSpeciesInGame((ushort)z.Value) && z.Value <= maxSpecies).ToArray();
|
||||
CB_Species.DataSource = new BindingSource(species, null);
|
||||
|
||||
var list = species
|
||||
|
||||
@@ -30,5 +30,4 @@ public static void InitializeLegality()
|
||||
IsInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user