Skip to content

Commit

Permalink
v.0.1.0
Browse files Browse the repository at this point in the history
Finnaly fixed precise float calculation
  • Loading branch information
Prevter committed Jul 13, 2020
1 parent a6e89b5 commit 3d24b49
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FloatToolGUI\bin
FloatToolGUI\obj
Binary file modified .vs/FloatToolGUI/v16/.suo
Binary file not shown.
45 changes: 23 additions & 22 deletions FloatToolGUI/Form1.Designer.cs

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

61 changes: 53 additions & 8 deletions FloatToolGUI/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ public override String ToString()
decimalPoint);
}
}
static public double craft(double[] ingridients, float minFloat, float maxFloat)
static public decimal craft(double[] ingridients, float minFloat, float maxFloat)
{
double avgFloat = 0;
decimal avgFloat = 0;
foreach (double f in ingridients)
{
avgFloat += f;
avgFloat += (decimal)f;
}
avgFloat /= 10;
return (maxFloat - minFloat) * avgFloat + minFloat;
return ((decimal)(maxFloat - minFloat) * avgFloat) + (decimal)minFloat;
}
static public string getNextRarity(string rarity)
{
Expand Down Expand Up @@ -216,8 +216,9 @@ public void parseCraft(double[] inputs, List<dynamic> outputs, string want, bool
//want = want.Replace(".", ",");
float minWear = item["minWear"];
float maxWear = item["maxWear"];
double flotOrigin = craft(inputs.ToArray(), minWear, maxWear);
string flot = ToExactString(flotOrigin);
decimal flotOrigin = Math.Round(craft(inputs.ToArray(), minWear, maxWear), 9);
string flot = ToExactString((double)flotOrigin);
Console.WriteLine(flot);
//Debug.WriteLine("[DEBUG] flot = " + flot);
// if (wasSort && ((!asc && (double.Parse(flot) > double.Parse(want))) || (asc && (double.Parse(flot) < double.Parse(want))))) {
// okSort = true;
Expand All @@ -226,6 +227,20 @@ public void parseCraft(double[] inputs, List<dynamic> outputs, string want, bool
{
this.Invoke((MethodInvoker)(() =>
{
using (WebClient wcf = new WebClient())
{
try
{
//string jsonf = wcf.DownloadString(url);
//dynamic rf = JsonConvert.DeserializeObject(jsonf);
//Debug.WriteLine("[DEBUG] " + counter + "/" + count + " load from csgofloat = " + jsonf);
//floats.Add(Convert.ToDouble(rf["iteminfo"]["floatvalue"]));
}
catch
{
Console.Write("");
}
}
textBox2.Text += "Коомбинация найдена!" + Environment.NewLine;
textBox2.Text += "Возможный флоат: " + flotOrigin + Environment.NewLine;
textBox2.Text += "Список флоатов: [";
Expand All @@ -241,6 +256,8 @@ public void parseCraft(double[] inputs, List<dynamic> outputs, string want, bool
textBox2.Text += "]" + Environment.NewLine + "======================================" + Environment.NewLine;
}
}
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));

Expand All @@ -249,6 +266,20 @@ public void parseCraft(double[] inputs, List<dynamic> outputs, string want, bool
}
}
}

public void SwitchEnabled()
{
comboBox1.Enabled = !comboBox1.Enabled;
comboBox2.Enabled = !comboBox2.Enabled;
textBox1.Enabled = !textBox1.Enabled;
comboBox3.Enabled = !comboBox3.Enabled;
textBox3.Enabled = !textBox3.Enabled;
numericUpDown1.Enabled = !numericUpDown1.Enabled;
numericUpDown2.Enabled = !numericUpDown2.Enabled;
checkBox1.Enabled = !checkBox1.Enabled;
checkBox2.Enabled = !checkBox2.Enabled;
checkBox3.Enabled = !checkBox3.Enabled;
}
public void updateSearchStr()
{
string search = "";
Expand All @@ -269,7 +300,6 @@ public FloatTool()

private void Form1_Load(object sender, EventArgs e)
{
thread1 = new Thread(StartCalculation);
comboBox2.Items.Clear();
using (StreamReader r = new StreamReader("itemData.json"))
{
Expand Down Expand Up @@ -338,8 +368,10 @@ private void StartCalculation()
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text = "Добро пожаловать в FloatTool!" + Environment.NewLine + "Инструмент для создания флоатов при помощи крафтов CS:GO" + Environment.NewLine;
textBox2.Text += "Время начала процесса: " + DateTime.Now.ToString("hh:mm:ss tt") + Environment.NewLine;
textBox2.Text += "Время начала процесса: " + DateTime.Now.ToString("HH:mm:ss tt") + Environment.NewLine;
button2.Text = "Стоп";
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));

Expand All @@ -348,11 +380,14 @@ private void StartCalculation()
string wanted = textBox3.Text;
string q = textBox1.Text;
string url = "https://steamcommunity.com/market/listings/730/" + q + "/render/?query=&language=russian&count=" + count + "&start=" + start + "&currency=5";
Console.WriteLine(url);
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text += "Загрузка скинов с торговой площадки..." + Environment.NewLine;
progressBar1.Maximum = int.Parse(count);
progressBar1.Value = 0;
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));

Expand All @@ -364,6 +399,8 @@ private void StartCalculation()
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text += "Получение флоатов..." + Environment.NewLine;
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));
int counter = 0;
Expand Down Expand Up @@ -415,6 +452,8 @@ private void StartCalculation()
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text += "Поиск ауткамов..." + Environment.NewLine;
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));

Expand All @@ -440,6 +479,8 @@ private void StartCalculation()
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text += "Ауткамы найдены! Начинаю подбор..." + Environment.NewLine + Environment.NewLine;
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));
//return;
Expand Down Expand Up @@ -475,6 +516,8 @@ private void StartCalculation()
this.Invoke((MethodInvoker)(() =>
{
textBox2.Text += "Программа завершила проверку всех комбинаций!" + Environment.NewLine;
textBox1.SelectionStart = textBox1.Text.Length;
textBox2.ScrollToCaret();
}
));

Expand All @@ -483,13 +526,15 @@ private void StartCalculation()
private void button2_Click(object sender, EventArgs e)
{
if(button2.Text == "Старт") {
thread1 = new Thread(StartCalculation);
thread1.Start();
}
else
{
thread1.Abort();
button2.Text = "Старт";
}
SwitchEnabled();
}

private void textBox2_TextChanged(object sender, EventArgs e)
Expand Down

0 comments on commit 3d24b49

Please sign in to comment.