From 083a11f42ffbe9ddb95a864115099cb2d8170269 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 24 Jan 2023 17:47:34 +1100 Subject: [PATCH] Add string resources --- 72_Queen/csharp/Program.cs | 3 ++ 72_Queen/csharp/Resources/AnyonePrompt.txt | 1 + 72_Queen/csharp/Resources/ComputerMove.txt | 1 + 72_Queen/csharp/Resources/Congratulations.txt | 7 +++ 72_Queen/csharp/Resources/Forfeit.txt | 2 + 72_Queen/csharp/Resources/IWin.txt | 4 ++ 72_Queen/csharp/Resources/IllegalMove.txt | 2 + 72_Queen/csharp/Resources/IllegalStart.txt | 3 ++ 72_Queen/csharp/Resources/Instructions.txt | 16 +++++++ .../csharp/Resources/InstructionsPrompt.txt | 1 + 72_Queen/csharp/Resources/MovePrompt.txt | 1 + 72_Queen/csharp/Resources/Resource.cs | 47 +++++++++++++++++++ 72_Queen/csharp/Resources/StartPrompt.txt | 1 + 72_Queen/csharp/Resources/Thanks.txt | 1 + 72_Queen/csharp/Resources/Title.txt | 5 ++ 72_Queen/csharp/Resources/YesyOrNo.txt | 1 + 16 files changed, 96 insertions(+) create mode 100644 72_Queen/csharp/Program.cs create mode 100644 72_Queen/csharp/Resources/AnyonePrompt.txt create mode 100644 72_Queen/csharp/Resources/ComputerMove.txt create mode 100644 72_Queen/csharp/Resources/Congratulations.txt create mode 100644 72_Queen/csharp/Resources/Forfeit.txt create mode 100644 72_Queen/csharp/Resources/IWin.txt create mode 100644 72_Queen/csharp/Resources/IllegalMove.txt create mode 100644 72_Queen/csharp/Resources/IllegalStart.txt create mode 100644 72_Queen/csharp/Resources/Instructions.txt create mode 100644 72_Queen/csharp/Resources/InstructionsPrompt.txt create mode 100644 72_Queen/csharp/Resources/MovePrompt.txt create mode 100644 72_Queen/csharp/Resources/Resource.cs create mode 100644 72_Queen/csharp/Resources/StartPrompt.txt create mode 100644 72_Queen/csharp/Resources/Thanks.txt create mode 100644 72_Queen/csharp/Resources/Title.txt create mode 100644 72_Queen/csharp/Resources/YesyOrNo.txt diff --git a/72_Queen/csharp/Program.cs b/72_Queen/csharp/Program.cs new file mode 100644 index 00000000..0733c377 --- /dev/null +++ b/72_Queen/csharp/Program.cs @@ -0,0 +1,3 @@ +using Games.Common.IO; + +var io = new ConsoleIO(); \ No newline at end of file diff --git a/72_Queen/csharp/Resources/AnyonePrompt.txt b/72_Queen/csharp/Resources/AnyonePrompt.txt new file mode 100644 index 00000000..a0289fd6 --- /dev/null +++ b/72_Queen/csharp/Resources/AnyonePrompt.txt @@ -0,0 +1 @@ +Anyone else care to try \ No newline at end of file diff --git a/72_Queen/csharp/Resources/ComputerMove.txt b/72_Queen/csharp/Resources/ComputerMove.txt new file mode 100644 index 00000000..f31b8e32 --- /dev/null +++ b/72_Queen/csharp/Resources/ComputerMove.txt @@ -0,0 +1 @@ +Computer moves to square {0} diff --git a/72_Queen/csharp/Resources/Congratulations.txt b/72_Queen/csharp/Resources/Congratulations.txt new file mode 100644 index 00000000..9f1db232 --- /dev/null +++ b/72_Queen/csharp/Resources/Congratulations.txt @@ -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. + diff --git a/72_Queen/csharp/Resources/Forfeit.txt b/72_Queen/csharp/Resources/Forfeit.txt new file mode 100644 index 00000000..120da75d --- /dev/null +++ b/72_Queen/csharp/Resources/Forfeit.txt @@ -0,0 +1,2 @@ +Looks like I have won by forfeit. + diff --git a/72_Queen/csharp/Resources/IWin.txt b/72_Queen/csharp/Resources/IWin.txt new file mode 100644 index 00000000..ced5d716 --- /dev/null +++ b/72_Queen/csharp/Resources/IWin.txt @@ -0,0 +1,4 @@ + +Nice try, but it looks like I have won. +Thanks for playing. + diff --git a/72_Queen/csharp/Resources/IllegalMove.txt b/72_Queen/csharp/Resources/IllegalMove.txt new file mode 100644 index 00000000..3d31638d --- /dev/null +++ b/72_Queen/csharp/Resources/IllegalMove.txt @@ -0,0 +1,2 @@ + +Y O U C H E A T . . . Try again diff --git a/72_Queen/csharp/Resources/IllegalStart.txt b/72_Queen/csharp/Resources/IllegalStart.txt new file mode 100644 index 00000000..25402bb6 --- /dev/null +++ b/72_Queen/csharp/Resources/IllegalStart.txt @@ -0,0 +1,3 @@ +Please read the instructions again. +You have begun illegally. + diff --git a/72_Queen/csharp/Resources/Instructions.txt b/72_Queen/csharp/Resources/Instructions.txt new file mode 100644 index 00000000..d440b335 --- /dev/null +++ b/72_Queen/csharp/Resources/Instructions.txt @@ -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. + + diff --git a/72_Queen/csharp/Resources/InstructionsPrompt.txt b/72_Queen/csharp/Resources/InstructionsPrompt.txt new file mode 100644 index 00000000..0d311b60 --- /dev/null +++ b/72_Queen/csharp/Resources/InstructionsPrompt.txt @@ -0,0 +1 @@ +Do you want instructions \ No newline at end of file diff --git a/72_Queen/csharp/Resources/MovePrompt.txt b/72_Queen/csharp/Resources/MovePrompt.txt new file mode 100644 index 00000000..8cb18999 --- /dev/null +++ b/72_Queen/csharp/Resources/MovePrompt.txt @@ -0,0 +1 @@ +What is your move \ No newline at end of file diff --git a/72_Queen/csharp/Resources/Resource.cs b/72_Queen/csharp/Resources/Resource.cs new file mode 100644 index 00000000..5290766e --- /dev/null +++ b/72_Queen/csharp/Resources/Resource.cs @@ -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}'."); +} \ No newline at end of file diff --git a/72_Queen/csharp/Resources/StartPrompt.txt b/72_Queen/csharp/Resources/StartPrompt.txt new file mode 100644 index 00000000..0b6f395b --- /dev/null +++ b/72_Queen/csharp/Resources/StartPrompt.txt @@ -0,0 +1 @@ +Where would you like to start \ No newline at end of file diff --git a/72_Queen/csharp/Resources/Thanks.txt b/72_Queen/csharp/Resources/Thanks.txt new file mode 100644 index 00000000..53980b09 --- /dev/null +++ b/72_Queen/csharp/Resources/Thanks.txt @@ -0,0 +1 @@ +Ok --- thanks again. \ No newline at end of file diff --git a/72_Queen/csharp/Resources/Title.txt b/72_Queen/csharp/Resources/Title.txt new file mode 100644 index 00000000..63549d09 --- /dev/null +++ b/72_Queen/csharp/Resources/Title.txt @@ -0,0 +1,5 @@ + Queen + Creative Computing Morristown, New Jersey + + + diff --git a/72_Queen/csharp/Resources/YesyOrNo.txt b/72_Queen/csharp/Resources/YesyOrNo.txt new file mode 100644 index 00000000..657bf8aa --- /dev/null +++ b/72_Queen/csharp/Resources/YesyOrNo.txt @@ -0,0 +1 @@ +Please answer 'Yes' or 'No'.