Add text resources

This commit is contained in:
Andrew Cooper
2022-07-28 22:09:57 +10:00
parent ed2e2be6ac
commit a2dc514955
13 changed files with 86 additions and 0 deletions

View File

@@ -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>

View File

@@ -0,0 +1 @@
For instructions, type '1', else type '0'

View File

@@ -0,0 +1 @@
My guess Your no. Result No. right

View File

@@ -0,0 +1,3 @@
I guessed more than 1/3 of your numbers.
I win.

View 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 *****

View File

@@ -0,0 +1,6 @@
Digits
Creative Computing Morristown, New Jersey
This is a game of guessing.

View File

@@ -0,0 +1,3 @@
I guessed exactly 1/3 of your numbers.
It's a tie game.

View 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}'.");
}

View File

@@ -0,0 +1 @@
Ten numbers, please

View File

@@ -0,0 +1,2 @@
Thanks for the game

View File

@@ -0,0 +1,2 @@
Only use the digits '0', '1', or '2'.
Let's try again.

View File

@@ -0,0 +1 @@
Do you want to try again (1 for yes, 0 for no)

View File

@@ -0,0 +1,3 @@
I guessed less than 1/3 of your numbers.
You beat me. Congratulations *****