mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 07:10:42 -08:00
Add string 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>
|
||||
|
||||
5
32_Diamond/csharp/Resources/Introduction.txt
Normal file
5
32_Diamond/csharp/Resources/Introduction.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Diamond
|
||||
Creative Computing Morristown, New Jersey
|
||||
|
||||
|
||||
|
||||
29
32_Diamond/csharp/Resources/Resource.cs
Normal file
29
32_Diamond/csharp/Resources/Resource.cs
Normal 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}'.");
|
||||
}
|
||||
22
32_Diamond/csharp/Resources/Rules.txt
Normal file
22
32_Diamond/csharp/Resources/Rules.txt
Normal 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.
|
||||
|
||||
2
32_Diamond/csharp/Resources/TypeNumber.txt
Normal file
2
32_Diamond/csharp/Resources/TypeNumber.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
For a pretty diamond pattern,
|
||||
type in an odd number between 5 and 21
|
||||
Reference in New Issue
Block a user