Add H for help in keyboard mode
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -53,8 +53,8 @@ Rows are numbered `1..N` down the left, columns are lettered `A..Z` (then `AA..`
|
|||||||
| `help` / `?` | list the commands |
|
| `help` / `?` | list the commands |
|
||||||
| `quit` / `q` | leave |
|
| `quit` / `q` | leave |
|
||||||
|
|
||||||
In `--keys` mode: arrows move, `Enter`/`Space` reveals, `F` flags, `C` chords, `1`/`2`/`3` change
|
In `--keys` mode: arrows move, `Enter`/`Space` reveals, `F` flags, `C` chords, `H` shows help,
|
||||||
difficulty, `N` starts a new board, `Q` or `Esc` quits.
|
`1`/`2`/`3` change difficulty, `N` starts a new board, `Q` or `Esc` quits.
|
||||||
|
|
||||||
Colours are on when writing to a terminal and off when the output is redirected; set `NO_COLOR`
|
Colours are on when writing to a terminal and off when the output is redirected; set `NO_COLOR`
|
||||||
to force them off. The process exits `0` after a win, `1` otherwise.
|
to force them off. The process exits `0` after a win, `1` otherwise.
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public static class CommandParser
|
|||||||
ConsoleKey.F => new Command.FlagAtCursor(),
|
ConsoleKey.F => new Command.FlagAtCursor(),
|
||||||
ConsoleKey.C => new Command.ChordAtCursor(),
|
ConsoleKey.C => new Command.ChordAtCursor(),
|
||||||
ConsoleKey.N => new Command.NewGame(),
|
ConsoleKey.N => new Command.NewGame(),
|
||||||
|
ConsoleKey.H => new Command.ShowHelp(),
|
||||||
ConsoleKey.D1 => new Command.ChangeDifficulty(GameDifficulty.Beginner),
|
ConsoleKey.D1 => new Command.ChangeDifficulty(GameDifficulty.Beginner),
|
||||||
ConsoleKey.D2 => new Command.ChangeDifficulty(GameDifficulty.Intermediate),
|
ConsoleKey.D2 => new Command.ChangeDifficulty(GameDifficulty.Intermediate),
|
||||||
ConsoleKey.D3 => new Command.ChangeDifficulty(GameDifficulty.Expert),
|
ConsoleKey.D3 => new Command.ChangeDifficulty(GameDifficulty.Expert),
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public sealed class GameSession
|
|||||||
quit | q leave
|
quit | q leave
|
||||||
|
|
||||||
Rows are numbered 1..N down the left, columns are lettered A..Z across the top.
|
Rows are numbered 1..N down the left, columns are lettered A..Z across the top.
|
||||||
With --keys, use the arrow keys to move, Enter/Space to reveal, F to flag, C to chord.
|
With --keys, use the arrow keys to move, Enter/Space to reveal, F to flag, C to chord, H for help.
|
||||||
""";
|
""";
|
||||||
|
|
||||||
private static MinesweeperGame NewGame(GameDifficulty difficulty, int? seed) =>
|
private static MinesweeperGame NewGame(GameDifficulty difficulty, int? seed) =>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public static class Program
|
|||||||
}
|
}
|
||||||
else if (keys)
|
else if (keys)
|
||||||
{
|
{
|
||||||
Console.WriteLine(palette.Dim("arrows move · enter reveal · f flag · c chord · 1/2/3 difficulty · n new · q quit"));
|
Console.WriteLine(palette.Dim("arrows move · enter reveal · f flag · c chord · 1/2/3 difficulty · n new · h help · q quit"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -178,6 +178,10 @@ public class CommandParserTests
|
|||||||
Assert.IsType<Command.Quit>(CommandParser.FromKey(Key(ConsoleKey.Q, 'q')));
|
Assert.IsType<Command.Quit>(CommandParser.FromKey(Key(ConsoleKey.Q, 'q')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void FromKey_Help() =>
|
||||||
|
Assert.IsType<Command.ShowHelp>(CommandParser.FromKey(Key(ConsoleKey.H, 'h')));
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FromKey_UnmappedKey_IsANoOp() =>
|
public void FromKey_UnmappedKey_IsANoOp() =>
|
||||||
Assert.IsType<Command.Noop>(CommandParser.FromKey(Key(ConsoleKey.B, 'b')));
|
Assert.IsType<Command.Noop>(CommandParser.FromKey(Key(ConsoleKey.B, 'b')));
|
||||||
|
|||||||
Reference in New Issue
Block a user