mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-25 21:40:21 +00:00
Minor clean
No alloc EncounterEgg relearn moves (use span instead) Move HoneyTreeUtil out of root Saves folder Minor readability tweaks
This commit is contained in:
parent
06c36130c5
commit
e448679f4a
4 changed files with 30 additions and 15 deletions
|
@ -15,7 +15,7 @@ public static class LearnVerifierRelearn
|
|||
else if (enc is IRelearn {Relearn: {HasMoves: true} x})
|
||||
VerifyRelearnSpecifiedMoveset(pk, x, result);
|
||||
else if (enc is EncounterEgg e)
|
||||
VerifyEggMoveset(e, result, pk.RelearnMoves);
|
||||
VerifyEggMoveset(e, result, pk);
|
||||
else if (enc is EncounterSlot6AO { CanDexNav: true } z && pk.RelearnMove1 != 0)
|
||||
VerifyRelearnDexNav(pk, result, z);
|
||||
else if (enc is EncounterSlot8b { IsUnderground: true } u)
|
||||
|
@ -75,6 +75,13 @@ public static class LearnVerifierRelearn
|
|||
result[0] = ParseExpect(pk.RelearnMove1);
|
||||
}
|
||||
|
||||
private static void VerifyEggMoveset(EncounterEgg e, Span<MoveResult> result, PKM pk)
|
||||
{
|
||||
Span<ushort> moves = stackalloc ushort[4];
|
||||
pk.GetRelearnMoves(moves);
|
||||
VerifyEggMoveset(e, result, moves);
|
||||
}
|
||||
|
||||
internal static void VerifyEggMoveset(EncounterEgg e, Span<MoveResult> result, ReadOnlySpan<ushort> moves)
|
||||
{
|
||||
int gen = e.Generation;
|
||||
|
|
|
@ -142,7 +142,11 @@ public partial class SAV_BlockDump8 : Form
|
|||
private static void ExportAllBlocks(IEnumerable<SCBlock> blocks, string path)
|
||||
{
|
||||
foreach (var b in blocks.Where(z => z.Data.Length != 0))
|
||||
File.WriteAllBytes(Path.Combine(path, $"{GetBlockFileNameWithoutExtension(b)}.bin"), b.Data);
|
||||
{
|
||||
var fn = $"{GetBlockFileNameWithoutExtension(b)}.bin";
|
||||
var fileName = Path.Combine(path, fn);
|
||||
File.WriteAllBytes(fileName, b.Data);
|
||||
}
|
||||
}
|
||||
|
||||
private void B_ImportFolder_Click(object sender, EventArgs e)
|
||||
|
@ -170,8 +174,14 @@ public partial class SAV_BlockDump8 : Form
|
|||
return;
|
||||
|
||||
var path = sfd.FileName;
|
||||
|
||||
var blocks = SAV.Accessor.BlockInfo;
|
||||
var option = GetExportOption();
|
||||
|
||||
ExportAllBlocksAsSingleFile(blocks, path, option);
|
||||
}
|
||||
|
||||
private SCBlockExportOption GetExportOption()
|
||||
{
|
||||
var option = SCBlockExportOption.None;
|
||||
if (CHK_DataOnly.Checked)
|
||||
option |= SCBlockExportOption.DataOnly;
|
||||
|
@ -181,8 +191,7 @@ public partial class SAV_BlockDump8 : Form
|
|||
option |= SCBlockExportOption.TypeInfo;
|
||||
if (CHK_FakeHeader.Checked)
|
||||
option |= SCBlockExportOption.FakeHeader;
|
||||
|
||||
ExportAllBlocksAsSingleFile(blocks, path, option);
|
||||
return option;
|
||||
}
|
||||
|
||||
private void B_LoadOld_Click(object sender, EventArgs e)
|
||||
|
@ -260,7 +269,7 @@ public partial class SAV_BlockDump8 : Form
|
|||
}
|
||||
|
||||
var bytes = File.ReadAllBytes(path);
|
||||
bytes.CopyTo(data, 0);
|
||||
blockTarget.ChangeData(bytes);
|
||||
}
|
||||
|
||||
private void PG_BlockView_PropertyValueChanged(object s, PropertyValueChangedEventArgs? e)
|
||||
|
|
|
@ -25,11 +25,10 @@ public class LegalityTest
|
|||
[Theory]
|
||||
[InlineData("Legal", true)]
|
||||
[InlineData("Illegal", false)]
|
||||
public void TestPublicFiles(string name, bool isValid)
|
||||
public void TestPublicFiles(string subFolder, bool isValid)
|
||||
{
|
||||
var folder = TestUtil.GetRepoPath();
|
||||
folder = Path.Combine(folder, "Legality");
|
||||
VerifyAll(folder, name, isValid);
|
||||
var folder = Path.Combine(TestPath, "Legality");
|
||||
VerifyAll(folder, subFolder, isValid);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -37,16 +36,16 @@ public class LegalityTest
|
|||
[InlineData("Illegal", false)]
|
||||
[InlineData("PassingHacks", true)] // mad hacks, stuff to be flagged in the future
|
||||
[InlineData("FalseFlags", false)] // legal quirks, to be fixed in the future
|
||||
public void TestPrivateFiles(string name, bool isValid)
|
||||
public void TestPrivateFiles(string subFolder, bool isValid)
|
||||
{
|
||||
var folder = Path.Combine(TestPath, "Legality", "Private");
|
||||
VerifyAll(folder, name, isValid, false);
|
||||
VerifyAll(folder, subFolder, isValid, false);
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedParameter.Local
|
||||
private static void VerifyAll(string folder, string name, bool isValid, bool checkDir = true)
|
||||
private static void VerifyAll(string folder, string subFolder, bool isValid, bool checkDir = true)
|
||||
{
|
||||
var path = Path.Combine(folder, name);
|
||||
var path = Path.Combine(folder, subFolder);
|
||||
bool exists = Directory.Exists(path);
|
||||
if (checkDir)
|
||||
exists.Should().BeTrue($"the specified test directory at '{path}' should exist");
|
||||
|
@ -89,7 +88,7 @@ public class LegalityTest
|
|||
legality.Valid.Should().BeFalse($"because the file '{fn}' should be invalid, but found Valid.");
|
||||
}
|
||||
}
|
||||
ctr.Should().BeGreaterThan(0);
|
||||
ctr.Should().BeGreaterThan(0, "any amount of files should have been processed from a folder that exists.");
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetIllegalLines(LegalityAnalysis legality)
|
||||
|
|
Loading…
Reference in a new issue