Skip to content

Commit

Permalink
Added UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cirion02 committed Mar 25, 2023
1 parent 8dcb01c commit 0ab6fd9
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 2 deletions.
2 changes: 2 additions & 0 deletions BingoForcing.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion BingoForcing/BoardGeneration/BoardsFileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static void WriteBoardsToFile(string filename, int count, int min = 0)

using StreamWriter sw = new StreamWriter(@"../../../BoardsFiles/" + filename + ".txt");

for (int i = min; i < count; i++)
for (int i = min; i < count + min; i++)
{
sw.WriteLine(StringRepresentationGenerator.BoardToString(generator.GenerateBoard(i)));
}
Expand Down
3 changes: 2 additions & 1 deletion BingoForcing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
using BingoForcing.BoardGeneration;
using BingoForcing.DataGathering;
using BingoForcing.GeneratorHelperFileGenerators;
using BingoForcing.UI;

ObjectiveCounts.WriteObjectiveCounts("lockout-3-1-2");
UI.Main();
115 changes: 115 additions & 0 deletions BingoForcing/UI/UI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using BingoForcing.BoardGeneration;

namespace BingoForcing.UI;

public static class UI
{
private static string? _currentFilename;

public static void Main()
{
Console.WriteLine("Bingo Brute Force v1.idk by Cirion02\n");

bool done = false;

while (!done)
{
done = AwaitCommand();
}
}

private static bool AwaitCommand()
{
Console.WriteLine("\nAwaiting command, type help for list of commands, type quit to exit program");

if (_currentFilename == null)
{
Console.WriteLine("WARNING: No filename is currently selected, most commands will not work without them. Set one using setFileName");
}

Console.Write("> ");
string input = (Console.ReadLine() ?? "");
string[] inputs = input.Split(" ");
string command = inputs[0].ToLower();
string arg = inputs.Length > 1 ? inputs[1] : "";

switch (command)
{
case "help":
Help();
return false;
case "quit":
Quit();
return true;
case "setfilename":
SetFileName(arg);
return false;
case "genboards":
GenBoards();
return false;
default:
Console.WriteLine("Unknown command, type help for list of commands.");
return false;
}
}

private static void Help()
{
Console.WriteLine("Help: Shows this list");
Console.WriteLine("Quit: Quits the application");
Console.WriteLine("SetFileName: Sets the file name of the files that will be read and written too,\n" +
"changing this between commands could have unintended consequences.");
Console.WriteLine("GenBoards: Generates the list of boards with the current gen (This takes long)");
}

private static void Quit()
{
Console.WriteLine("Exiting...");
}

private static void SetFileName(string arg)
{
string filename;
if (arg == "")
{
Console.WriteLine("Enter filename (this is the base filename of your json file, so lockout1.json would be 'lockout1'");
Console.Write("> ");
filename = (Console.ReadLine() ?? "").ToLower();
}
else
{
filename = arg;
}
if (!File.Exists(@"../../../GeneratorJsons/" + filename + ".json"))
{
Console.WriteLine($"No generator was found at GeneratorJsons/{filename}\nPlease try again");
}
else
{
Console.WriteLine($"Succesfully set generator filename to {filename}");
_currentFilename = filename;
}
}

private static void GenBoards()
{
if (_currentFilename == null)
{
Console.WriteLine("No filename is currently selected, set use using SetFileName and then try again.");
return;
}
if (File.Exists(@"../../../BoardsFiles/" + _currentFilename + ".txt"))
{
Console.WriteLine($"Boards for {_currentFilename} have already been generated before, are you sure you want to do it again. Type Y to continue.");
Console.Write("> ");
string input = (Console.ReadLine() ?? "").ToLower();
if (input != "y" && input != "yes")
{
Console.WriteLine("Boardfile generation cancelled.");
return;
}
Console.WriteLine("Continuing");
}
BoardsFileGenerator.WriteBoardsToFile(_currentFilename, 1000000);
}
}

0 comments on commit 0ab6fd9

Please sign in to comment.