Add string resources

This commit is contained in:
Andrew Cooper
2023-01-24 17:47:34 +11:00
parent f6bde49474
commit 083a11f42f
16 changed files with 96 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
using Games.Common.IO;
var io = new ConsoleIO();
@@ -0,0 +1 @@
Anyone else care to try
@@ -0,0 +1 @@
Computer moves to square {0}
@@ -0,0 +1,7 @@
C O N G R A T U L A T I O N S . . .
You have won--very well played.
It looks like I have met my match.
Thanks for playing--I can't win all the time.
+2
View File
@@ -0,0 +1,2 @@
Looks like I have won by forfeit.
+4
View File
@@ -0,0 +1,4 @@
Nice try, but it looks like I have won.
Thanks for playing.
@@ -0,0 +1,2 @@
Y O U C H E A T . . . Try again
@@ -0,0 +1,3 @@
Please read the instructions again.
You have begun illegally.
@@ -0,0 +1,16 @@
We are going to play a game based on one of the chess
moves. Our queen will be able to move only to the left,
down, or diagonally down and to the left.
The object of the game is to place the queen in the lower
left hand square by alternating moves between you and the
computer. The first one to place the queen there wins.
You go first and place the queen in any one of the squares
on the top row or right hand column.
That will be your first move.
We alternate moves.
You may forfeit by typing '0' as your move.
Be sure to press the return key after each response.
@@ -0,0 +1 @@
Do you want instructions
+1
View File
@@ -0,0 +1 @@
What is your move
+47
View File
@@ -0,0 +1,47 @@
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Queen.Resources;
internal static class Resource
{
internal static class Streams
{
public static Stream Title => GetStream();
public static Stream Instructions => GetStream();
public static Stream YesOrNo => GetStream();
public static Stream IllegalStart => GetStream();
public static Stream ComputerMove => GetStream();
public static Stream IllegalMove => GetStream();
public static Stream Forfeit => GetStream();
public static Stream IWin => GetStream();
public static Stream Congratulations => GetStream();
public static Stream Thanks => GetStream();
}
internal static class Prompts
{
public static string Instructions => GetPrompt();
public static string Start => GetPrompt();
public static string Move => GetPrompt();
public static string Anyone => GetPrompt();
}
internal static class Formats
{
public static string Balance => GetString();
}
private static string GetPrompt([CallerMemberName] string? name = null) => GetString($"{name}Prompt");
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}'.");
}
@@ -0,0 +1 @@
Where would you like to start
+1
View File
@@ -0,0 +1 @@
Ok --- thanks again.
+5
View File
@@ -0,0 +1,5 @@
Queen
Creative Computing Morristown, New Jersey
+1
View File
@@ -0,0 +1 @@
Please answer 'Yes' or 'No'.