2019-07-11 07:13:52 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
using FluentAssertions;
|
2019-07-13 06:43:12 +00:00
|
|
|
|
using PKHeX.Core;
|
2019-07-11 07:13:52 +00:00
|
|
|
|
|
2019-07-13 06:43:12 +00:00
|
|
|
|
namespace PKHeX.Tests.Saves
|
2019-07-11 07:13:52 +00:00
|
|
|
|
{
|
|
|
|
|
public static class PokeDex
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(Species.Bulbasaur)]
|
|
|
|
|
[InlineData(Species.Voltorb)]
|
|
|
|
|
[InlineData(Species.Genesect)]
|
|
|
|
|
public static void Gen5(Species species)
|
|
|
|
|
{
|
|
|
|
|
var bw = new SAV5B2W2();
|
|
|
|
|
SetDexSpecies(bw, (int)species, 0x54);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(Species.Landorus)]
|
|
|
|
|
public static void Gen5Form(Species species)
|
|
|
|
|
{
|
|
|
|
|
var bw = new SAV5B2W2();
|
|
|
|
|
SetDexSpecies(bw, (int)species, 0x54);
|
|
|
|
|
CheckDexFlags5(bw, (int)species, 0, 0x54, 0xB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetDexSpecies(SaveFile sav, int species, int regionSize)
|
|
|
|
|
{
|
|
|
|
|
var pk5 = new PK5 {Species = species, TID = 1337}; // non-shiny
|
2019-07-13 06:43:12 +00:00
|
|
|
|
pk5.Gender = pk5.GetSaneGender();
|
2019-07-11 07:13:52 +00:00
|
|
|
|
|
|
|
|
|
int boxofs = sav.GetBoxSlotOffset(0, 0);
|
|
|
|
|
sav.SetStoredSlot(pk5, boxofs);
|
|
|
|
|
|
|
|
|
|
CheckFlags(sav, species, regionSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CheckFlags(SaveFile sav, int species, int regionSize)
|
|
|
|
|
{
|
|
|
|
|
var dex = sav.PokeDex;
|
|
|
|
|
var data = sav.Data;
|
|
|
|
|
|
|
|
|
|
var bit = species - 1;
|
|
|
|
|
var val = (byte) (1 << (bit & 7));
|
|
|
|
|
var ofs = bit >> 3;
|
|
|
|
|
data[dex + 0x08 + ofs].Should().Be(val, "caught flag");
|
|
|
|
|
data[dex + 0x08 + regionSize + ofs].Should().Be(val, "seen flag");
|
|
|
|
|
data[dex + 0x08 + regionSize + (regionSize * 4) + ofs].Should().Be(val, "displayed flag");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CheckDexFlags5(SaveFile sav, int species, int form, int regionSize, int formRegionSize)
|
|
|
|
|
{
|
|
|
|
|
var dex = sav.PokeDex;
|
|
|
|
|
var data = sav.Data;
|
|
|
|
|
|
2019-10-04 05:21:33 +00:00
|
|
|
|
var formDex = dex + 8 + (regionSize * 9);
|
2019-07-11 07:13:52 +00:00
|
|
|
|
|
|
|
|
|
int fc = sav.Personal[species].FormeCount;
|
|
|
|
|
var bit = ((SAV5)sav).Zukan.DexFormIndexFetcher(species, fc, 0);
|
|
|
|
|
if (bit < 0)
|
|
|
|
|
return;
|
|
|
|
|
bit += form;
|
|
|
|
|
var val = (byte)(1 << (bit & 7));
|
|
|
|
|
var ofs = bit >> 3;
|
|
|
|
|
data[formDex + ofs].Should().Be(val, "seen flag");
|
|
|
|
|
data[formDex + ofs + (formRegionSize * 2)].Should().Be(val, "displayed flag");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|