-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
150 lines (119 loc) · 5.57 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using System.Drawing;
using System.Windows.Forms;
namespace GenshinWishesPredictor
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void UpdateProbabilities(object sender, EventArgs e)
{
int wishes, doneWishes;
try
{
wishes = int.Parse(this.textBox1.Text) / 160;
doneWishes = int.Parse(this.textBox2.Text);
}
catch(Exception)
{
wishes = 0;
doneWishes = 0;
}
double anyChance = 0, eventChance = 0;
if (this.checkBox2.Checked)
{
wishes += doneWishes;
for (int i = 1; i <= Math.Min(wishes, 90); ++i)
{
double currAnyChance = Main.WishProbability(i);
anyChance += currAnyChance;
eventChance += currAnyChance / 2;
for (int j = 1; j <= Math.Min(wishes - i, 90); ++j)
eventChance += Main.WishProbability(j) * currAnyChance / 2;
}
}
else
{
for (int i = doneWishes + 1; i <= Math.Min(wishes + doneWishes, 90); ++i)
{
double currAnyChance = Main.WishProbability(i);
anyChance += currAnyChance;
eventChance += currAnyChance / 2;
for (int j = 1; j <= Math.Min(wishes + doneWishes - i, 90); ++j)
eventChance += Main.WishProbability(j) * currAnyChance / 2;
}
}
anyChance = Math.Max(Math.Min(anyChance, 1), 0);
eventChance = Math.Max(Math.Min(eventChance, 1), 0);
if (this.checkBox1.Checked)
{
this.eventChance.Text = (Math.Round(anyChance, 4) * 100).ToString() + "%";
this.eventChance.ForeColor = Main.GetProbabilityColor(anyChance);
}
else
{
this.anyChance.Text = (Math.Round(anyChance, 4) * 100).ToString() + "%";
this.eventChance.Text = (Math.Round(eventChance, 4) * 100).ToString() + "%";
this.anyChance.ForeColor = Main.GetProbabilityColor(anyChance);
this.eventChance.ForeColor = Main.GetProbabilityColor(eventChance);
}
}
public static double WishProbability(int wish)
{
return wish < 90 ? Math.Pow(0.994, wish - 1) * 0.006 : 1;
}
public static Color GetProbabilityColor(double probability)
{
return probability <= 0.15 ? Color.Red :
probability <= 0.3 ? Color.Orange :
probability <= 0.45 ? Color.SteelBlue :
Color.Green;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked)
{
this.label4.Visible = false;
this.anyChance.Visible = false;
this.label5.Top -= 40;
this.eventChance.Top -= 40;
this.Height -= 40;
}
else
{
this.label4.Visible = true;
this.anyChance.Visible = true;
this.label5.Top += 40;
this.eventChance.Top += 40;
this.Height += 40;
}
this.UpdateProbabilities(sender, e);
}
private void pictureBox6_Click(object sender, EventArgs e)
{
MessageBox.Show("Total amount of primogems you have or want to spend on event banner", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void pictureBox5_Click(object sender, EventArgs e)
{
MessageBox.Show("Amount of made wishes in event banners after the last 5* character. If you're trying to count the whole probability this parameter will be counted as number of wishes you have or want to use on event banner", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void pictureBox3_Click(object sender, EventArgs e)
{
MessageBox.Show("Enable this if you previously got a non-event 5* character from an event banner. This will change calculation results because you'll have 100% probability that your next 5* character will be event one", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void pictureBox4_Click(object sender, EventArgs e)
{
MessageBox.Show("You can calculate two types of probability:\n\nIf disabled - you will calculate probability of getting a 5* character for next some wishes you can do with your primogems\n\nIf enabled - you will calculate probability of getting a 5* character for all primogems and wishes you have\n\nThat's not quite clear difference so I'll give you an example: if you have already done 88 wishes and have 160 primogems\n\nWith disabled option you will see 0.35% probability to get 5* character\nWith enabled - 41.47%\n\nThat's because probability to get any 5* character for 89 wishes is 41.47%, but to get it for 1 wish after 88 ones is 0.35%", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
this.label7.Text = this.checkBox2.Checked ?
"Amount of available wishes:" :
"Amount of made wishes:";
this.UpdateProbabilities(sender, e);
}
}
}