Add Difficulty Value Calculator

This commit is contained in:
Yako 2024-03-27 23:12:48 +01:00
parent e4552f0dd5
commit 7f79ab80c8
11 changed files with 3274 additions and 1524 deletions

View File

@ -95,6 +95,15 @@
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<Compile Include="DVCalculator\DVCalc.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DVCalculator\DVCalc.Designer.cs" />
<Compile Include="DVCalculator\DVCalcNatureViewerForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DVCalculator\DVCalcNatureViewerForm.Designer.cs" />
<Compile Include="DVCalculator\DVCalculator.cs" />
<Compile Include="EditorPanels.cs" />
<Compile Include="Editors\EncountersEditor.cs">
<SubType>UserControl</SubType>
@ -347,6 +356,8 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources\writeText.Designer.cs" />
<EmbeddedResource Include="DVCalculator\DVCalc.resx" />
<EmbeddedResource Include="DVCalculator\DVCalcNatureViewerForm.resx" />
<EmbeddedResource Include="Editors\EncountersEditor.resx">
<DependentUpon>EncountersEditor.cs</DependentUpon>
</EmbeddedResource>

52
DS_Map/DVCalculator/DVCalc.Designer.cs generated Normal file
View File

@ -0,0 +1,52 @@
using System.Windows.Forms;
namespace DSPRE
{
partial class DVCalc
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
#endregion
private Label poke_label;
private Label trainerClassIdx_label;
private Label trainerIdx_label;
private Label pokeLVL_label;
private NumericUpDown pokeLevel;
private NumericUpDown trainerClassIdx;
private NumericUpDown trainerIdx;
private ComboBox natureSelect;
private Label nature_label;
private Label DV_label;
private Button calcButton;
private CheckBox maleCheck;
private Label maxDVNature_label;
private Label IV_label;
private ComboBox pokemonSelector;
private Button showAllButton;
private Button helpButton;
}
}

View File

@ -0,0 +1,372 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Linq;
namespace DSPRE
{
public partial class DVCalc : Form
{
public DVCalc(int TrainerIndex, int TrainerClassIndex)
{
InitializeComponent();
PopulateComboBox();
SetTrainerData(TrainerIndex, TrainerClassIndex);
//make Pokemon searchable
pokemonSelector.TextChanged += PokemonSelector_TextChanged;
pokemonSelector.AutoCompleteMode = AutoCompleteMode.Suggest;
pokemonSelector.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection autoCompleteSource = new AutoCompleteStringCollection();
foreach (KeyValuePair<int, string> item in pokemonSelector.Items)
{
autoCompleteSource.Add(item.Value);
}
pokemonSelector.AutoCompleteCustomSource = autoCompleteSource;
}
private void MainForm_Load(object sender, EventArgs e)
{
}
private void InitializeComponent()
{
this.poke_label = new System.Windows.Forms.Label();
this.trainerClassIdx_label = new System.Windows.Forms.Label();
this.trainerIdx_label = new System.Windows.Forms.Label();
this.pokeLVL_label = new System.Windows.Forms.Label();
this.pokeLevel = new System.Windows.Forms.NumericUpDown();
this.trainerClassIdx = new System.Windows.Forms.NumericUpDown();
this.trainerIdx = new System.Windows.Forms.NumericUpDown();
this.natureSelect = new System.Windows.Forms.ComboBox();
this.nature_label = new System.Windows.Forms.Label();
this.DV_label = new System.Windows.Forms.Label();
this.calcButton = new System.Windows.Forms.Button();
this.maleCheck = new System.Windows.Forms.CheckBox();
this.maxDVNature_label = new System.Windows.Forms.Label();
this.IV_label = new System.Windows.Forms.Label();
this.pokemonSelector = new System.Windows.Forms.ComboBox();
this.showAllButton = new System.Windows.Forms.Button();
this.helpButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pokeLevel)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trainerClassIdx)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trainerIdx)).BeginInit();
this.SuspendLayout();
//
// poke_label
//
this.poke_label.AutoSize = true;
this.poke_label.Location = new System.Drawing.Point(28, 154);
this.poke_label.Name = "poke_label";
this.poke_label.Size = new System.Drawing.Size(65, 16);
this.poke_label.TabIndex = 3;
this.poke_label.Text = "Pokémon";
//
// trainerClassIdx_label
//
this.trainerClassIdx_label.AutoSize = true;
this.trainerClassIdx_label.Location = new System.Drawing.Point(28, 87);
this.trainerClassIdx_label.Name = "trainerClassIdx_label";
this.trainerClassIdx_label.Size = new System.Drawing.Size(122, 16);
this.trainerClassIdx_label.TabIndex = 4;
this.trainerClassIdx_label.Text = "Trainer Class Index";
//
// trainerIdx_label
//
this.trainerIdx_label.AutoSize = true;
this.trainerIdx_label.Location = new System.Drawing.Point(28, 21);
this.trainerIdx_label.Name = "trainerIdx_label";
this.trainerIdx_label.Size = new System.Drawing.Size(85, 16);
this.trainerIdx_label.TabIndex = 5;
this.trainerIdx_label.Text = "Trainer Index";
//
// pokeLVL_label
//
this.pokeLVL_label.AutoSize = true;
this.pokeLVL_label.Location = new System.Drawing.Point(278, 179);
this.pokeLVL_label.Name = "pokeLVL_label";
this.pokeLVL_label.Size = new System.Drawing.Size(33, 16);
this.pokeLVL_label.TabIndex = 6;
this.pokeLVL_label.Text = "LVL.";
//
// pokeLevel
//
this.pokeLevel.Location = new System.Drawing.Point(318, 177);
this.pokeLevel.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.pokeLevel.Name = "pokeLevel";
this.pokeLevel.Size = new System.Drawing.Size(46, 22);
this.pokeLevel.TabIndex = 7;
this.pokeLevel.Value = new decimal(new int[] {
50,
0,
0,
0});
//
// trainerClassIdx
//
this.trainerClassIdx.Location = new System.Drawing.Point(28, 110);
this.trainerClassIdx.Maximum = new decimal(new int[] {
120,
0,
0,
0});
this.trainerClassIdx.Name = "trainerClassIdx";
this.trainerClassIdx.Size = new System.Drawing.Size(125, 22);
this.trainerClassIdx.TabIndex = 9;
//
// trainerIdx
//
this.trainerIdx.Location = new System.Drawing.Point(28, 44);
this.trainerIdx.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.trainerIdx.Name = "trainerIdx";
this.trainerIdx.Size = new System.Drawing.Size(125, 22);
this.trainerIdx.TabIndex = 10;
//
// natureSelect
//
this.natureSelect.FormattingEnabled = true;
this.natureSelect.Location = new System.Drawing.Point(192, 44);
this.natureSelect.Name = "natureSelect";
this.natureSelect.Size = new System.Drawing.Size(207, 24);
this.natureSelect.TabIndex = 11;
//
// nature_label
//
this.nature_label.AutoSize = true;
this.nature_label.Location = new System.Drawing.Point(192, 21);
this.nature_label.Name = "nature_label";
this.nature_label.Size = new System.Drawing.Size(47, 16);
this.nature_label.TabIndex = 12;
this.nature_label.Text = "Nature";
//
// DV_label
//
this.DV_label.AutoSize = true;
this.DV_label.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.DV_label.Location = new System.Drawing.Point(443, 44);
this.DV_label.Name = "DV_label";
this.DV_label.Size = new System.Drawing.Size(162, 25);
this.DV_label.TabIndex = 13;
this.DV_label.Text = "Difficulty Value: 0";
//
// calcButton
//
this.calcButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.calcButton.Location = new System.Drawing.Point(491, 179);
this.calcButton.Name = "calcButton";
this.calcButton.Size = new System.Drawing.Size(114, 51);
this.calcButton.TabIndex = 14;
this.calcButton.Text = "Calculate";
this.calcButton.UseVisualStyleBackColor = true;
this.calcButton.Click += new System.EventHandler(this.CalcButton_Click);
//
// maleCheck
//
this.maleCheck.AutoSize = true;
this.maleCheck.Checked = true;
this.maleCheck.CheckState = System.Windows.Forms.CheckState.Checked;
this.maleCheck.Location = new System.Drawing.Point(192, 111);
this.maleCheck.Name = "maleCheck";
this.maleCheck.Size = new System.Drawing.Size(112, 20);
this.maleCheck.TabIndex = 15;
this.maleCheck.Text = "Trainer Male?";
this.maleCheck.UseVisualStyleBackColor = true;
//
// maxDVNature_label
//
this.maxDVNature_label.AutoSize = true;
this.maxDVNature_label.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.maxDVNature_label.Location = new System.Drawing.Point(323, 127);
this.maxDVNature_label.Name = "maxDVNature_label";
this.maxDVNature_label.Size = new System.Drawing.Size(125, 20);
this.maxDVNature_label.TabIndex = 16;
this.maxDVNature_label.Text = "DV 255 Nature:";
//
// IV_label
//
this.IV_label.AutoSize = true;
this.IV_label.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.IV_label.Location = new System.Drawing.Point(323, 87);
this.IV_label.Name = "IV_label";
this.IV_label.Size = new System.Drawing.Size(113, 20);
this.IV_label.TabIndex = 17;
this.IV_label.Text = "Resulting IVs:";
//
// pokemonSelector
//
this.pokemonSelector.FormattingEnabled = true;
this.pokemonSelector.Location = new System.Drawing.Point(28, 176);
this.pokemonSelector.Name = "pokemonSelector";
this.pokemonSelector.Size = new System.Drawing.Size(244, 24);
this.pokemonSelector.TabIndex = 18;
//
// showAllButton
//
this.showAllButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.showAllButton.Location = new System.Drawing.Point(391, 192);
this.showAllButton.Name = "showAllButton";
this.showAllButton.Size = new System.Drawing.Size(94, 29);
this.showAllButton.TabIndex = 19;
this.showAllButton.Text = "Show All";
this.showAllButton.UseVisualStyleBackColor = true;
this.showAllButton.Click += new System.EventHandler(this.ShowAllButton_Click);
//
// helpButton
//
this.helpButton.Location = new System.Drawing.Point(541, 2);
this.helpButton.Name = "helpButton";
this.helpButton.Size = new System.Drawing.Size(75, 23);
this.helpButton.TabIndex = 20;
this.helpButton.Text = "Help";
this.helpButton.UseVisualStyleBackColor = true;
this.helpButton.Click += new System.EventHandler(this.buttonHelp_Click);
//
// DVCalc
//
this.ClientSize = new System.Drawing.Size(628, 242);
this.Controls.Add(this.helpButton);
this.Controls.Add(this.showAllButton);
this.Controls.Add(this.pokemonSelector);
this.Controls.Add(this.IV_label);
this.Controls.Add(this.maxDVNature_label);
this.Controls.Add(this.maleCheck);
this.Controls.Add(this.calcButton);
this.Controls.Add(this.DV_label);
this.Controls.Add(this.nature_label);
this.Controls.Add(this.natureSelect);
this.Controls.Add(this.trainerIdx);
this.Controls.Add(this.trainerClassIdx);
this.Controls.Add(this.pokeLevel);
this.Controls.Add(this.pokeLVL_label);
this.Controls.Add(this.trainerIdx_label);
this.Controls.Add(this.trainerClassIdx_label);
this.Controls.Add(this.poke_label);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Name = "DVCalc";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "DVCalc";
((System.ComponentModel.ISupportInitialize)(this.pokeLevel)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trainerClassIdx)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trainerIdx)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private void PopulateComboBox()
{
// Populate Nature ComboBox (static readonly List)
natureSelect.DataSource = DVCalculator.Natures;
// Fill the pokemon selector combo box with pokemon names from the ROM
string[] pokeNames = RomInfo.GetPokemonNames();
pokemonSelector.Items.Clear();
for (int id = 0; id < pokeNames.Length; id++)
{
pokemonSelector.Items.Add(new KeyValuePair<int, string>(id, pokeNames[id]));
}
pokemonSelector.SelectedIndex = 0;
}
private void SetTrainerData(int TrainerIndex, int TrainerClassIndex)
{
trainerIdx.Value = TrainerIndex;
trainerClassIdx.Value = TrainerClassIndex;
}
private void CalcButton_Click(object sender, EventArgs e)
{
// Natures are sorted by their index so this works
uint nature = (uint)natureSelect.SelectedIndex;
int pokemonIndex = 1;
if (pokemonSelector.SelectedItem != null)
{
KeyValuePair<int, string> selectedPokemon = (KeyValuePair<int, string>)pokemonSelector.SelectedItem;
pokemonIndex = (int)selectedPokemon.Key;
}
int DV = DVCalculator.findHighestDV((int)trainerIdx.Value, (int)trainerClassIdx.Value, maleCheck.Checked, pokemonIndex, (int)pokeLevel.Value, nature);
// Determine nature for max DV (max IV) for convenience
uint maxDVNature = DVCalculator.getNatureFromPID(DVCalculator.generatePID((int)trainerIdx.Value, (int)trainerClassIdx.Value, maleCheck.Checked, pokemonIndex, (int)pokeLevel.Value, 255));
// Display results
DV_label.Text = "Difficulty Value: " + DV;
IV_label.Text = "Resulting IVs: " + (DV * 31 / 255);
maxDVNature_label.Text = "DV 255 Nature: " + DVCalculator.Natures[(int)maxDVNature];
}
private void ShowAllButton_Click(object sender, EventArgs e)
{
int pokemonIndex = 1;
if (pokemonSelector.SelectedItem != null)
{
KeyValuePair<int, string> selectedPokemon = (KeyValuePair<int, string>)pokemonSelector.SelectedItem;
pokemonIndex = (int)selectedPokemon.Key;
}
// Create a list of DV-IV-Nature Triplets
List<DVIVNatureTriplet> natureDict = DVCalculator.getAllNatures((int)trainerIdx.Value, (int)trainerClassIdx.Value, maleCheck.Checked, pokemonIndex, (int)pokeLevel.Value);
// Create an instance of the view form and pass the data
// There might be a better way to do this?
DVCalcNatureViewerForm natureViewer = new DVCalcNatureViewerForm(natureDict);
natureViewer.ShowDialog();
}
private void PokemonSelector_TextChanged(object sender, EventArgs e)
{
if (sender == null || !(sender is ComboBox)) { return; }
ComboBox comboBox = (ComboBox)sender;
string enteredText = comboBox.Text.ToLower();
// If name of pokemon is typed select that item
foreach (KeyValuePair<int, string> item in comboBox.Items)
{
if (item.Value.ToLower().Equals(enteredText))
{
comboBox.SelectedItem = item;
return;
}
}
}
private void buttonHelp_Click(object sender, EventArgs e)
{
MessageBox.Show("DV, or \"Difficulty Value\", is used by the game engine to calculate how tough an opponent Pokemon should be.\n" +
"The DV affects a Pokemon's Nature and IVs - the higher the value, the stronger the Pokemon.\n" +
"DVs will go from 0 (0 IVs) to 255 (31 IVs). Natures are chosen semi-randomly." +
"\nIVs will be the same value for all Stats at any DV, so Hidden Power will only be Fighting or Dark Type." +
"\nThis calculator allows you to choose a desired Nature and then find the highest possible DV that will yield that Nature." +
"\nIf you want a specific combination of IVs and Nature instead, please click the \"Show All\" button and find the one you want."
, "Difficulty Value", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,78 @@
using System.Drawing;
using System.Windows.Forms;
namespace DSPRE
{
partial class DVCalcNatureViewerForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.natureGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.natureGridView)).BeginInit();
this.SuspendLayout();
//
// natureGridView
//
this.natureGridView.AllowUserToAddRows = false;
this.natureGridView.AllowUserToDeleteRows = false;
this.natureGridView.AllowUserToOrderColumns = true;
this.natureGridView.AllowUserToResizeRows = false;
this.natureGridView.BackgroundColor = System.Drawing.SystemColors.Menu;
this.natureGridView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.natureGridView.ColumnHeadersHeight = 29;
this.natureGridView.Location = new System.Drawing.Point(16, 10);
this.natureGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.natureGridView.Name = "natureGridView";
this.natureGridView.ReadOnly = true;
this.natureGridView.RowHeadersWidth = 51;
this.natureGridView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.natureGridView.Size = new System.Drawing.Size(387, 333);
this.natureGridView.TabIndex = 0;
//
// DVCalcNatureViewerForm
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(415, 352);
this.Controls.Add(this.natureGridView);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.MaximizeBox = false;
this.Name = "DVCalcNatureViewerForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Full List";
((System.ComponentModel.ISupportInitialize)(this.natureGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView natureGridView;
}
}

View File

@ -0,0 +1,40 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
namespace DSPRE
{
public partial class DVCalcNatureViewerForm : Form
{
private List<DVIVNatureTriplet> data;
public DVCalcNatureViewerForm(List<DVIVNatureTriplet> data)
{
InitializeComponent();
this.data = data;
PopulateDataGridView();
}
private void PopulateDataGridView()
{
// Create a BindingList to bind to the DataGridView
var bindingList = new BindingList<DVIVNatureTriplet>(data.ToList());
// Set the DataSource of the DataGridView
natureGridView.DataSource = bindingList;
// Set the columns
natureGridView.Columns[0].HeaderText = "IV";
natureGridView.Columns[0].DataPropertyName = "IV";
natureGridView.Columns[1].HeaderText = "Nature";
natureGridView.Columns[1].DataPropertyName = "Nature";
natureGridView.Columns[2].HeaderText = "DV";
natureGridView.Columns[2].DataPropertyName = "DV";
// Adjust column widths
natureGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,143 @@
using System.Collections.Generic;
namespace DSPRE
{
// Putting this class here is bad practice, however it's just a really small utility class
public class DVIVNatureTriplet
{
public int DV { get; set; }
public int IV { get; set; }
public string Nature { get; set; }
public DVIVNatureTriplet(int DV, int IV, string Nature)
{
this.DV = DV;
this.IV = IV;
this.Nature = Nature;
}
}
internal static class DVCalculator
{
private static long seed;
public static void setSeed(long seed)
{
DVCalculator.seed = seed;
}
public static long getSeed()
{
return DVCalculator.seed;
}
// This function is lifted from turtleisaac's Pokeditor (with permission)
// See https://github.com/turtleisaac/PokEditor-v2/blob/72ca6ab641f616b8be9a87624b81896baa45f947/src/com/turtleisaac/pokeditor/utilities/TrainerPersonalityCalculator.java
public static long getNextRandom()
{
long random = 0x41c64e6d * seed + 0x6073;
//last 32 bits is new seed
seed = random & 0xFFFFFFFFL;
return random;
}
public static int findHighestDV(int trainerIdx, int trainerClassIdx, bool trainerClassMale, int pokeIdx, int pokeLevel, uint nature)
{
int DV;
// Iterate over all possible PIDs and return highest DV that yields the desired nature
for (DV = 255; DV >= 0; DV--)
{
if (getNatureFromPID(generatePID(trainerIdx, trainerClassIdx, trainerClassMale, pokeIdx, pokeLevel, DV)) == nature)
{ return DV; }
}
return -1;
}
// this function is lifted from turtleisaac's Pokeditor (with permission)
// See https://github.com/turtleisaac/PokEditor-v2/blob/72ca6ab641f616b8be9a87624b81896baa45f947/src/com/turtleisaac/pokeditor/utilities/TrainerPersonalityCalculator.java
public static uint generatePID(int trainerIdx, int trainerClassIdx, bool trainerClassMale, int pokeIdx, int pokeLevel, int difficultyValue)
{
long newSeed = trainerIdx + pokeIdx + pokeLevel + difficultyValue;
long random = 0;
setSeed(newSeed);
while (trainerClassIdx > 0)
{
trainerClassIdx--;
random = getNextRandom();
}
// Don't really get this part? Why are we shifting to the right then left again?
long PID = (random >> 16) & 0xffff;
PID = PID * 256;
// This seems super arbitrary (wtf GameFreak?)
PID += trainerClassMale ? 136 : 120;
return (uint)PID;
}
public static uint getNatureFromPID(uint PID)
{
return (PID % 100) % 25;
}
public static List<DVIVNatureTriplet> getAllNatures(int trainerIdx, int trainerClassIdx, bool trainerClassMale, int pokeIdx, int pokeLevel)
{
List<DVIVNatureTriplet> natureList = new List<DVIVNatureTriplet>();
int DV;
uint natureIdx;
// Iterate over all possible PIDs and store the DV IV and Nature String in the custom data type
for (DV = 255; DV >= 0; DV--)
{
natureIdx = getNatureFromPID(generatePID(trainerIdx, trainerClassIdx, trainerClassMale, pokeIdx, pokeLevel, DV));
natureList.Add(new DVIVNatureTriplet(DV, DV*31/255 , Natures[(int)natureIdx]));
}
return natureList;
}
public static readonly List<string> Natures = new List<string>
{
"Hardy: Neutral",
"Lonely: +Atk, -Def",
"Brave: +Atk, -Spe",
"Adamant: +Atk, -SpA",
"Naughty: +Atk, -SpD",
"Bold: +Def, -Atk",
"Docile: Neutral",
"Relaxed: +Def, -Spe",
"Impish: +Def, -SpA",
"Lax: +Def, -SpD",
"Timid: +Spe, -Atk",
"Hasty: +Spe, -Def",
"Serious: Neutral",
"Jolly: +Spe, -SpA",
"Naive: +Spe, -SpD",
"Modest: +SpA, -Atk",
"Mild: +SpA, -Def",
"Quiet: +SpA, -Spe",
"Bashful: Neutral",
"Rash: +SpA, -SpD",
"Calm: +SpD, -Atk",
"Gentle: +SpD, -Def",
"Sassy: +SpD, -Spe",
"Careful: +SpD, -SpA",
"Quirky: Neutral"
};
}
}

File diff suppressed because it is too large Load Diff

View File

@ -8154,11 +8154,8 @@ namespace DSPRE {
}
private void DVExplainButton_Click(object sender, EventArgs e) {
MessageBox.Show("DV, or \"Difficulty Value\", is used by the game engine to calculate how tough an opponent Pokemon should be.\n" +
"The DV affects a Pokemon's Nature and IVs - the higher the value, the stronger the Pokemon.\n" +
"DVs will go from 1 (0 IVs) to 255 (31 IVs). Natures are chosen semi-randomly." +
"\nIVs will be the same value for all Stats at any DV, so Hidden Power will only be Fighting or Dark Type." +
"\n\nFor the time being, DSPRE Reloaded is unable to calculate the target DV of a Pokémon for a given Nature and set of IVs.", "Difficulty Value", MessageBoxButtons.OK, MessageBoxIcon.Information);
DVCalc DVcalcForm = new DVCalc(trainerComboBox.SelectedIndex, trainerClassListBox.SelectedIndex);
DVcalcForm.ShowDialog();
}
private void partyCountUpDown_ValueChanged(object sender, EventArgs e) {

View File

@ -956,7 +956,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM
EgAAAk1TRnQBSQFMAgEBCgEAATABHAEwARwBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
EgAAAk1TRnQBSQFMAgEBCgEAATgBHAE4ARwBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA