Add resource strings

This commit is contained in:
Andrew Cooper
2022-08-12 17:28:49 +10:00
parent 2259def843
commit 7ab0e91c1f
10 changed files with 93 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,2 @@
O.K. Hope you had fun!!

View File

@@ -0,0 +1 @@
Jump from

View File

@@ -0,0 +1 @@
Illegal move. Try again...

View File

@@ -0,0 +1,29 @@
One Check
Creative Computing Morristown, New Jersey
Solitaire checker puzzle by David Ahl
48 checkers and placed on the 2 outside spaces of a
standard 64-square checkerboard. The object is to
remove as many checkers as possible by diagonal jumps
(as in standard checkers). Use the numbered board to
indicate the square you wish to jump from and to. On
the board printed out on each turn '1' indicates a
checker and '0' an empty square. When you have no
possible jumps remaining, input a '0' in response to
question 'Jump from ?'
Here is the numerical board:
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
And here is the opening position of the checkers.

View File

@@ -0,0 +1,45 @@
using System.Reflection;
using System.Runtime.CompilerServices;
namespace OneCheck.Resources;
internal static class Resource
{
internal static class Streams
{
public static Stream Introduction => GetStream();
public static Stream IllegalMove => GetStream();
public static Stream YesOrNo => GetStream();
public static Stream Bye => GetStream();
}
internal static class Formats
{
public static string Results => GetString();
}
internal static class Prompts
{
public static string From => GetString();
public static string To => GetString();
public static string TryAgain => 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,4 @@
You made {0} jumps and had {1} pieces
remaining on the board.

View File

@@ -0,0 +1 @@
to

View File

@@ -0,0 +1 @@
Try again

View File

@@ -0,0 +1 @@
Please answer 'Yes' or 'No'.