Skip to content

Commit 0ddaf15

Browse files
committed
SG : Added missing settings and clear screen feature before asking for next parameter
1 parent 3b7d490 commit 0ddaf15

File tree

2 files changed

+189
-112
lines changed

2 files changed

+189
-112
lines changed

PCCSettingsCalculator/Program.cs

Lines changed: 122 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ class Program
2626

2727
static void Main(string[] args)
2828
{
29-
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
30-
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
31-
Console.WriteLine("=====================================================================================================================");
32-
Console.WriteLine("Note :");
33-
Console.WriteLine("Please keep in mind that,");
34-
Console.WriteLine("There will be precision loss for those settings generated by this application.");
35-
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
29+
#region Initialize
30+
31+
Clear();
3632
string temp = "Start";
3733
Console.ReadKey();
3834
Settings settings = new Settings
@@ -42,115 +38,141 @@ static void Main(string[] args)
4238
};
4339
PearlEntity pearl = new PearlEntity();
4440
Surface2D chamber = new Surface2D();
41+
42+
#endregion
43+
4544
do
4645
{
46+
47+
#region Input
48+
4749
if(temp == "1" || temp == "Start")
4850
{
51+
Clear();
4952
Console.WriteLine("Please enter the corrdinate of the center Of your FTL blast chamber :");
5053
chamber = ReadSurface2DFromConsole("FTL blast chamber ceter coordinate");
5154
}
5255
if(temp == "2" || temp == "Start")
5356
{
57+
Clear();
5458
Console.WriteLine("Please enter the coordinate of the pearl:");
5559
settings.Pearl.Position = ReadSpace3DFromConsole("Pearl coordinate");
5660
}
5761
if(temp == "3" || temp == "Start")
5862
{
63+
Clear();
5964
Console.WriteLine("Please enter the pearl motion :");
6065
settings.Pearl.Motion = ReadSpace3DFromConsole("Pearl Motion");
6166
}
6267
if(temp == "4" || temp == "Start")
6368
{
69+
Clear();
6470
Console.WriteLine("Please enter the coordinates of the north west TNT :");
6571
settings.NorthWestTNT = ReadSpace3DFromConsole("North west TNT coordinate");
6672
}
6773
if(temp == "5" || temp == "Start")
6874
{
75+
Clear();
6976
Console.WriteLine("Please enter the coordinates of the north east TNT :");
7077
settings.NorthEastTNT = ReadSpace3DFromConsole("North east TNT coordinate");
7178
}
7279
if(temp == "6" || temp == "Start")
7380
{
81+
Clear();
7482
Console.WriteLine("Please enter the coordinates of the south west TNT :");
7583
settings.SouthWestTNT = ReadSpace3DFromConsole("South west TNT coordinate");
7684
}
7785
if(temp == "7" || temp == "Start")
7886
{
87+
Clear();
7988
Console.WriteLine("Please enter the coordinates of the south east TNT :");
8089
settings.SouthEastTNT = ReadSpace3DFromConsole("South east TNT coordinate");
8190
}
82-
//if(temp == "9" || temp == "Start")
83-
//{
84-
// Console.WriteLine("Please set the direction of your FTL in east mode");
85-
// Console.WriteLine("Please enter the coordinates of the red TNT");
86-
// Space3D redTNT = ReadSpace3DFromConsole("Red TNT coordinate");
87-
// Console.WriteLine("Please enter the coordinates of the blue TNT");
88-
// Space3D blueTNT = ReadSpace3DFromConsole("Blue TNT coordinate");
89-
// if(redTNT.IsNorth(blueTNT))
90-
// {
91-
// settings.NorthWestTNT = redTNT;
92-
// settings.SouthWestTNT = blueTNT;
93-
// settings.DefaultRedTNTDirection = Direction.North;
94-
// settings.DefaultBlueTNTDirection = Direction.South;
95-
// }
96-
// else
97-
// {
98-
// settings.NorthWestTNT = blueTNT;
99-
// settings.SouthWestTNT = redTNT;
100-
// settings.DefaultBlueTNTDirection = Direction.North;
101-
// settings.DefaultRedTNTDirection = Direction.South;
102-
// }
103-
// Console.WriteLine("Please set the direction of your FTL in west mode");
104-
// Console.WriteLine("Please enter the coordinate of the red TNT");
105-
// redTNT = ReadSpace3DFromConsole("Red TNT coordinate");
106-
// Console.WriteLine("Please enter the coordinate of the blue TNT");
107-
// blueTNT = ReadSpace3DFromConsole("Blue TNT coordinate");
108-
// if(redTNT.IsNorth(blueTNT))
109-
110-
//}
111-
if(temp == "8" || temp == "Start")
91+
if(temp == "9" || temp == "Start")
11292
{
113-
Console.Clear();
114-
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
115-
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
116-
Console.WriteLine("=====================================================================================================================");
117-
Console.WriteLine("Note :");
118-
Console.WriteLine("Please keep in mind that,");
119-
Console.WriteLine("There will be precision loss for those settings generated by this application.");
120-
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
121-
Console.WriteLine(" | | ");
122-
Console.WriteLine(" | | ");
123-
Console.WriteLine(" | | ");
124-
Console.WriteLine("--------+---------------------------------+--------");
125-
Console.WriteLine(" | | ");
126-
Console.WriteLine(" | | ");
127-
Console.WriteLine(" | | ");
128-
Console.WriteLine(" | | ");
129-
Console.WriteLine(" | | ");
130-
Console.WriteLine(" | | ");
131-
Console.WriteLine(" | | ");
132-
Console.WriteLine(" | | ");
133-
Console.WriteLine(" | | ");
134-
Console.WriteLine(" | | ");
135-
Console.WriteLine(" | | ");
136-
Console.WriteLine(" | | ");
137-
Console.WriteLine(" | | ");
138-
Console.WriteLine("--------+---------------------------------+--------");
139-
Console.WriteLine(" | | ");
140-
Console.WriteLine(" | | ");
141-
Console.WriteLine(" | | ");
93+
Clear();
94+
Console.WriteLine("Please take a look in the following AA image and press a key");
95+
Console.WriteLine();
96+
Console.WriteLine(@" | | ");
97+
Console.WriteLine(@" | | ");
98+
Console.WriteLine(@" A | | B ");
99+
Console.WriteLine(@"--------+---------------------------------+-------- ");
100+
Console.WriteLine(@" | | ");
101+
Console.WriteLine(@" | | N ");
102+
Console.WriteLine(@" | | ^ ");
103+
Console.WriteLine(@" | | /|\ ");
104+
Console.WriteLine(@" | | | ");
105+
Console.WriteLine(@" | | | ");
106+
Console.WriteLine(@" | | | ");
107+
Console.WriteLine(@" | | | ");
108+
Console.WriteLine(@" | | | ");
109+
Console.WriteLine(@" | | | ");
110+
Console.WriteLine(@" | | | ");
111+
Console.WriteLine(@" | | ");
112+
Console.WriteLine(@" | | ");
113+
Console.WriteLine(@"--------+---------------------------------+-------- ");
114+
Console.WriteLine(@" C | | D ");
115+
Console.WriteLine(@" | | ");
116+
Console.WriteLine(@" | | ");
117+
Console.ReadKey();
118+
Console.WriteLine();
119+
Console.WriteLine("Please take a look in the following statement and understand it.");
120+
SeparatingLine();
121+
Console.WriteLine("Once your TNT was flew into the chamber.");
122+
Console.WriteLine("Don't use anything to move it.");
123+
Console.WriteLine("Let the TNT drop and remember it's place.");
124+
Console.WriteLine("Them, enter the corresponding English symbol.");
125+
Console.WriteLine("For example, the TNT was dropped in the south east corner.");
126+
Console.WriteLine("The corresponding English symbol will be D.");
127+
SeparatingLine();
128+
Console.WriteLine("Corresponding English symbol for red TNT");
129+
string temp2 = Console.ReadLine();
130+
while(temp2 != "A" && temp2 != "B" && temp2 != "C" && temp2 != "D")
131+
{
132+
SeparatingLine();
133+
Console.WriteLine("Wrong format. Please enter the following value again.");
134+
Console.WriteLine("Corresponding English symbol for red TNT");
135+
temp2 = Console.ReadLine();
136+
}
137+
switch(temp2)
138+
{
139+
case "A":
140+
settings.DefaultRedTNTDirection = Direction.NorthWest;
141+
settings.DefaultBlueTNTDirection = Direction.SouthEast;
142+
break;
143+
case "B":
144+
settings.DefaultRedTNTDirection = Direction.NorthEast;
145+
settings.DefaultBlueTNTDirection = Direction.SouthWest;
146+
break;
147+
case "C":
148+
settings.DefaultRedTNTDirection = Direction.SouthWest;
149+
settings.DefaultBlueTNTDirection = Direction.NorthEast;
150+
break;
151+
case "D":
152+
settings.DefaultRedTNTDirection = Direction.SouthEast;
153+
settings.DefaultBlueTNTDirection = Direction.NorthWest;
154+
break;
155+
}
142156
}
143-
if(temp == "9" || temp == "Start")
157+
if(temp == "8" || temp == "Start")
144158
{
159+
Clear();
145160
Console.WriteLine("Please enter the maximum amount of TNT :");
146161
temp = Console.ReadLine();
147162
while(!int.TryParse(temp , out settings.MaxTNT))
148163
{
164+
Clear();
149165
Console.WriteLine("Wrong format. Please enter the following value again.");
150166
Console.WriteLine("Maximum amount of TNT :");
151167
temp = Console.ReadLine();
152168
}
153169
}
170+
171+
#endregion
172+
173+
#region Verify
174+
175+
Clear();
154176
Console.WriteLine("These are the parameters that you have entered.");
155177
Console.WriteLine("1) FTL blast chamber center " + chamber);
156178
Console.WriteLine("2) Ender Pearl " + settings.Pearl.Position);
@@ -161,6 +183,7 @@ static void Main(string[] args)
161183
Console.WriteLine("6) South west TNT " + settings.SouthWestTNT);
162184
Console.WriteLine("7) South east TNT " + settings.SouthEastTNT);
163185
Console.WriteLine("8) Max TNT : " + settings.MaxTNT.ToString());
186+
Console.WriteLine("9) Direction of the red TNT : " + settings.DefaultRedTNTDirection.ToString());
164187
Console.WriteLine("Please confirm if they are all correct. (Y/N)");
165188
temp = Console.ReadLine().ToUpper();
166189
while(temp != "Y" && temp != "N")
@@ -172,14 +195,20 @@ static void Main(string[] args)
172195
{
173196
Console.WriteLine("Please specify the number of the parameter you would like to chamge.");
174197
temp = Console.ReadLine();
175-
while(!(int.TryParse(temp , out int i) && i < 9 && i > 0))
198+
while(!(int.TryParse(temp , out int i) && i < 10 && i > 0))
176199
{
177200
Console.WriteLine("Wrong format. Please enter the following parameter again.");
178201
Console.WriteLine("Please specify the number of the parameter you would like to chamge.");
179202
temp = Console.ReadLine();
180203
}
181204
}
205+
206+
#endregion
207+
182208
} while(temp != "Y");
209+
210+
#region General settings.json
211+
183212
settings.NorthWestTNT -= chamber.ToSpace3D();
184213
settings.NorthEastTNT -= chamber.ToSpace3D();
185214
settings.SouthWestTNT -= chamber.ToSpace3D();
@@ -188,6 +217,7 @@ static void Main(string[] args)
188217
settings.Pearl.Position.X = 0;
189218
settings.Pearl.Position.Z = 0;
190219
settings.Direction = Direction.North;
220+
Clear();
191221
Console.WriteLine("These are the settings it had generated.");
192222
Console.WriteLine("1) Max TNT : " + settings.MaxTNT.ToString());
193223
Console.WriteLine("2) North West TNT " + settings.NorthWestTNT.ToString());
@@ -198,20 +228,25 @@ static void Main(string[] args)
198228
temp = settings.Pearl.Motion.X.ToString() + " , " + settings.Pearl.Motion.Y.ToString() + " , " + settings.Pearl.Motion.Z.ToString();
199229
Console.WriteLine("7) Ender Pearl Motion : " + temp);
200230
Console.WriteLine("8) Offset " + settings.Offset.ToString());
231+
Console.WriteLine("9) Default Red TNT Direction : " + settings.DefaultRedTNTDirection.ToString());
232+
Console.WriteLine("10) Default Blue TNT Direction : " + settings.DefaultBlueTNTDirection.ToString());
201233
Console.WriteLine("Do you want to save as settings.json? (Y/N)");
202234
temp = Console.ReadLine().ToUpper();
203235
while(temp != "Y" && temp != "N")
204236
{
205237
Console.WriteLine("Unexpected response. Do you want to save as settings.json? (Y/N)");
206238
temp = Console.ReadLine().ToUpper();
207239
}
240+
Clear();
208241
if(temp == "Y")
209242
{
210243
SaveSettingsToJson("./settings.json" , settings);
211244
Console.WriteLine("File saved.");
212245
}
213246
Console.WriteLine("Press any key to quit.");
214247
Console.ReadKey();
248+
249+
#endregion
215250
}
216251

217252
private static void SaveSettingsToJson(string path , Settings settings)
@@ -275,5 +310,24 @@ public static Surface2D ReadSurface2DFromConsole(string valueName)
275310
}
276311
return result;
277312
}
313+
314+
public static void Clear()
315+
{
316+
Console.Clear();
317+
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
318+
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
319+
Console.WriteLine("=====================================================================================================================");
320+
Console.WriteLine("Note :");
321+
Console.WriteLine("Please keep in mind that,");
322+
Console.WriteLine("There will be precision loss for those settings generated by this application.");
323+
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
324+
Console.WriteLine();
325+
Console.WriteLine();
326+
}
327+
328+
public static void SeparatingLine()
329+
{
330+
Console.WriteLine("---------------------------------------------------Separating Line---------------------------------------------------");
331+
}
278332
}
279333
}

0 commit comments

Comments
 (0)