Skip to content

Commit

Permalink
Add interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
fhelwanger committed Mar 10, 2021
1 parent c5aa463 commit 2d15377
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Instead of editing the source code directly, the settings can be changed by edit
"Fuzzy": [ ".", "r", "o", "ro" ], // If do fuzzy search do find cards (r = input ranks, o = opening hands)
"ForcedIncr": 10, // Number of RNG additions when "Play" is selected
"AcceptDelayFrame": 3, // Number of frames after selecting "Play" that RNG additions stop
"Prompt": "> " // The prompt string to display
"Prompt": "> ", // The prompt string to display
"Interactive": false // If should prompt for parameters in case they're not supplied
}
```

Expand Down
3 changes: 2 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"Fuzzy": [ ".", "r", "o", "ro" ],
"ForcedIncr": 10,
"AcceptDelayFrame": 3,
"Prompt": "> "
"Prompt": "> ",
"Interactive": false
}
1 change: 1 addition & 0 deletions src/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Options
public uint ForcedIncr { get; set; } = 10;
public int AcceptDelayFrame { get; set; } = 3;
public string Prompt { get; set; } = "> ";
public bool Interactive { get; set; } = false;

public enum TOrder
{
Expand Down
31 changes: 27 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ static void Main(string[] args)
return;
}

if (args.Length == 0)
if (_args.Length == 0)
{
ShowHelp();
return;
if (_options.Interactive)
{
_args = PromptArgs();
}
else
{
ShowHelp();
return;
}
}

var (firstState, state, count, searchType) = ReadArgs(args);
var (firstState, state, count, searchType) = ReadArgs(_args);
var player = PlayerTable.Get(_options.Player);

if (searchType == TSearchType.First)
Expand Down Expand Up @@ -781,6 +788,22 @@ static void ShowPatternHelp()
Console.WriteLine(Translate.Get("help.pattern"));
}

static string[] PromptArgs()
{
Console.WriteLine(Translate.Get("prompt_args.first"));
var first = Prompt();
Console.WriteLine(Translate.Get("prompt_args.second"));
var second = Prompt();
Console.WriteLine();

if (string.IsNullOrWhiteSpace(second))
{
return new string[] { first };
}

return new string[] { first, second };
}

static string Prompt()
{
Console.Write(_options.Prompt);
Expand Down
3 changes: 3 additions & 0 deletions src/Translate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ static Translate()
_expressions.Add("pattern2str_fmt", "Initiative: {0}\nDeck: {1}");
_expressions.Add("no_target", "There is no target.");

_expressions.Add("prompt_args.first", "Enter 1 for Elastoid, 2 for Malboro, 3 for Biggs&Wedge or the RNG state in hexadecimal:");
_expressions.Add("prompt_args.second", "Enter the RNG counter (optional):");

_expressions.Add("prompt.rare_search", "Enter:start Rare Card Timer (h:Help, q:Quit, else:Recovery Search):");
_expressions.Add("prompt.after_normal_search", "Enter:start Rare Card Timer (h:Help, q:Quit, else:change Pattern for Search):");
_expressions.Add("prompt.second_game_method", "Please hit \"Play\" with turbo button\nand input the opening situation of the 1st game (h:Help, q:Quit):");
Expand Down

0 comments on commit 2d15377

Please sign in to comment.