mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-10 04:07:28 -08:00
Add text resources
This commit is contained in:
@@ -6,4 +6,12 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources/*.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\00_Common\dotnet\Games.Common\Games.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
1
34_Digits/csharp/Resources/ForInstructions.txt
Normal file
1
34_Digits/csharp/Resources/ForInstructions.txt
Normal file
@@ -0,0 +1 @@
|
||||
For instructions, type '1', else type '0'
|
||||
1
34_Digits/csharp/Resources/Headings.txt
Normal file
1
34_Digits/csharp/Resources/Headings.txt
Normal file
@@ -0,0 +1 @@
|
||||
My guess Your no. Result No. right
|
||||
3
34_Digits/csharp/Resources/IWin.txt
Normal file
3
34_Digits/csharp/Resources/IWin.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
I guessed more than 1/3 of your numbers.
|
||||
I win.
|
||||
|
||||
11
34_Digits/csharp/Resources/Instructions.txt
Normal file
11
34_Digits/csharp/Resources/Instructions.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
Please take a piece of paper and write down
|
||||
the digits '0', '1', or '2' thirty times at random.
|
||||
Arrange them in three lines of ten digits each.
|
||||
I will ask for then ten at a time.
|
||||
I will always guess them first and then look at your
|
||||
next number to see if I was right. By pure luck,
|
||||
I ought to be right ten times. But I hope to do better
|
||||
than that *****
|
||||
|
||||
|
||||
6
34_Digits/csharp/Resources/Introduction.txt
Normal file
6
34_Digits/csharp/Resources/Introduction.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Digits
|
||||
Creative Computing Morristown, New Jersey
|
||||
|
||||
|
||||
|
||||
This is a game of guessing.
|
||||
3
34_Digits/csharp/Resources/ItsATie.txt
Normal file
3
34_Digits/csharp/Resources/ItsATie.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
I guessed exactly 1/3 of your numbers.
|
||||
It's a tie game.
|
||||
|
||||
44
34_Digits/csharp/Resources/Resource.cs
Normal file
44
34_Digits/csharp/Resources/Resource.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Chomp.Resources;
|
||||
|
||||
internal static class Resource
|
||||
{
|
||||
internal static class Streams
|
||||
{
|
||||
public static Stream Introduction => GetStream();
|
||||
public static Stream Instructions => GetStream();
|
||||
public static Stream TryAgain => GetStream();
|
||||
public static Stream ItsATie => GetStream();
|
||||
public static Stream IWin => GetStream();
|
||||
public static Stream YouWin => GetStream();
|
||||
public static Stream Thanks => GetStream();
|
||||
public static Stream Headings => GetStream();
|
||||
}
|
||||
|
||||
internal static class Prompts
|
||||
{
|
||||
public static string ForInstructions => GetString();
|
||||
public static string TenNumbers => GetString();
|
||||
public static string WantToTryAgain => GetString();
|
||||
}
|
||||
|
||||
internal static class Strings
|
||||
{
|
||||
public static string TooManyColumns => GetString();
|
||||
public static string TooManyRows => GetString();
|
||||
}
|
||||
|
||||
private static string GetString([CallerMemberName] string? name = null)
|
||||
{
|
||||
using var stream = GetStream(name);
|
||||
using var reader = new StreamReader(stream);
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
|
||||
|
||||
private static Stream GetStream([CallerMemberName] string? name = null) =>
|
||||
Assembly.GetExecutingAssembly().GetManifestResourceStream($"{typeof(Resource).Namespace}.{name}.txt")
|
||||
?? throw new Exception($"Could not find embedded resource stream '{name}'.");
|
||||
}
|
||||
1
34_Digits/csharp/Resources/TenNumbers.txt
Normal file
1
34_Digits/csharp/Resources/TenNumbers.txt
Normal file
@@ -0,0 +1 @@
|
||||
Ten numbers, please
|
||||
2
34_Digits/csharp/Resources/Thanks.txt
Normal file
2
34_Digits/csharp/Resources/Thanks.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
Thanks for the game
|
||||
2
34_Digits/csharp/Resources/TryAgain.txt
Normal file
2
34_Digits/csharp/Resources/TryAgain.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Only use the digits '0', '1', or '2'.
|
||||
Let's try again.
|
||||
1
34_Digits/csharp/Resources/WantToTryAgain.txt
Normal file
1
34_Digits/csharp/Resources/WantToTryAgain.txt
Normal file
@@ -0,0 +1 @@
|
||||
Do you want to try again (1 for yes, 0 for no)
|
||||
3
34_Digits/csharp/Resources/YouWin.txt
Normal file
3
34_Digits/csharp/Resources/YouWin.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
I guessed less than 1/3 of your numbers.
|
||||
You beat me. Congratulations *****
|
||||
|
||||
Reference in New Issue
Block a user