mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-15 08:47:14 +00:00
Update ownership sort
gen4 and below saves don't provide an accurate Version/Game; ignore the version check if it is not a valid game ID. secondary sort to current OT name so that same-named OT (ignoring case) are immediately after the current save's pkms.
This commit is contained in:
parent
e25e3fcc19
commit
505877763b
2 changed files with 6 additions and 3 deletions
|
@ -120,5 +120,6 @@
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static bool IsValid(this GameVersion g) => 0 < g && g <= GameVersion.RB;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,8 @@ namespace PKHeX.Core
|
||||||
public static IEnumerable<PKM> OrderByOwnership(this IEnumerable<PKM> list, ITrainerInfo trainer)
|
public static IEnumerable<PKM> OrderByOwnership(this IEnumerable<PKM> list, ITrainerInfo trainer)
|
||||||
{
|
{
|
||||||
return list.InitialSortBy()
|
return list.InitialSortBy()
|
||||||
.ThenByDescending(trainer.IsOriginalHandler) // true first
|
.ThenByDescending(p => trainer.IsOriginalHandler(p, ((GameVersion)trainer.Game).IsValid())) // true first
|
||||||
|
.ThenByDescending(p => string.Equals(p.OT_Name, trainer.OT, StringComparison.CurrentCultureIgnoreCase))
|
||||||
.OrderByTrainer()
|
.OrderByTrainer()
|
||||||
.ThenBy(p => p.Species)
|
.ThenBy(p => p.Species)
|
||||||
.FinalSortBy();
|
.FinalSortBy();
|
||||||
|
@ -168,12 +169,13 @@ namespace PKHeX.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="trainer">The <see cref="ITrainerInfo"/> requesting the check.</param>
|
/// <param name="trainer">The <see cref="ITrainerInfo"/> requesting the check.</param>
|
||||||
/// <param name="pk">Pokémon data</param>
|
/// <param name="pk">Pokémon data</param>
|
||||||
|
/// <param name="checkGame">Toggle to check the game's version or not</param>
|
||||||
/// <returns>True if OT, false if not OT.</returns>
|
/// <returns>True if OT, false if not OT.</returns>
|
||||||
private static bool IsOriginalHandler(this ITrainerInfo trainer, PKM pk)
|
private static bool IsOriginalHandler(this ITrainerInfo trainer, PKM pk, bool checkGame)
|
||||||
{
|
{
|
||||||
if (pk.Format >= 6)
|
if (pk.Format >= 6)
|
||||||
return pk.CurrentHandler != 1;
|
return pk.CurrentHandler != 1;
|
||||||
if (trainer.Game != pk.Version)
|
if (checkGame && trainer.Game != pk.Version)
|
||||||
return false;
|
return false;
|
||||||
if (trainer.TID != pk.TID || trainer.SID != pk.SID)
|
if (trainer.TID != pk.TID || trainer.SID != pk.SID)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue