Add text resources

This commit is contained in:
Andrew Cooper
2022-07-23 10:00:57 +10:00
parent 320f5dede0
commit 961085be48
16 changed files with 101 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 @@
You now have {0} dollars.

View File

@@ -0,0 +1,4 @@
******BANG******
You lose!

View File

@@ -0,0 +1 @@
Tried to fool me; bet again

View File

@@ -0,0 +1 @@
You bust.

View File

@@ -0,0 +1 @@
Congratulations!

View File

@@ -0,0 +1,3 @@
Tough luck!
Goodbye.

View File

@@ -0,0 +1 @@
How much

View File

@@ -0,0 +1,2 @@
Illegal move. You lose.

View File

@@ -0,0 +1,24 @@
This is a game in which you will be playing against the
random decision od the computer. The field of play is a
cube of side 3. Any of the 27 locations can be designated
by inputing three numbers such as 2,3,1. At the start,
you are automatically at location 1,1,1. The object of
the game is to get to location 3,3,3. One minor detail:
the computer will pick, at random, 5 locations at which
it will play land mines. If you hit one of these locations
you lose. One other details: you may move only one space
in one direction each move. For example: from 1,1,2 you
may move to 2,1,2 or 1,1,3. You may not change
two of the numbers on the same move. If you make an illegal
move, you lose and the computer takes the money you may
have bet on that round.
All Yes or No questions will be answered by a 1 for Yes
or a 0 (zero) for no.
When stating the amount of a wager, print only the number
of dollars (example: 250) You are automatically started with
500 dollars in your account.
Good luck!

View File

@@ -0,0 +1,6 @@
Cube
Creative Computing Morristown, New Jersey
Do you want to see the instructions? (Yes--1,No--0)

View File

@@ -0,0 +1 @@
Next move:

View File

@@ -0,0 +1,44 @@
using System.Reflection;
using System.Runtime.CompilerServices;
namespace Cube.Resources;
internal static class Resource
{
internal static class Streams
{
public static Stream Introduction => GetStream();
public static Stream Instructions => GetStream();
public static Stream Wager => GetStream();
public static Stream IllegalMove => GetStream();
public static Stream Bang => GetStream();
public static Stream Bust => GetStream();
public static Stream Congratulations => GetStream();
public static Stream Goodbye => GetStream();
}
internal static class Prompts
{
public static string HowMuch => GetString();
public static string BetAgain => GetString();
public static string YourMove => GetString();
public static string NextMove => GetString();
public static string TryAgain => GetString();
}
internal static class Formats
{
public static string Balance => 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 @@
Do you want to try again

View File

@@ -0,0 +1 @@
Want to make a wager

View File

@@ -0,0 +1,2 @@
It's your move: