Skip to content

Commit

Permalink
* added new multipliers
Browse files Browse the repository at this point in the history
* increased tolerance for rounding-errors
  • Loading branch information
cadon committed Jan 5, 2016
1 parent 998d895 commit 6bf55ca
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 29 deletions.
3 changes: 3 additions & 0 deletions ARKBreedingStats/ARKBreedingStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Content Include="settings.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="stats.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
58 changes: 42 additions & 16 deletions ARKBreedingStats/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 92 additions & 10 deletions ARKBreedingStats/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public Form1()

private void Form1_Load(object sender, EventArgs e)
{
linkLabel1.Links.Add(0, 12, "https://github.com/cadon/ARKStatsExtractor");
statIOs.Add(this.statIOHealth);
statIOs.Add(this.statIOStamina);
statIOs.Add(this.statIOOxygen);
Expand All @@ -48,9 +47,8 @@ private void Form1_Load(object sender, EventArgs e)
statIOs[s].Title = statNames[s];
if (precisions[s] == 3) { statIOs[s].Percent = true; }
}
loadFile();
loadFile(true);
comboBoxCreatures.SelectedIndex = 0;
labelVersion.Text = "v0.12";
labelSumDomSB.Text = "";
ToolTip tt = new ToolTip();
tt.SetToolTip(this.checkBoxOutputRowHeader, "Include Headerrow");
Expand Down Expand Up @@ -155,13 +153,14 @@ private void buttonCalculate_Click(object sender, EventArgs e)
vWildL = stats[c][s][0] + stats[c][s][0] * stats[c][s][1] * w + (postTamed ? stats[c][s][3] : 0);
for (int d = 0; d < maxLD + 1; d++)
{
double temp = Math.Round(vWildL + vWildL * stats[c][s][2] * d, precisions[s]);
if (withTEff)
{
// taming bonus is percentual, this means the taming-efficiency plays a role
// taming bonus is dependant on taming-efficiency
// get tamingEfficiency-possibility
// rounding errors need to increase error-range
tamingEfficiency = Math.Round((inputValue / (1 + stats[c][s][2] * d) - vWildL) / (vWildL * stats[c][s][4]), 3, MidpointRounding.AwayFromZero);
if (tamingEfficiency >= tELowerBound)
if (tamingEfficiency > 1 && tamingEfficiency < 1.005) { tamingEfficiency = 1; }
if (tamingEfficiency >= tELowerBound - 0.005)
{
if (tamingEfficiency <= tEUpperBound)
{
Expand Down Expand Up @@ -440,10 +439,53 @@ private void setPossibilitiesListbox(int s)
}
}

private void loadFile()
private void loadFile(bool loadSettings)
{
string path = "";
if (loadSettings)
{
// read settings from file
path = "settings.txt";

// check if file exists
if (System.IO.File.Exists(path))
{
string[] rows;
rows = System.IO.File.ReadAllLines(path);
string[] values;
int s = 0;
double value = 0;
foreach (string row in rows)
{
if (row.Length > 1 && row.Substring(0, 2) != "//")
{
values = row.Split(',');
if (values.Length == 3)
{
value = 0;
if (Double.TryParse(values[0], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out value))
{
statIOs[s].MultAdd = value;
}
value = 0;
if (Double.TryParse(values[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out value))
{
statIOs[s].MultAff = value;
}
value = 0;
if (Double.TryParse(values[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out value))
{
statIOs[s].MultLevel = value;
}
s++;
}
}
}
}
}

// read entities from file
string path = "stats.txt";
path = "stats.txt";

// check if file exists
if (!System.IO.File.Exists(path))
Expand Down Expand Up @@ -480,12 +522,24 @@ private void loadFile()
{
for (int v = 0; v < values.Length; v++)
{
if ((s == 5 || s == 6) && v == 0) { stats[c][s][0] = 1; } // damage and speed are handled as percentage of a hidden base value, this tool uses 100% as base
if ((s == 5 || s == 6) && v == 0) { stats[c][s][0] = 1; } // damage and speed are handled as percentage of a hidden base value, this tool uses 100% as base, as seen ingame
else
{
double value = 0;
if (Double.TryParse(values[v], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out value))
{
switch (v)
{
case 2:
value *= statIOs[s].MultLevel;
break;
case 3:
value *= statIOs[s].MultAdd;
break;
case 4:
value *= statIOs[s].MultAff;
break;
}
stats[c][s][v] = value;
}
}
Expand Down Expand Up @@ -628,7 +682,7 @@ private double breedingValue(int s, int r)

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
System.Diagnostics.Process.Start("https://github.com/cadon/ARKStatsExtractor");
}

private void numericUpDown_Enter(object sender, EventArgs e)
Expand Down Expand Up @@ -662,6 +716,34 @@ private void buttonClear_Click(object sender, EventArgs e)
numericUpDownLevel.Value = 1;
}

private void checkBoxSettings_CheckedChanged(object sender, EventArgs e)
{
this.SuspendLayout();
bool t = checkBoxSettings.Checked;
for (int s = 0; s < 8; s++)
{
statIOs[s].Settings = t;
}
checkBoxSettings.Text = (t ? "OK" : "Settings");
if (!t)
{
// save settings to file
string path = "settings.txt";
string[] content = new string[9];
content[0] = "// csv of multiplicators: MultAdd,MultAffinity,MultLevel. Order of stats (one per row): Health, Stamina, Oxygen, Food, Weight, Damage, Speed, Torpor";
for (int s = 0; s < 8; s++)
{
content[s + 1] = statIOs[s].MultAdd.ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + statIOs[s].MultAff.ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + statIOs[s].MultLevel.ToString(System.Globalization.CultureInfo.InvariantCulture);
}

System.IO.File.WriteAllLines(path, content);

// update stats according to settings
loadFile(false);
}
this.ResumeLayout();
}

private void showSumOfChosenLevels()
{
int sumW = 0, sumD = 0;
Expand Down
Loading

0 comments on commit 6bf55ca

Please sign in to comment.