mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Handle level20 transferred feebas edge case
Closes #2394 thanks @iiippppk !
This commit is contained in:
parent
930f4a2062
commit
03c3610eb5
7 changed files with 38 additions and 0 deletions
|
@ -52,5 +52,6 @@ namespace PKHeX.Core
|
|||
public static class EvolutionTypeExtensions
|
||||
{
|
||||
public static bool IsTrade(this EvolutionType t) => t == Trade || t == TradeHeldItem || t == TradeSpecies;
|
||||
public static bool IsLevelUpRequired(this EvolutionType t) => t.ToString().StartsWith("LevelUp"); // don't use this
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37
Tests/PKHeX.Core.Tests/Legality/LegalityData.cs
Normal file
37
Tests/PKHeX.Core.Tests/Legality/LegalityData.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using FluentAssertions;
|
||||
using PKHeX.Core;
|
||||
using Xunit;
|
||||
|
||||
namespace PKHeX.Tests.Legality
|
||||
{
|
||||
public class LegalityData
|
||||
{
|
||||
[Fact]
|
||||
public void EvolutionsOrdered() // feebas, see issue #2394
|
||||
{
|
||||
var trees = typeof(EvolutionTree).GetFields(BindingFlags.Static | BindingFlags.NonPublic);
|
||||
foreach (var t in trees)
|
||||
{
|
||||
var gen = Convert.ToInt32(t.Name[7].ToString());
|
||||
if (gen <= 4)
|
||||
continue;
|
||||
|
||||
var fTree = (EvolutionTree)t.GetValue(typeof(EvolutionTree));
|
||||
var fEntries = typeof(EvolutionTree).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).First(z => z.Name == "Entries");
|
||||
|
||||
var entries = (IReadOnlyList<EvolutionMethod[]>)fEntries.GetValue(fTree);
|
||||
var feebas = entries[(int)Species.Feebas];
|
||||
|
||||
var t1 = (EvolutionType)feebas[0].Method;
|
||||
var t2 = (EvolutionType)feebas[1].Method;
|
||||
|
||||
t1.IsLevelUpRequired().Should().BeFalse();
|
||||
t2.IsLevelUpRequired().Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue