mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
67fc0d0885
Add Cap Pikachu const value updating for USUM, also set Magearna const for USUM (not only SM) Remove `NotDistributed` property from WC3 as only CXD events used it, no longer WC3 type. Delete ArrayUtil; move remaining methods into the StorageUtil class that used them for compressing/inserting bulk into boxes. Add shiny wormhole flag Extract byte array strings into spans, faster tests and less overhead.
67 lines
3.3 KiB
C#
67 lines
3.3 KiB
C#
using System;
|
|
using FluentAssertions;
|
|
using Xunit;
|
|
|
|
namespace PKHeX.Core.Tests.Legality;
|
|
|
|
public class RaidTests
|
|
{
|
|
// Just a regular Charizard pk8
|
|
private static ReadOnlySpan<byte> Charizard =>
|
|
[
|
|
0x65, 0xE7, 0x9F, 0xC0, 0x00, 0x00, 0x85, 0xF1, 0x06, 0x00, 0x60, 0x04, 0x5C, 0xF0, 0xA3, 0xAA,
|
|
0x14, 0x2C, 0x10, 0x00, 0x5E, 0x00, 0x14, 0x00, 0x15, 0x01, 0x00, 0x00, 0xEE, 0x55, 0x01, 0xE2,
|
|
0x08, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x8A, 0xAD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x72, 0x00,
|
|
0x69, 0x00, 0x7A, 0x00, 0x61, 0x00, 0x72, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x35, 0x00, 0x1E, 0x02, 0x4C, 0x00, 0x9B, 0x01, 0x18, 0x10, 0x10, 0x08, 0x03, 0x03,
|
|
0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x01, 0xFF, 0x7F, 0x1E, 0x3F,
|
|
0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x00, 0x69, 0x00, 0x63, 0x00, 0x74, 0x00,
|
|
0x6F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x01, 0x02, 0x01, 0x00, 0x00, 0x00, 0x32, 0x01, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00,
|
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x72, 0x00, 0x63, 0x00, 0x68, 0x00,
|
|
0x69, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x01, 0x17, 0x00,
|
|
0x00, 0x00, 0xA2, 0x00, 0x09, 0x37, 0x28, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
|
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x29, 0x01, 0xB7, 0x00, 0xC1, 0x00,
|
|
0x48, 0x01, 0x3D, 0x01, 0xCE, 0x00, 0x00, 0x00,
|
|
];
|
|
|
|
[Fact]
|
|
public void CheckDynamaxRaidCharizardPK8()
|
|
{
|
|
var pk8 = new PK8();
|
|
|
|
const ulong seed = 0xbefd08cf9e027d0a;
|
|
Charizard.CopyTo(pk8.Data);
|
|
|
|
bool found = IsPotentialRaidSeed(pk8.EncryptionConstant, pk8.PID, seed);
|
|
found.Should().BeTrue();
|
|
|
|
// Ensure it matches encounter data and the actual seed is matched.
|
|
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;
|
|
}
|
|
}
|