mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-02 05:46:47 -05:00
Add TM Randomizer
This commit is contained in:
13
pk3DS/Subforms/TMHM.Designer.cs
generated
13
pk3DS/Subforms/TMHM.Designer.cs
generated
@@ -32,6 +32,7 @@ private void InitializeComponent()
|
||||
this.L_TM = new System.Windows.Forms.Label();
|
||||
this.dgvHM = new System.Windows.Forms.DataGridView();
|
||||
this.L_HM = new System.Windows.Forms.Label();
|
||||
this.B_RTM = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvTM)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgvHM)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@@ -82,11 +83,22 @@ private void InitializeComponent()
|
||||
this.L_HM.TabIndex = 4;
|
||||
this.L_HM.Text = "HM:";
|
||||
//
|
||||
// B_RTM
|
||||
//
|
||||
this.B_RTM.Location = new System.Drawing.Point(41, 1);
|
||||
this.B_RTM.Name = "B_RTM";
|
||||
this.B_RTM.Size = new System.Drawing.Size(75, 23);
|
||||
this.B_RTM.TabIndex = 5;
|
||||
this.B_RTM.Text = "Randomize";
|
||||
this.B_RTM.UseVisualStyleBackColor = true;
|
||||
this.B_RTM.Click += new System.EventHandler(this.B_RandomTM_Click);
|
||||
//
|
||||
// TMHM
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(504, 332);
|
||||
this.Controls.Add(this.B_RTM);
|
||||
this.Controls.Add(this.L_HM);
|
||||
this.Controls.Add(this.dgvHM);
|
||||
this.Controls.Add(this.L_TM);
|
||||
@@ -111,5 +123,6 @@ private void InitializeComponent()
|
||||
private System.Windows.Forms.Label L_TM;
|
||||
private System.Windows.Forms.DataGridView dgvHM;
|
||||
private System.Windows.Forms.Label L_HM;
|
||||
private System.Windows.Forms.Button B_RTM;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
|
||||
namespace pk3DS
|
||||
{
|
||||
@@ -39,6 +40,7 @@ private void setupDGV()
|
||||
dgvIndex.Width = 45;
|
||||
dgvIndex.ReadOnly = true;
|
||||
dgvIndex.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
dgvIndex.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
}
|
||||
DataGridViewComboBoxColumn dgvMove = new DataGridViewComboBoxColumn();
|
||||
{
|
||||
@@ -49,6 +51,7 @@ private void setupDGV()
|
||||
|
||||
dgvMove.Width = 133;
|
||||
dgvMove.FlatStyle = FlatStyle.Flat;
|
||||
dgvIndex.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
}
|
||||
dgvTM.Columns.Add(dgvIndex);
|
||||
dgvTM.Columns.Add(dgvMove);
|
||||
@@ -126,5 +129,23 @@ private void formClosing(object sender, FormClosingEventArgs e)
|
||||
setList();
|
||||
File.WriteAllBytes(codebin, data);
|
||||
}
|
||||
|
||||
private void B_RandomTM_Click(object sender, EventArgs e)
|
||||
{
|
||||
int[] randomMoves = Enumerable.Range(1, movelist.Length - 1).Select(i => (int)i).ToArray();
|
||||
Util.Shuffle(randomMoves);
|
||||
|
||||
int[] banned = { 15, 19, 57, 70, 127, 249, 291, 148 };
|
||||
int ctr = 0;
|
||||
|
||||
for (int i = 0; i < dgvTM.Rows.Count; i++)
|
||||
{
|
||||
int val = Array.IndexOf(movelist, dgvTM.Rows[i].Cells[1].Value);
|
||||
if (banned.Contains(val)) continue;
|
||||
while (banned.Contains(randomMoves[ctr])) ctr++;
|
||||
|
||||
dgvTM.Rows[i].Cells[1].Value = movelist[randomMoves[ctr++]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user