Convert level % mult to decimal mult

Closes #155
This commit is contained in:
Kurt 2017-06-14 18:08:55 -07:00
parent 75297acc3b
commit 9da0444527
7 changed files with 72 additions and 49 deletions

View File

@ -533,7 +533,7 @@ private void Setup()
private readonly List<string> Tags = new List<string>();
private readonly Dictionary<string, int> TagTypes = new Dictionary<string, int>();
public static int[] sL; // Random Species List
public static decimal rGiftPercent, rLevelPercent;
public static decimal rGiftPercent, rLevelMultiplier;
private void B_Randomize_Click(object sender, EventArgs e)
{
rPKM = rMove = rAbility = rDiffAI = rDiffIV = rClass = rGift = rItem = rDoRand = false; // init to false
@ -714,7 +714,7 @@ private void Randomize()
trpk_form[p].SelectedIndex = (int)(rnd32() % trpk_form[p].Items.Count);
}
if (rLevel)
trpk_lvl[p].SelectedIndex = Math.Max(1, Math.Min((int)(trpk_lvl[p].SelectedIndex * (100 + rLevelPercent) / 100), 100));
trpk_lvl[p].SelectedIndex = Randomizer.getModifiedLevel(trpk_lvl[p].SelectedIndex, rLevelMultiplier);
if (rAbility)
trpk_abil[p].SelectedIndex = (int)(1 + rnd32() % 3);
if (rDiffIV)

View File

@ -1002,29 +1002,40 @@ private void InitializeComponent()
//
// NUD_LevelAmp
//
this.NUD_LevelAmp.DecimalPlaces = 2;
this.NUD_LevelAmp.Increment = new decimal(new int[] {
2,
0,
0,
65536});
this.NUD_LevelAmp.Location = new System.Drawing.Point(152, 16);
this.NUD_LevelAmp.Maximum = new decimal(new int[] {
3,
0,
0,
0});
this.NUD_LevelAmp.Minimum = new decimal(new int[] {
75,
1,
0,
0,
-2147483648});
65536});
this.NUD_LevelAmp.Name = "NUD_LevelAmp";
this.NUD_LevelAmp.Size = new System.Drawing.Size(41, 20);
this.NUD_LevelAmp.TabIndex = 276;
this.NUD_LevelAmp.Value = new decimal(new int[] {
50,
13,
0,
0,
0});
65536});
//
// CHK_Level
//
this.CHK_Level.AutoSize = true;
this.CHK_Level.Location = new System.Drawing.Point(33, 17);
this.CHK_Level.Name = "CHK_Level";
this.CHK_Level.Size = new System.Drawing.Size(122, 17);
this.CHK_Level.Size = new System.Drawing.Size(109, 17);
this.CHK_Level.TabIndex = 279;
this.CHK_Level.Text = "Modify All Levels (%)";
this.CHK_Level.Text = "Multiply All Levels";
this.CHK_Level.UseVisualStyleBackColor = true;
//
// L_HordeC_Max

View File

@ -591,7 +591,7 @@ private void B_Randomize_Click(object sender, EventArgs e)
Enabled = false;
// Calculate % diff we will apply to each level
decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100;
decimal leveldiff = NUD_LevelAmp.Value;
// Nonrepeating List Start
int[] sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked,
@ -775,7 +775,7 @@ private void modifyLevels(object sender, EventArgs e)
Enabled = false;
// Calculate % diff we will apply to each level
decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100;
decimal leveldiff = NUD_LevelAmp.Value;
// Cycle through each location to modify levels
for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location
@ -785,7 +785,8 @@ private void modifyLevels(object sender, EventArgs e)
// Amp Levels
for (int l = 0; l < max.Length; l++)
min[l].Value = max[l].Value = max[l].Value <= 1 ? max[l].Value : Math.Max(1, Math.Min(100, (int)(leveldiff * max[l].Value)));
if (min[l].Value > 1)
min[l].Value = max[l].Value = Randomizer.getModifiedLevel((int)max[l].Value, leveldiff);
// Save Changes
B_Save_Click(sender, e);

View File

@ -39,7 +39,6 @@ private void InitializeComponent()
this.B_Cancel = new System.Windows.Forms.Button();
this.NUD_GiftPercent = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.NUD_Level = new System.Windows.Forms.NumericUpDown();
this.CHK_Level = new System.Windows.Forms.CheckBox();
this.GB_Tweak = new System.Windows.Forms.GroupBox();
@ -212,31 +211,33 @@ private void InitializeComponent()
this.label1.TabIndex = 12;
this.label1.Text = "%";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(183, 15);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(15, 13);
this.label2.TabIndex = 4;
this.label2.Text = "%";
//
// NUD_Level
//
this.NUD_Level.DecimalPlaces = 2;
this.NUD_Level.Increment = new decimal(new int[] {
2,
0,
0,
65536});
this.NUD_Level.Location = new System.Drawing.Point(139, 11);
this.NUD_Level.Maximum = new decimal(new int[] {
3,
0,
0,
0});
this.NUD_Level.Minimum = new decimal(new int[] {
75,
1,
0,
0,
-2147483648});
65536});
this.NUD_Level.Name = "NUD_Level";
this.NUD_Level.Size = new System.Drawing.Size(43, 20);
this.NUD_Level.TabIndex = 3;
this.NUD_Level.Value = new decimal(new int[] {
50,
13,
0,
0,
0});
65536});
this.NUD_Level.ValueChanged += new System.EventHandler(this.changeLevelPercent);
//
// CHK_Level
@ -581,7 +582,6 @@ private void InitializeComponent()
this.Controls.Add(this.CHK_MaxDiffPKM);
this.Controls.Add(this.CHK_RandomAbilities);
this.Controls.Add(this.CHK_RandomItems);
this.Controls.Add(this.label2);
this.Controls.Add(this.NUD_Level);
this.Controls.Add(this.CHK_Level);
this.Controls.Add(this.label1);
@ -626,7 +626,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.NumericUpDown NUD_GiftPercent;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown NUD_Level;
private System.Windows.Forms.CheckBox CHK_Level;
private System.Windows.Forms.GroupBox GB_Tweak;

View File

@ -32,7 +32,7 @@ private void B_Save_Click(object sender, EventArgs e)
RSTE.sL = Randomizer.getSpeciesList(CHK_G1.Checked, CHK_G2.Checked, CHK_G3.Checked, CHK_G4.Checked, CHK_G5.Checked, CHK_G6.Checked, false, CHK_L.Checked, CHK_E.Checked, ModifierKeys == Keys.Control);
RSTE.rSmart = CHK_BST.Checked;
RSTE.rLevel = CHK_Level.Checked;
RSTE.rLevelPercent = NUD_Level.Value;
RSTE.rLevelMultiplier = NUD_Level.Value;
RSTE.rMove = CB_Moves.SelectedIndex == 1;
RSTE.rNoMove = CB_Moves.SelectedIndex == 2;
@ -101,7 +101,7 @@ private void CHK_RandomPKM_CheckedChanged(object sender, EventArgs e)
private void CHK_Level_CheckedChanged(object sender, EventArgs e)
{
NUD_Level.Enabled = CHK_Level.Checked;
NUD_Level.Value = Convert.ToDecimal(CHK_Level.Checked) * 50;
NUD_Level.Value = CHK_Level.Checked ? 1.3m : 1m;
}
private void changeLevelPercent(object sender, EventArgs e)
{

View File

@ -276,6 +276,7 @@ private void InitializeComponent()
this.label25 = new System.Windows.Forms.Label();
this.TabPage_Horde = new System.Windows.Forms.TabPage();
this.GB_Tweak = new System.Windows.Forms.GroupBox();
this.CHK_MegaForm = new System.Windows.Forms.CheckBox();
this.L_RandOpt = new System.Windows.Forms.Label();
this.CHK_BST = new System.Windows.Forms.CheckBox();
this.CHK_E = new System.Windows.Forms.CheckBox();
@ -561,7 +562,6 @@ private void InitializeComponent()
this.CB_FormeList = new System.Windows.Forms.ComboBox();
this.B_Randomize = new System.Windows.Forms.Button();
this.B_Dump = new System.Windows.Forms.Button();
this.CHK_MegaForm = new System.Windows.Forms.CheckBox();
this.TabControl_EncounterData.SuspendLayout();
this.TabPage_Land.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUP_RockSmashMax5)).BeginInit();
@ -15527,6 +15527,16 @@ private void InitializeComponent()
this.GB_Tweak.TabStop = false;
this.GB_Tweak.Text = "Extra Tweaks";
//
// CHK_MegaForm
//
this.CHK_MegaForm.AutoSize = true;
this.CHK_MegaForm.Location = new System.Drawing.Point(152, 97);
this.CHK_MegaForm.Name = "CHK_MegaForm";
this.CHK_MegaForm.Size = new System.Drawing.Size(127, 17);
this.CHK_MegaForm.TabIndex = 296;
this.CHK_MegaForm.Text = "Random Mega Forms";
this.CHK_MegaForm.UseVisualStyleBackColor = true;
//
// L_RandOpt
//
this.L_RandOpt.AutoSize = true;
@ -15654,29 +15664,40 @@ private void InitializeComponent()
//
// NUD_LevelAmp
//
this.NUD_LevelAmp.DecimalPlaces = 2;
this.NUD_LevelAmp.Increment = new decimal(new int[] {
2,
0,
0,
65536});
this.NUD_LevelAmp.Location = new System.Drawing.Point(152, 16);
this.NUD_LevelAmp.Maximum = new decimal(new int[] {
3,
0,
0,
0});
this.NUD_LevelAmp.Minimum = new decimal(new int[] {
75,
1,
0,
0,
-2147483648});
65536});
this.NUD_LevelAmp.Name = "NUD_LevelAmp";
this.NUD_LevelAmp.Size = new System.Drawing.Size(41, 20);
this.NUD_LevelAmp.TabIndex = 276;
this.NUD_LevelAmp.Value = new decimal(new int[] {
50,
13,
0,
0,
0});
65536});
//
// CHK_Level
//
this.CHK_Level.AutoSize = true;
this.CHK_Level.Location = new System.Drawing.Point(33, 17);
this.CHK_Level.Name = "CHK_Level";
this.CHK_Level.Size = new System.Drawing.Size(122, 17);
this.CHK_Level.Size = new System.Drawing.Size(109, 17);
this.CHK_Level.TabIndex = 279;
this.CHK_Level.Text = "Modify All Levels (%)";
this.CHK_Level.Text = "Multiply All Levels";
this.CHK_Level.UseVisualStyleBackColor = true;
//
// label129
@ -27895,21 +27916,11 @@ private void InitializeComponent()
this.B_Dump.UseVisualStyleBackColor = true;
this.B_Dump.Click += new System.EventHandler(this.B_Dump_Click);
//
// CHK_MegaForm
//
this.CHK_MegaForm.AutoSize = true;
this.CHK_MegaForm.Location = new System.Drawing.Point(152, 97);
this.CHK_MegaForm.Name = "CHK_MegaForm";
this.CHK_MegaForm.Size = new System.Drawing.Size(127, 17);
this.CHK_MegaForm.TabIndex = 296;
this.CHK_MegaForm.Text = "Random Mega Forms";
this.CHK_MegaForm.UseVisualStyleBackColor = true;
//
// XYWE
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(948, 416);
this.ClientSize = new System.Drawing.Size(948, 415);
this.Controls.Add(this.B_Dump);
this.Controls.Add(this.B_Randomize);
this.Controls.Add(this.label136);

View File

@ -633,7 +633,7 @@ private void modifyLevels(object sender, EventArgs e)
Enabled = false;
// Calculate % diff we will apply to each level
decimal leveldiff = (100 + NUD_LevelAmp.Value) / 100;
decimal leveldiff = NUD_LevelAmp.Value;
// Cycle through each location to modify levels
for (int i = 0; i < CB_LocationID.Items.Count; i++) // for every location
@ -643,7 +643,8 @@ private void modifyLevels(object sender, EventArgs e)
// Amp Levels
for (int l = 0; l < max.Length; l++)
min[l].Value = max[l].Value = max[l].Value <= 1 ? max[l].Value : Math.Max(1, Math.Min(100, (int)(leveldiff * max[l].Value)));
if (min[l].Value > 1)
min[l].Value = max[l].Value = Randomizer.getModifiedLevel((int)max[l].Value, leveldiff);
// Save Changes
B_Save_Click(sender, e);