Add string resources

This commit is contained in:
Andrew Cooper
2022-07-24 21:33:10 +10:00
parent ed2e2be6ac
commit 842f749db5
5 changed files with 66 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,5 @@
Diamond
Creative Computing Morristown, New Jersey

View File

@@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Diamond.Resources;
internal static class Resource
{
internal static class Streams
{
public static Stream Introduction => GetStream();
}
internal static class Prompts
{
public static string TypeNumber => 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,22 @@
Chomp is for 1 or more players (humans only).
Here's how a board looks (this one is 5 by 7):
1 2 3 4 5 6 7 8 9
1 P * * * * * *
2 * * * * * * *
3 * * * * * * *
4 * * * * * * *
5 * * * * * * *
The board is a big cookie - R rows high and C columns
wide. You input R and C at the start. In the upper left
corner of the cookie is a poison square (P). The one who
chomps the poison square loses. To take a chomp, type the
row and column of one of the squares on the cookie.
All of the squares below and to the right of that square
(including that square, too) disappear -- Chomp!!
No fair chomping on squares that have already been chomped,
or that are outside the original dimensions of the cookie.

View File

@@ -0,0 +1,2 @@
For a pretty diamond pattern,
type in an odd number between 5 and 21