2023-01-22 04:02:33 +00:00
|
|
|
using System;
|
2020-01-23 08:11:07 +00:00
|
|
|
using FluentAssertions;
|
|
|
|
using Xunit;
|
|
|
|
|
2023-01-22 04:02:33 +00:00
|
|
|
namespace PKHeX.Core.Tests.Legality;
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
public class RaidTests
|
2020-01-23 08:11:07 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
public const string Charizard = "65E79FC0000085F1060060045CF0A3AA142C10005E00140015010000EE5501E2080A00000000000004FCFC0000000000000000008800000000001C0000000000000000000000000000000000000000008AAD000000000000430068006100720069007A00610072006400000000000000000035001E024C009B01181010080303030300000000000000002901FF7F1E3F0A000000000000000000000000000000000000000000000056006900630074006F0072006900610000000000000000000000010201000000320104080000000000000000000000000000000000002C000000020000000000FF0000000000000000000000000000004100720063006800690074000000000000000000000000000000FF000000000000000000140117000000A20009372804000000000000000100000200000000000000000000000000000000000000000064002901B700C10048013D01CE000000";
|
2020-01-23 08:11:07 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Theory]
|
|
|
|
[InlineData(Charizard, 0xbefd08cf9e027d0a)]
|
|
|
|
public void CheckMatch(string raw, ulong seed)
|
|
|
|
{
|
|
|
|
byte[] data = raw.ToByteArray();
|
|
|
|
var pk8 = new PK8(data);
|
2020-01-23 08:11:07 +00:00
|
|
|
|
2023-08-15 03:01:38 +00:00
|
|
|
bool found = false;
|
|
|
|
var seeds = new XoroMachineSkip(pk8.EncryptionConstant, pk8.PID);
|
|
|
|
foreach (var s in seeds)
|
|
|
|
{
|
|
|
|
if (s != seed)
|
|
|
|
continue;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
found.Should().BeTrue();
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var la = new LegalityAnalysis(pk8);
|
|
|
|
var enc = la.EncounterMatch;
|
2020-01-23 08:11:07 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var compare = enc switch
|
|
|
|
{
|
|
|
|
EncounterStatic8N r => r.Verify(pk8, seed),
|
|
|
|
EncounterStatic8ND r => r.Verify(pk8, seed),
|
|
|
|
EncounterStatic8NC r => r.Verify(pk8, seed),
|
2023-08-15 03:01:38 +00:00
|
|
|
EncounterStatic8U r => r.Verify(pk8, seed),
|
2022-06-18 18:04:24 +00:00
|
|
|
_ => throw new ArgumentException(nameof(enc)),
|
|
|
|
};
|
|
|
|
compare.Should().BeTrue();
|
2020-01-23 08:11:07 +00:00
|
|
|
}
|
|
|
|
}
|