Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flash Cards #80

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/Flash Cards Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Flash Cards Build
on:
push:
paths:
- 'Projects/Flash Cards/**'
- '!**.md'
pull_request:
paths:
- 'Projects/Flash Cards/**'
- '!**.md'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- run: dotnet build "Projects\Flash Cards\Flash Cards.csproj" --configuration Release
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
"console": "externalTerminal",
"stopAtEntry": false,
},
{
"name": "Flash Cards",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build Flash Cards",
"program": "${workspaceFolder}/Projects/Flash Cards/bin/Debug/Flash Cards.dll",
"cwd": "${workspaceFolder}/Projects/Flash Cards/bin/Debug",
"console": "externalTerminal",
"stopAtEntry": false,
},
{
"name": "Quick Draw",
"type": "coreclr",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"**/obj": true,
},
"csharp.semanticHighlighting.enabled": true,
"dotnet.defaultSolution": "dotnet-console-games.sln",

//// color/theme settings
//// optional color/theme settings
//"workbench.colorTheme": "Default Dark+",
//"editor.semanticTokenColorCustomizations":
//{
Expand Down
13 changes: 13 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,19 @@
],
"problemMatcher": "$msCompile",
},
{
"label": "Build Flash Cards",
"command": "dotnet",
"type": "process",
"args":
[
"build",
"${workspaceFolder}/Projects/Flash Cards/Flash Cards.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
],
"problemMatcher": "$msCompile",
},
{
"label": "Build Solution",
"command": "dotnet",
Expand Down
8 changes: 8 additions & 0 deletions Projects/Flash Cards/Flash Cards.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
86 changes: 86 additions & 0 deletions Projects/Flash Cards/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;

(char Letter, string CodeWord)[] array = new[]
{
( 'A', "Alpha" ), ( 'B', "Bravo" ), ( 'C', "Charlie" ), ( 'D', "Delta" ),
( 'E', "Echo" ), ( 'F', "Foxtrot" ), ( 'G', "Golf" ), ( 'H', "Hotel" ),
( 'I', "India" ), ( 'J', "Juliett" ), ( 'K', "Kilo" ), ( 'L', "Lima" ),
( 'M', "Mike" ), ( 'N', "November" ), ( 'O', "Oscar" ), ( 'P', "Papa" ),
( 'Q', "Quebec" ), ( 'R', "Romeo" ), ( 'S', "Sierra" ), ( 'T', "Tango" ),
( 'U', "Uniform" ), ( 'V', "Victor" ), ( 'W', "Whiskey" ), ( 'X', "X-ray" ),
( 'Y', "Yankee" ), ( 'Z', "Zulu" ),
};

while (true)
{
Console.Clear();
Console.WriteLine();
Console.WriteLine(" Flash Cards");
Console.WriteLine();
Console.WriteLine(" In this game you will be doing flash card exercises");
Console.WriteLine(" to help you memorize the NATO phonetic alphabet. The");
Console.WriteLine(" NATO phonetic alphabet is commonly used during radio");
Console.WriteLine(" communication in aviation. Each flash card will have");
Console.WriteLine(" a letter from the english alphabet and you need to");
Console.WriteLine(" provide the corresponding code word for that letter.");
Console.WriteLine();
Console.WriteLine(" | NATO phonetic alphabet code words");
Console.WriteLine(" |");
Console.WriteLine(" | A -> Alpha B -> Bravo C -> Charlie D -> Delta");
Console.WriteLine(" | E -> Echo F -> Foxtrot G -> Golf H -> Hotel");
Console.WriteLine(" | I -> India J -> Juliett K -> Kilo L -> Lima");
Console.WriteLine(" | M -> Mike N -> November O -> Oscar P -> Papa");
Console.WriteLine(" | Q -> Quebec R -> Romeo S -> Sierra T -> Tango");
Console.WriteLine(" | U -> Uniform V -> Victor W -> Whiskey X -> X-ray");
Console.WriteLine(" | Y -> Yankee Z -> Zulu");
Console.WriteLine();
Console.Write(" Press [enter] to continue or [escape] to quit...");
while (true)
{
ConsoleKey key = Console.ReadKey(true).Key;
if (key is ConsoleKey.Enter)
{
break;
}
if (key is ConsoleKey.Escape)
{
Console.Clear();
Console.WriteLine("Flash Cards was closed.");
return;
}
}
bool returnToMainMenu = false;
while (!returnToMainMenu)
{
int index = Random.Shared.Next(array.Length);
Console.Clear();
Console.WriteLine();
Console.WriteLine(" What is the NATO phonetic alphabet code word for...");
Console.WriteLine();
Console.Write($" {array[index].Letter}? ");
string input = Console.ReadLine()!;
Console.WriteLine();
if (input.Trim().ToUpper() == array[index].CodeWord.ToUpper())
{
Console.WriteLine(" Correct! :)");
}
else
{
Console.WriteLine($" Incorrect. :( {array[index].Letter} -> {array[index].CodeWord}");
}
Console.Write(" Press [enter] to continue or [escape] to return to main menu...");
while (true)
{
ConsoleKey key = Console.ReadKey(true).Key;
if (key is ConsoleKey.Enter)
{
break;
}
if (key is ConsoleKey.Escape)
{
returnToMainMenu = true;
break;
}
}
}
}
58 changes: 58 additions & 0 deletions Projects/Flash Cards/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<h1 align="center">
Flash Cards
</h1>

<p align="center">
<a href="https://github.com/dotnet/dotnet-console-games"><img src="../../.github/resources/github-repo-black.svg" alt="GitHub repo"></a>
<a href="https://docs.microsoft.com/en-us/dotnet/csharp/"><img src="../../.github/resources/language-csharp.svg" alt="Language C#"></a>
<a href="https://dotnet.microsoft.com/download"><img src="../../.github/resources/dotnet-badge.svg" title="Target Framework" alt="Target Framework"></a>
<a href="https://github.com/dotnet/dotnet-console-games/actions"><img src="https://github.com/dotnet/dotnet-console-games/workflows/Flash%20Cards%20Build/badge.svg" title="Goto Build" alt="Build"></a>
<a href="https://discord.gg/4XbQbwF"><img src="../../.github/resources/discord-badge.svg" title="Go To Discord Server" alt="Discord"></a>
<a href="../../LICENSE"><img src="../../.github/resources/license-MIT-green.svg" alt="License"></a>
</p>

<p align="center">
You can play this game in your browser:
<br />
<a href="https://dotnet.github.io/dotnet-console-games/Flash Cards" alt="Play Now">
<sub><img height="40"src="../../.github/resources/play-badge.svg" alt="Play Now"></sub>
</a>
<br />
<sup>Hosted On GitHub Pages</sup>
</p>

In this game you will be doing flash card exercises to help you memorize the NATO phonetic alphabet.
The NATO phonetic alphabet is commonly used during radio communication in aviation. Each flash card
will have a letter from the english alphabet and you need to provide the corresponding code word for
that letter.

```
| NATO phonetic alphabet code words
|
| A -> Alpha B -> Bravo C -> Charlie D -> Delta
| E -> Echo F -> Foxtrot G -> Golf H -> Hotel
| I -> India J -> Juliett K -> Kilo L -> Lima
| M -> Mike N -> November O -> Oscar P -> Papa
| Q -> Quebec R -> Romeo S -> Sierra T -> Tango
| U -> Uniform V -> Victor W -> Whiskey X -> X-ray
| Y -> Yankee Z -> Zulu
```

```
What is the NATO phonetic alphabet code word for...

C? Casper
Incorrect. :( C -> Charlie
```

## Input

- `enter`: confirm

## Downloads

[win-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/win-x64/Flash%20Cards.exe)

[linux-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/linux-x64/Flash%20Cards)

[osx-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/osx-x64/Flash%20Cards)
2 changes: 2 additions & 0 deletions Projects/Website/BlazorConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public void EnqueueInput(ConsoleKey key, bool shift = false, bool alt = false, b
ConsoleKey.Enter => '\n',
ConsoleKey.Backspace => '\b',
ConsoleKey.OemPeriod => '.',
ConsoleKey.OemMinus => '-',
_ => '\0',
};
InputBuffer.Enqueue(new(shift ? char.ToUpper(c) : c, key, shift, alt, control));
Expand All @@ -136,6 +137,7 @@ public void OnKeyDown(KeyboardEventArgs e)
case "ArrowUp": EnqueueInput(ConsoleKey.UpArrow); break;
case "ArrowDown": EnqueueInput(ConsoleKey.DownArrow); break;
case ".": EnqueueInput(ConsoleKey.OemPeriod); break;
case "-": EnqueueInput(ConsoleKey.OemMinus); break;
default:
if (e.Key.Length is 1)
{
Expand Down
97 changes: 97 additions & 0 deletions Projects/Website/Games/Flash Cards/Flash Cards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using System;
using System.Threading.Tasks;

namespace Website.Games.Flash_Cards;

public class Flash_Cards
{
public readonly BlazorConsole Console = new();

public async Task Run()
{
(char Letter, string CodeWord)[] array = new[]
{
( 'A', "Alpha" ), ( 'B', "Bravo" ), ( 'C', "Charlie" ), ( 'D', "Delta" ),
( 'E', "Echo" ), ( 'F', "Foxtrot" ), ( 'G', "Golf" ), ( 'H', "Hotel" ),
( 'I', "India" ), ( 'J', "Juliett" ), ( 'K', "Kilo" ), ( 'L', "Lima" ),
( 'M', "Mike" ), ( 'N', "November" ), ( 'O', "Oscar" ), ( 'P', "Papa" ),
( 'Q', "Quebec" ), ( 'R', "Romeo" ), ( 'S', "Sierra" ), ( 'T', "Tango" ),
( 'U', "Uniform" ), ( 'V', "Victor" ), ( 'W', "Whiskey" ), ( 'X', "X-ray" ),
( 'Y', "Yankee" ), ( 'Z', "Zulu" ),
};

while (true)
{
await Console.Clear();
await Console.WriteLine();
await Console.WriteLine(" Flash Cards");
await Console.WriteLine();
await Console.WriteLine(" In this game you will be doing flash card exercises");
await Console.WriteLine(" to help you memorize the NATO phonetic alphabet. The");
await Console.WriteLine(" NATO phonetic alphabet is commonly used during radio");
await Console.WriteLine(" communication in aviation. Each flash card will have");
await Console.WriteLine(" a letter from the english alphabet and you need to");
await Console.WriteLine(" provide the corresponding code word for that letter.");
await Console.WriteLine();
await Console.WriteLine(" | NATO phonetic alphabet code words");
await Console.WriteLine(" |");
await Console.WriteLine(" | A -> Alpha B -> Bravo C -> Charlie D -> Delta");
await Console.WriteLine(" | E -> Echo F -> Foxtrot G -> Golf H -> Hotel");
await Console.WriteLine(" | I -> India J -> Juliett K -> Kilo L -> Lima");
await Console.WriteLine(" | M -> Mike N -> November O -> Oscar P -> Papa");
await Console.WriteLine(" | Q -> Quebec R -> Romeo S -> Sierra T -> Tango");
await Console.WriteLine(" | U -> Uniform V -> Victor W -> Whiskey X -> X-ray");
await Console.WriteLine(" | Y -> Yankee Z -> Zulu");
await Console.WriteLine();
await Console.Write(" Press [enter] to continue or [escape] to quit...");
while (true)
{
ConsoleKey key = (await Console.ReadKey(true)).Key;
if (key is ConsoleKey.Enter)
{
break;
}
if (key is ConsoleKey.Escape)
{
await Console.Clear();
await Console.WriteLine("Flash Cards was closed.");
return;
}
}
bool returnToMainMenu = false;
while (!returnToMainMenu)
{
int index = Random.Shared.Next(array.Length);
await Console.Clear();
await Console.WriteLine();
await Console.WriteLine(" What is the NATO phonetic alphabet code word for...");
await Console.WriteLine();
await Console.Write($" {array[index].Letter}? ");
string input = await Console.ReadLine()!;
await Console.WriteLine();
if (input.Trim().ToUpper() == array[index].CodeWord.ToUpper())
{
await Console.WriteLine(" Correct! :)");
}
else
{
await Console.WriteLine($" Incorrect. :( {array[index].Letter} -> {array[index].CodeWord}");
}
await Console.Write(" Press [enter] to continue or [escape] to return to main menu...");
while (true)
{
ConsoleKey key = (await Console.ReadKey(true)).Key;
if (key is ConsoleKey.Enter)
{
break;
}
if (key is ConsoleKey.Escape)
{
returnToMainMenu = true;
break;
}
}
}
}
}
}
56 changes: 56 additions & 0 deletions Projects/Website/Pages/Flash Cards.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@using System

@page "/Flash Cards"

<PageTitle>Flash Cards</PageTitle>

<h1>Flash&nbsp;Cards</h1>

<a href="https://github.com/dotnet/dotnet-console-games/tree/main/Projects/Flash%20Cards" alt="Go To Readme">
<img title="Go To Readme" alt="Go To Readme" src="https://raw.githubusercontent.com/dotnet/dotnet-console-games/main/.github/resources/readme-black.svg">
</a>

<div class="console-window text-center my-3" @onkeydown="@Console.OnKeyDown" tabindex="0">
<div class="d-inline-block bg-dark text-light border p-2 text-start shadow padding-0">
<pre class="console">
<code>@Console.State</code>
</pre>
</div>
<div>
@for (char i = 'a'; i <= 'z'; i++)
{
char c = i;
<span></span>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.A + (c - 'a'))">@c</button>
<span></span>
}
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.OemMinus)">-</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.Enter) ">enter</button>
<button class="btn btn-primary" @onclick="() => Console.EnqueueInput(ConsoleKey.Escape) ">escape</button>
</div>
</div>

<div class="alert alert-secondary" role="alert">
&#9000; Keyboard input is supported if you <strong>click</strong> on the game.
</div>

<div class="alert alert-secondary" role="alert">
&#8635; You can restart the game by <strong>refreshing</strong> the page.
</div>

@code
{
Games.Flash_Cards.Flash_Cards Game;
BlazorConsole Console;

public Flash_Cards()
{
Game = new();
Console = Game.Console;
Console.WindowWidth = 70;
Console.WindowHeight = 24;
Console.TriggerRefresh = StateHasChanged;
}

protected override void OnInitialized() => InvokeAsync(Game.Run);
}
Loading