mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-20 14:21:59 +00:00
95fbf66a6e
In addition to the Method 1 (and other sibling PIDIV types) correlation, an encounter can only be triggered if the calls prior land on the Method {1} seed. The RNG community has dubbed these patterns as "Method J" (D/P/Pt), "Method K" (HG/SS), and "Method H" (Gen3, coined by yours truly). The basic gist of these is that they are pre-requisites, like the Shadow locks of Colosseum/XD. Rename/re-type a bunch of properties to get the codebase more in line with correct property names & more obvious underlying types.
40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
using System;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace PKHeX.Core.Tests.Legality;
|
|
|
|
public class RaidTests
|
|
{
|
|
public const string Charizard = "65E79FC0000085F1060060045CF0A3AA142C10005E00140015010000EE5501E2080A00000000000004FCFC0000000000000000008800000000001C0000000000000000000000000000000000000000008AAD000000000000430068006100720069007A00610072006400000000000000000035001E024C009B01181010080303030300000000000000002901FF7F1E3F0A000000000000000000000000000000000000000000000056006900630074006F0072006900610000000000000000000000010201000000320104080000000000000000000000000000000000002C000000020000000000FF0000000000000000000000000000004100720063006800690074000000000000000000000000000000FF000000000000000000140117000000A20009372804000000000000000100000200000000000000000000000000000000000000000064002901B700C10048013D01CE000000";
|
|
|
|
[Theory]
|
|
[InlineData(Charizard, 0xbefd08cf9e027d0a)]
|
|
public void CheckMatch(string raw, ulong seed)
|
|
{
|
|
byte[] data = raw.ToByteArray();
|
|
var pk8 = new PK8(data);
|
|
|
|
bool found = IsPotentialRaidSeed(pk8.EncryptionConstant, pk8.PID, seed);
|
|
found.Should().BeTrue();
|
|
|
|
var la = new LegalityAnalysis(pk8);
|
|
var enc = la.EncounterMatch;
|
|
if (enc is not ISeedCorrelation64<Core.PKM> s64)
|
|
throw new ArgumentException(nameof(enc));
|
|
s64.TryGetSeed(pk8, out ulong detected).Should().BeTrue();
|
|
detected.Should().Be(seed);
|
|
}
|
|
|
|
private static bool IsPotentialRaidSeed(uint ec, uint pid, ulong expect)
|
|
{
|
|
var seeds = new XoroMachineSkip(ec, pid);
|
|
foreach (var seed in seeds)
|
|
{
|
|
if (seed != expect)
|
|
continue;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|