Skip to content

Commit

Permalink
SG : Added missing settings and clear screen feature before asking fo…
Browse files Browse the repository at this point in the history
…r next parameter
  • Loading branch information
LegendsOfSky committed Jul 11, 2021
1 parent 3b7d490 commit 0ddaf15
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 112 deletions.
190 changes: 122 additions & 68 deletions PCCSettingsCalculator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ class Program

static void Main(string[] args)
{
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
Console.WriteLine("=====================================================================================================================");
Console.WriteLine("Note :");
Console.WriteLine("Please keep in mind that,");
Console.WriteLine("There will be precision loss for those settings generated by this application.");
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
#region Initialize

Clear();
string temp = "Start";
Console.ReadKey();
Settings settings = new Settings
Expand All @@ -42,115 +38,141 @@ static void Main(string[] args)
};
PearlEntity pearl = new PearlEntity();
Surface2D chamber = new Surface2D();

#endregion

do
{

#region Input

if(temp == "1" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the corrdinate of the center Of your FTL blast chamber :");
chamber = ReadSurface2DFromConsole("FTL blast chamber ceter coordinate");
}
if(temp == "2" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the coordinate of the pearl:");
settings.Pearl.Position = ReadSpace3DFromConsole("Pearl coordinate");
}
if(temp == "3" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the pearl motion :");
settings.Pearl.Motion = ReadSpace3DFromConsole("Pearl Motion");
}
if(temp == "4" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the coordinates of the north west TNT :");
settings.NorthWestTNT = ReadSpace3DFromConsole("North west TNT coordinate");
}
if(temp == "5" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the coordinates of the north east TNT :");
settings.NorthEastTNT = ReadSpace3DFromConsole("North east TNT coordinate");
}
if(temp == "6" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the coordinates of the south west TNT :");
settings.SouthWestTNT = ReadSpace3DFromConsole("South west TNT coordinate");
}
if(temp == "7" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the coordinates of the south east TNT :");
settings.SouthEastTNT = ReadSpace3DFromConsole("South east TNT coordinate");
}
//if(temp == "9" || temp == "Start")
//{
// Console.WriteLine("Please set the direction of your FTL in east mode");
// Console.WriteLine("Please enter the coordinates of the red TNT");
// Space3D redTNT = ReadSpace3DFromConsole("Red TNT coordinate");
// Console.WriteLine("Please enter the coordinates of the blue TNT");
// Space3D blueTNT = ReadSpace3DFromConsole("Blue TNT coordinate");
// if(redTNT.IsNorth(blueTNT))
// {
// settings.NorthWestTNT = redTNT;
// settings.SouthWestTNT = blueTNT;
// settings.DefaultRedTNTDirection = Direction.North;
// settings.DefaultBlueTNTDirection = Direction.South;
// }
// else
// {
// settings.NorthWestTNT = blueTNT;
// settings.SouthWestTNT = redTNT;
// settings.DefaultBlueTNTDirection = Direction.North;
// settings.DefaultRedTNTDirection = Direction.South;
// }
// Console.WriteLine("Please set the direction of your FTL in west mode");
// Console.WriteLine("Please enter the coordinate of the red TNT");
// redTNT = ReadSpace3DFromConsole("Red TNT coordinate");
// Console.WriteLine("Please enter the coordinate of the blue TNT");
// blueTNT = ReadSpace3DFromConsole("Blue TNT coordinate");
// if(redTNT.IsNorth(blueTNT))

//}
if(temp == "8" || temp == "Start")
if(temp == "9" || temp == "Start")
{
Console.Clear();
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
Console.WriteLine("=====================================================================================================================");
Console.WriteLine("Note :");
Console.WriteLine("Please keep in mind that,");
Console.WriteLine("There will be precision loss for those settings generated by this application.");
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine("--------+---------------------------------+--------");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine("--------+---------------------------------+--------");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Console.WriteLine(" | | ");
Clear();
Console.WriteLine("Please take a look in the following AA image and press a key");
Console.WriteLine();
Console.WriteLine(@" | | ");
Console.WriteLine(@" | | ");
Console.WriteLine(@" A | | B ");
Console.WriteLine(@"--------+---------------------------------+-------- ");
Console.WriteLine(@" | | ");
Console.WriteLine(@" | | N ");
Console.WriteLine(@" | | ^ ");
Console.WriteLine(@" | | /|\ ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | | ");
Console.WriteLine(@" | | ");
Console.WriteLine(@" | | ");
Console.WriteLine(@"--------+---------------------------------+-------- ");
Console.WriteLine(@" C | | D ");
Console.WriteLine(@" | | ");
Console.WriteLine(@" | | ");
Console.ReadKey();
Console.WriteLine();
Console.WriteLine("Please take a look in the following statement and understand it.");
SeparatingLine();
Console.WriteLine("Once your TNT was flew into the chamber.");
Console.WriteLine("Don't use anything to move it.");
Console.WriteLine("Let the TNT drop and remember it's place.");
Console.WriteLine("Them, enter the corresponding English symbol.");
Console.WriteLine("For example, the TNT was dropped in the south east corner.");
Console.WriteLine("The corresponding English symbol will be D.");
SeparatingLine();
Console.WriteLine("Corresponding English symbol for red TNT");
string temp2 = Console.ReadLine();
while(temp2 != "A" && temp2 != "B" && temp2 != "C" && temp2 != "D")
{
SeparatingLine();
Console.WriteLine("Wrong format. Please enter the following value again.");
Console.WriteLine("Corresponding English symbol for red TNT");
temp2 = Console.ReadLine();
}
switch(temp2)
{
case "A":
settings.DefaultRedTNTDirection = Direction.NorthWest;
settings.DefaultBlueTNTDirection = Direction.SouthEast;
break;
case "B":
settings.DefaultRedTNTDirection = Direction.NorthEast;
settings.DefaultBlueTNTDirection = Direction.SouthWest;
break;
case "C":
settings.DefaultRedTNTDirection = Direction.SouthWest;
settings.DefaultBlueTNTDirection = Direction.NorthEast;
break;
case "D":
settings.DefaultRedTNTDirection = Direction.SouthEast;
settings.DefaultBlueTNTDirection = Direction.NorthWest;
break;
}
}
if(temp == "9" || temp == "Start")
if(temp == "8" || temp == "Start")
{
Clear();
Console.WriteLine("Please enter the maximum amount of TNT :");
temp = Console.ReadLine();
while(!int.TryParse(temp , out settings.MaxTNT))
{
Clear();
Console.WriteLine("Wrong format. Please enter the following value again.");
Console.WriteLine("Maximum amount of TNT :");
temp = Console.ReadLine();
}
}

#endregion

#region Verify

Clear();
Console.WriteLine("These are the parameters that you have entered.");
Console.WriteLine("1) FTL blast chamber center " + chamber);
Console.WriteLine("2) Ender Pearl " + settings.Pearl.Position);
Expand All @@ -161,6 +183,7 @@ static void Main(string[] args)
Console.WriteLine("6) South west TNT " + settings.SouthWestTNT);
Console.WriteLine("7) South east TNT " + settings.SouthEastTNT);
Console.WriteLine("8) Max TNT : " + settings.MaxTNT.ToString());
Console.WriteLine("9) Direction of the red TNT : " + settings.DefaultRedTNTDirection.ToString());
Console.WriteLine("Please confirm if they are all correct. (Y/N)");
temp = Console.ReadLine().ToUpper();
while(temp != "Y" && temp != "N")
Expand All @@ -172,14 +195,20 @@ static void Main(string[] args)
{
Console.WriteLine("Please specify the number of the parameter you would like to chamge.");
temp = Console.ReadLine();
while(!(int.TryParse(temp , out int i) && i < 9 && i > 0))
while(!(int.TryParse(temp , out int i) && i < 10 && i > 0))
{
Console.WriteLine("Wrong format. Please enter the following parameter again.");
Console.WriteLine("Please specify the number of the parameter you would like to chamge.");
temp = Console.ReadLine();
}
}

#endregion

} while(temp != "Y");

#region General settings.json

settings.NorthWestTNT -= chamber.ToSpace3D();
settings.NorthEastTNT -= chamber.ToSpace3D();
settings.SouthWestTNT -= chamber.ToSpace3D();
Expand All @@ -188,6 +217,7 @@ static void Main(string[] args)
settings.Pearl.Position.X = 0;
settings.Pearl.Position.Z = 0;
settings.Direction = Direction.North;
Clear();
Console.WriteLine("These are the settings it had generated.");
Console.WriteLine("1) Max TNT : " + settings.MaxTNT.ToString());
Console.WriteLine("2) North West TNT " + settings.NorthWestTNT.ToString());
Expand All @@ -198,20 +228,25 @@ static void Main(string[] args)
temp = settings.Pearl.Motion.X.ToString() + " , " + settings.Pearl.Motion.Y.ToString() + " , " + settings.Pearl.Motion.Z.ToString();
Console.WriteLine("7) Ender Pearl Motion : " + temp);
Console.WriteLine("8) Offset " + settings.Offset.ToString());
Console.WriteLine("9) Default Red TNT Direction : " + settings.DefaultRedTNTDirection.ToString());
Console.WriteLine("10) Default Blue TNT Direction : " + settings.DefaultBlueTNTDirection.ToString());
Console.WriteLine("Do you want to save as settings.json? (Y/N)");
temp = Console.ReadLine().ToUpper();
while(temp != "Y" && temp != "N")
{
Console.WriteLine("Unexpected response. Do you want to save as settings.json? (Y/N)");
temp = Console.ReadLine().ToUpper();
}
Clear();
if(temp == "Y")
{
SaveSettingsToJson("./settings.json" , settings);
Console.WriteLine("File saved.");
}
Console.WriteLine("Press any key to quit.");
Console.ReadKey();

#endregion
}

private static void SaveSettingsToJson(string path , Settings settings)
Expand Down Expand Up @@ -275,5 +310,24 @@ public static Surface2D ReadSurface2DFromConsole(string valueName)
}
return result;
}

public static void Clear()
{
Console.Clear();
Console.WriteLine("Welcome to the Pearl Calculator Core Settings Generator.");
Console.WriteLine("Please make sure you can see all the symbols(=) in the following line");
Console.WriteLine("=====================================================================================================================");
Console.WriteLine("Note :");
Console.WriteLine("Please keep in mind that,");
Console.WriteLine("There will be precision loss for those settings generated by this application.");
Console.WriteLine("Press any key to proceed if you acknowledge the above remark and prefer using this application.");
Console.WriteLine();
Console.WriteLine();
}

public static void SeparatingLine()
{
Console.WriteLine("---------------------------------------------------Separating Line---------------------------------------------------");
}
}
}
Loading

0 comments on commit 0ddaf15

Please sign in to comment.