mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-01 05:16:35 -05:00
Misc tweaks
standardize rand usage to single instance, no functional changes
This commit is contained in:
@@ -8,7 +8,7 @@ namespace pk3DS.Core.Randomizers
|
||||
{
|
||||
public class PersonalRandomizer : IRandomizer
|
||||
{
|
||||
private static readonly Random rnd = new Random();
|
||||
private readonly Random rnd = Util.rand;
|
||||
|
||||
private const decimal LearnTMPercent = 35; // Average Learnable TMs is 35.260.
|
||||
private const decimal LearnTypeTutorPercent = 2; //136 special tutor moves learnable by species in Untouched ORAS.
|
||||
|
||||
@@ -9,11 +9,20 @@ public class EncounterStatic6
|
||||
|
||||
public ushort Species
|
||||
{
|
||||
get { return BitConverter.ToUInt16(Data, 0x0); }
|
||||
set { BitConverter.GetBytes(value).CopyTo(Data, 0x0); }
|
||||
get => BitConverter.ToUInt16(Data, 0x0);
|
||||
set => BitConverter.GetBytes(value).CopyTo(Data, 0x0);
|
||||
}
|
||||
|
||||
public byte Form
|
||||
{
|
||||
get => Data[0x2];
|
||||
set => Data[0x2] = value;
|
||||
}
|
||||
public byte Level
|
||||
{
|
||||
get => Data[0x3];
|
||||
set => Data[0x3] = value;
|
||||
}
|
||||
public byte Form { get { return Data[0x2]; } set { Data[0x2] = value; } }
|
||||
public byte Level { get { return Data[0x3]; } set { Data[0x3] = value; } }
|
||||
public int HeldItem
|
||||
{
|
||||
get
|
||||
@@ -29,20 +38,34 @@ public int HeldItem
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShinyLock { get { return (Data[0x6] & 2) >> 1 == 1; } set { Data[0x6] = (byte)(Data[0x6] & ~2 | (value ? 2 : 0)); } }
|
||||
public int Gender { get { return (Data[0x6] & 0xC) >> 2; } set { Data[0x6] = (byte)(Data[0x6] & ~0xC | ((value & 3) << 2)); } }
|
||||
public int Ability { get { return (Data[0x6] & 0x70) >> 4; } set { Data[0x6] = (byte)(Data[0x6] & ~0x70 | ((value & 7) << 4)); } }
|
||||
|
||||
public bool IV3 { get { return (Data[0x7] & 1) >> 0 == 1; } set { Data[0x7] = (byte)(Data[0x7] & ~1 | (value ? 1 : 0)); } }
|
||||
public bool IV3_1 { get { return (Data[0x7] & 2) >> 1 == 1; } set { Data[0x7] = (byte)(Data[0x7] & ~2 | (value ? 2 : 0)); } }
|
||||
|
||||
public EncounterStatic6(byte[] data)
|
||||
public bool ShinyLock
|
||||
{
|
||||
Data = (byte[])data.Clone();
|
||||
get => (Data[0x6] & 2) >> 1 == 1;
|
||||
set => Data[0x6] = (byte)(Data[0x6] & ~2 | (value ? 2 : 0));
|
||||
}
|
||||
public byte[] Write()
|
||||
public int Gender
|
||||
{
|
||||
return (byte[])Data.Clone();
|
||||
get => (Data[0x6] & 0xC) >> 2;
|
||||
set => Data[0x6] = (byte)(Data[0x6] & ~0xC | ((value & 3) << 2));
|
||||
}
|
||||
|
||||
public int Ability
|
||||
{
|
||||
get => (Data[0x6] & 0x70) >> 4;
|
||||
set => Data[0x6] = (byte)(Data[0x6] & ~0x70 | ((value & 7) << 4));
|
||||
}
|
||||
public bool IV3
|
||||
{
|
||||
get => (Data[0x7] & 1) >> 0 == 1;
|
||||
set => Data[0x7] = (byte)(Data[0x7] & ~1 | (value ? 1 : 0));
|
||||
}
|
||||
public bool IV3_1
|
||||
{
|
||||
get => (Data[0x7] & 2) >> 1 == 1;
|
||||
set => Data[0x7] = (byte)(Data[0x7] & ~2 | (value ? 2 : 0));
|
||||
}
|
||||
|
||||
public EncounterStatic6(byte[] data) => Data = (byte[])data.Clone();
|
||||
public byte[] Write() => (byte[])Data.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,14 @@ public int Gender
|
||||
set => Data[0x6] = (byte)(Data[0x6] & ~0xC | ((value & 3) << 2));
|
||||
}
|
||||
public int Ability
|
||||
{ get => (Data[0x6] & 0x70) >> 4;
|
||||
{
|
||||
get => (Data[0x6] & 0x70) >> 4;
|
||||
set => Data[0x6] = (byte)(Data[0x6] & ~0x70 | ((value & 7) << 4));
|
||||
}
|
||||
|
||||
public bool _7
|
||||
{ get => (Data[0x7] & 1) >> 0 == 1;
|
||||
{
|
||||
get => (Data[0x7] & 1) >> 0 == 1;
|
||||
set => Data[0x7] = (byte)(Data[0x7] & ~1 | (value ? 1 : 0));
|
||||
}
|
||||
public bool _7_1
|
||||
@@ -96,10 +98,7 @@ public int Nature
|
||||
|
||||
public int[] IVs
|
||||
{
|
||||
get => new int[]
|
||||
{
|
||||
(sbyte) Data[0x15], (sbyte) Data[0x16], (sbyte) Data[0x17], (sbyte) Data[0x18], (sbyte) Data[0x19], (sbyte) Data[0x1A]
|
||||
};
|
||||
get => new int[] { (sbyte) Data[0x15], (sbyte) Data[0x16], (sbyte) Data[0x17], (sbyte) Data[0x18], (sbyte) Data[0x19], (sbyte) Data[0x1A] };
|
||||
set
|
||||
{
|
||||
if (value.Length != 6)
|
||||
@@ -110,10 +109,7 @@ public int[] IVs
|
||||
}
|
||||
public int[] EVs
|
||||
{
|
||||
get => new int[]
|
||||
{
|
||||
(byte) Data[0x1B], (byte) Data[0x1C], (byte) Data[0x1D], (byte) Data[0x1E], (byte) Data[0x1F], (byte) Data[0x20]
|
||||
};
|
||||
get => new int[] { Data[0x1B], Data[0x1C], Data[0x1D], Data[0x1E], Data[0x1F], Data[0x20] };
|
||||
set
|
||||
{
|
||||
if (value.Length != 6)
|
||||
|
||||
@@ -33,11 +33,9 @@ public static string TrimFromZero(string input)
|
||||
}
|
||||
|
||||
// Randomization
|
||||
public static Random rand = new Random();
|
||||
public static uint rnd32()
|
||||
{
|
||||
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
|
||||
}
|
||||
public static Random rand { get; private set; } = new Random();
|
||||
public static void ReseedRand(int seed) => rand = new Random(seed);
|
||||
public static uint rnd32() => (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
|
||||
|
||||
// Data Retrieval
|
||||
public static int ToInt32(string value)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace pk3DS.ARCUtil
|
||||
{
|
||||
public class ARC
|
||||
public static class ARC
|
||||
{
|
||||
// Multi Type Archive Handling
|
||||
internal static bool onefile = true;
|
||||
|
||||
@@ -174,7 +174,7 @@ private void B_RandAll_Click(object sender, EventArgs e)
|
||||
}
|
||||
|
||||
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Moves? Cannot undo.", "Double check options on the right before continuing.") != DialogResult.Yes) return;
|
||||
Random rnd = new Random();
|
||||
Random rnd = Util.rand;
|
||||
for (int i = 0; i < CB_Move.Items.Count; i++)
|
||||
{
|
||||
CB_Move.SelectedIndex = i; // Get new Move
|
||||
|
||||
@@ -131,11 +131,7 @@ public RSTE(byte[][] trc, byte[][] trd, byte[][] trp)
|
||||
Setup();
|
||||
}
|
||||
private string[][] AltForms;
|
||||
internal static readonly Random rand = new Random();
|
||||
internal static uint rnd32()
|
||||
{
|
||||
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
|
||||
}
|
||||
internal static uint rnd32() => Util.rnd32();
|
||||
private bool start = true;
|
||||
private bool loading = true;
|
||||
private int index = -1;
|
||||
|
||||
@@ -304,11 +304,7 @@ private void RSWE_Load()
|
||||
//Preload Tabs
|
||||
PreloadTabs();
|
||||
}
|
||||
internal static Random rand = new Random();
|
||||
internal static uint rnd32()
|
||||
{
|
||||
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
|
||||
}
|
||||
internal static uint rnd32() => Util.rnd32();
|
||||
|
||||
private void openQuick(string[] encdata)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ private void loadData()
|
||||
for (int i = 0; i < EncounterData.Length; i++)
|
||||
{
|
||||
EncounterData[i] = new EncounterStatic6(FieldData.Skip(fieldOffset + i * fieldSize).Take(fieldSize).ToArray());
|
||||
LB_Encounters.Items.Add($"{i.ToString("00")} - {specieslist[EncounterData[i].Species]}");
|
||||
LB_Encounters.Items.Add($"{i:00} - {specieslist[EncounterData[i].Species]}");
|
||||
}
|
||||
loaded = true;
|
||||
LB_Encounters.SelectedIndex = 0;
|
||||
|
||||
@@ -495,11 +495,8 @@ private void PreloadTabs(object sender, EventArgs e)
|
||||
}
|
||||
TabControl_EncounterData.TabPages[0].Show();
|
||||
}
|
||||
internal static Random rand = new Random();
|
||||
internal static uint rnd32()
|
||||
{
|
||||
return (uint)rand.Next(1 << 30) << 2 | (uint)rand.Next(1 << 2);
|
||||
}
|
||||
|
||||
internal static uint rnd32() => Util.rnd32();
|
||||
|
||||
private void B_Randomize_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -175,7 +175,7 @@ private void B_RandAll_Click(object sender, EventArgs e)
|
||||
}
|
||||
|
||||
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Randomize Moves? Cannot undo.", "Double check options on the right before continuing.") != DialogResult.Yes) return;
|
||||
Random rnd = new Random();
|
||||
Random rnd = Util.rand;
|
||||
for (int i = 0; i < CB_Move.Items.Count; i++)
|
||||
{
|
||||
CB_Move.SelectedIndex = i; // Get new Move
|
||||
|
||||
@@ -176,7 +176,7 @@ private void saveData()
|
||||
|
||||
private string getEntryText(int species, int entry)
|
||||
{
|
||||
return $"{entry.ToString("00")} - {specieslist[species]}";
|
||||
return $"{entry:00} - {specieslist[species]}";
|
||||
}
|
||||
private string getEntryText(EncounterStatic enc, int entry)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user