From 842f749db5c67879b2df2f99cb9a155b75bdce04 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Sun, 24 Jul 2022 21:33:10 +1000 Subject: [PATCH] Add string resources --- 32_Diamond/csharp/Diamond.csproj | 8 ++++++ 32_Diamond/csharp/Resources/Introduction.txt | 5 ++++ 32_Diamond/csharp/Resources/Resource.cs | 29 ++++++++++++++++++++ 32_Diamond/csharp/Resources/Rules.txt | 22 +++++++++++++++ 32_Diamond/csharp/Resources/TypeNumber.txt | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 32_Diamond/csharp/Resources/Introduction.txt create mode 100644 32_Diamond/csharp/Resources/Resource.cs create mode 100644 32_Diamond/csharp/Resources/Rules.txt create mode 100644 32_Diamond/csharp/Resources/TypeNumber.txt diff --git a/32_Diamond/csharp/Diamond.csproj b/32_Diamond/csharp/Diamond.csproj index d3fe4757..3870320c 100644 --- a/32_Diamond/csharp/Diamond.csproj +++ b/32_Diamond/csharp/Diamond.csproj @@ -6,4 +6,12 @@ enable enable + + + + + + + + diff --git a/32_Diamond/csharp/Resources/Introduction.txt b/32_Diamond/csharp/Resources/Introduction.txt new file mode 100644 index 00000000..e983fc9f --- /dev/null +++ b/32_Diamond/csharp/Resources/Introduction.txt @@ -0,0 +1,5 @@ + Diamond + Creative Computing Morristown, New Jersey + + + diff --git a/32_Diamond/csharp/Resources/Resource.cs b/32_Diamond/csharp/Resources/Resource.cs new file mode 100644 index 00000000..d7051f5c --- /dev/null +++ b/32_Diamond/csharp/Resources/Resource.cs @@ -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}'."); +} \ No newline at end of file diff --git a/32_Diamond/csharp/Resources/Rules.txt b/32_Diamond/csharp/Resources/Rules.txt new file mode 100644 index 00000000..2fd9177f --- /dev/null +++ b/32_Diamond/csharp/Resources/Rules.txt @@ -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. + diff --git a/32_Diamond/csharp/Resources/TypeNumber.txt b/32_Diamond/csharp/Resources/TypeNumber.txt new file mode 100644 index 00000000..d74d21fd --- /dev/null +++ b/32_Diamond/csharp/Resources/TypeNumber.txt @@ -0,0 +1,2 @@ +For a pretty diamond pattern, +type in an odd number between 5 and 21 \ No newline at end of file