From 5a37d2536440bf7e6f7dde07a016549f8bd4c90e Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 16 Jun 2015 21:18:06 -0700 Subject: [PATCH] Move LCRNG method to a random-based class --- pk3DS/Randomizer.cs | 12 +++++++++++- pk3DS/Tools/Image.cs | 11 +---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pk3DS/Randomizer.cs b/pk3DS/Randomizer.cs index 28d8bda..5ac5f4a 100644 --- a/pk3DS/Randomizer.cs +++ b/pk3DS/Randomizer.cs @@ -10,7 +10,7 @@ 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).Select(i => i).ToArray(); + internal static readonly int[] RandomSpeciesList = Enumerable.Range(1, 721).ToArray(); internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5, bool G6, bool L, bool E, bool Shedinja = true) { @@ -44,5 +44,15 @@ internal static int[] getSpeciesList(bool G1, bool G2, bool G3, bool G4, bool G5 return sL.Length == 0 ? RandomSpeciesList : sL; } + + public static uint LCRNG(uint seed, int ctr) + { + for (int i = 0; i < ctr; i++) + { + seed *= 0x41C64E6D; + seed += 0x00006073; + } + return seed; + } } } diff --git a/pk3DS/Tools/Image.cs b/pk3DS/Tools/Image.cs index c743034..911b2f6 100644 --- a/pk3DS/Tools/Image.cs +++ b/pk3DS/Tools/Image.cs @@ -24,7 +24,7 @@ internal static Bitmap makeIMG(string path, bool save, int shift = 4, int s = 8) c = Color.Black; else { - color = LCRNG(color, shift); + color = Randomizer.LCRNG(color, shift); c = Color.FromArgb(0xFF, 0xFF - (byte)(color & 0xFF), 0xFF - (byte)((color >> 8) & 0xFF), 0xFF - (byte)(color >> 24 & 0xFF)); } try @@ -48,14 +48,5 @@ internal static Bitmap makeIMG(string path, bool save, int shift = 4, int s = 8) return img; } } - public static uint LCRNG(uint seed, int ctr) - { - for (int i = 0; i < ctr; i++) - { - seed *= 0x41C64E6D; - seed += 0x00006073; - } - return seed; - } } }