Prep for next wave of implementation

need to get a release out beforehand tho
This commit is contained in:
Kurt 2017-04-23 09:18:42 -07:00
parent d402c1ee61
commit 2b1bc213aa
9 changed files with 72 additions and 19 deletions

34
PKHeX/Legality/RNG/RNG.cs Normal file
View file

@ -0,0 +1,34 @@
namespace PKHeX.Core
{
public class RNG
{
public static RNG LCRNG = new RNG(0x41C64E6D, 0x00006073, 0xEEB9EB65, 0x0A3561A1);
public static RNG XDRNG = new RNG(0x000343FD, 0x00269EC3, 0xB9B33155, 0xA170F641);
public static RNG ARNG = new RNG(0x6C078965, 0x00000001, 0x9638806D, 0x69C77F93);
private readonly uint Mult, Add, rMult, rAdd;
protected RNG(uint f_mult, uint f_add, uint r_mult, uint r_add)
{
Mult = f_mult;
Add = f_add;
rMult = r_mult;
rAdd = r_add;
}
public uint Next(uint seed) => seed * Mult + Add;
private uint Prev(uint seed) => seed * rMult + rAdd;
private uint Advance(uint seed, int frames)
{
for (int i = 0; i < frames; i++)
seed = Next(seed);
return seed;
}
private uint Reverse(uint seed, int frames)
{
for (int i = 0; i < frames; i++)
seed = Prev(seed);
return seed;
}
}
}

View file

@ -0,0 +1,10 @@
namespace PKHeX.Core
{
// Gender Locking
public class EncounterLock
{
public int Species;
public int Nature = -1;
public int Gender = -1;
}
}

View file

@ -18,7 +18,6 @@
public bool EggEncounter => false;
public int Generation { get; set; } = -1;
public EncounterSlot() { }
public virtual EncounterSlot Clone()
{
return new EncounterSlot
@ -47,7 +46,6 @@
public class EncounterSlot1 : EncounterSlot
{
public int Rate;
public EncounterSlot1() { }
public override EncounterSlot Clone()
{
return new EncounterSlot1

View file

@ -159,4 +159,13 @@
};
}
}
public class EncounterStaticShadow : EncounterStatic
{
public EncounterLock[] Locks;
protected override EncounterStatic Clone(int location)
{
throw new System.Exception();
}
}
}

View file

@ -5,8 +5,8 @@
public int Species { get; set; }
public int[] Moves { get; set; }
public int Level;
public int LevelMin { get { return Level; } set { } }
public int LevelMax { get { return 100; } set { } }
public int LevelMin => Level;
public int LevelMax => 100;
public int Generation { get; set; } = -1;
public int Location = -1;

View file

@ -0,0 +1,11 @@
namespace PKHeX.Core
{
public class PIDIV
{
/// <summary> The RNG that generated the PKM from the <see cref="OriginSeed"/> </summary>
public RNG RNG;
/// <summary> The RNG seed which immediately generates the PIDIV (starting with PID or IVs, whichever comes first). </summary>
public uint OriginSeed;
}
}

View file

@ -155,9 +155,11 @@
<Compile Include="Legality\LegalityCheckStrings.cs" />
<Compile Include="Legality\Core.cs" />
<Compile Include="Legality\Data.cs" />
<Compile Include="Legality\RNG\RNG.cs" />
<Compile Include="Legality\Structures\DexLevel.cs" />
<Compile Include="Legality\Structures\EggMoves.cs" />
<Compile Include="Legality\Structures\EncounterArea.cs" />
<Compile Include="Legality\Structures\EncounterLock.cs" />
<Compile Include="Legality\Structures\EncounterType.cs" />
<Compile Include="Legality\Structures\GBEncounterData.cs" />
<Compile Include="Legality\Structures\IEncounterable.cs" />
@ -171,6 +173,7 @@
<Compile Include="Legality\Structures\IRibbonSet.cs" />
<Compile Include="Legality\Structures\Learnset.cs" />
<Compile Include="Legality\Structures\Nature.cs" />
<Compile Include="Legality\Structures\PIDIV.cs" />
<Compile Include="Legality\Structures\SlotType.cs" />
<Compile Include="Legality\Tables.cs" />
<Compile Include="Legality\Tables2.cs" />

View file

@ -60,20 +60,8 @@ namespace PKHeX.Core
}.Contains((int)len);
}
public static uint LCRNG(uint seed)
{
const uint a = 0x41C64E6D;
const uint c = 0x00006073;
return seed * a + c;
}
public static uint LCRNG(ref uint seed)
{
const uint a = 0x41C64E6D;
const uint c = 0x00006073;
return seed = seed * a + c;
}
public static uint LCRNG(uint seed) => RNG.LCRNG.Next(seed);
public static uint LCRNG(ref uint seed) => seed = RNG.LCRNG.Next(seed);
#region ExpTable
private static readonly uint[,] ExpTable =
{

View file

@ -33,7 +33,7 @@ namespace PKHeX.Core
}
public void SetEntry(StrategyMemoEntry entry)
{
int index = Array.FindIndex(Entries.ToArray(), ent => ent.Species == entry.Species);
int index = Entries.FindIndex(ent => ent.Species == entry.Species);
if (index > 0)
Entries[index] = entry;
else