From b71c19558a43ce646d5a21561b3668a98e13200b Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 8 Dec 2016 18:56:23 -0800 Subject: [PATCH] Increase randomizer flexibility settle on a stat randomization method (BST rand method should be here anyway for a consistent implementation) --- pk3DS/Legality/Randomizer.cs | 26 +++++++++++++++++++++++++- pk3DS/Main.cs | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pk3DS/Legality/Randomizer.cs b/pk3DS/Legality/Randomizer.cs index 0b7c8bc..4dad258 100644 --- a/pk3DS/Legality/Randomizer.cs +++ b/pk3DS/Legality/Randomizer.cs @@ -10,7 +10,31 @@ internal static int getRandomSpecies(ref int[] list, ref int ctr) int species = list[ctr++]; ctr %= list.Length; return species; } - internal static readonly int[] RandomSpeciesList = Enumerable.Range(1, 721).ToArray(); + internal static int MaxSpeciesID = 721; + internal static int[] RandomSpeciesList => Enumerable.Range(1, MaxSpeciesID).ToArray(); + internal static int getRandomSpecies(ref int[] sL, ref int ctr, int oldSpecies, bool BST, PersonalInfo[] stats = null) + { + int species = getRandomSpecies(ref sL, ref ctr); + if (!BST || stats == null) + return species; + + PersonalInfo oldpkm = stats[oldSpecies]; + PersonalInfo pkm = stats[species]; + + // Stat Deviation: increasing 10% increments if no suitable match found in entire list + int a = 11; + const int c = 10; + + int iter = 0; + while (!(pkm.BST * c/a < oldpkm.BST && pkm.BST * a/c > oldpkm.BST)) + { + species = getRandomSpecies(ref sL, ref ctr); + pkm = Main.SpeciesStat[species]; + if (++iter % sL.Length == 0) + a++; + } + return species; + } internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5, bool G6, bool G7, bool L, bool E, bool Shedinja = true) { diff --git a/pk3DS/Main.cs b/pk3DS/Main.cs index f879df7..d53ccf2 100644 --- a/pk3DS/Main.cs +++ b/pk3DS/Main.cs @@ -315,6 +315,7 @@ private bool checkIfRomFS(string path) RomFSPath = path; Config = cfg; TextFile.Config = cfg; + Randomizer.MaxSpeciesID = cfg.MaxSpeciesID; return true; } RomFSPath = null;