mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-02-04 19:12:07 -08:00
Add text resources
This commit is contained in:
@@ -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>
|
||||
|
||||
1
30_Cube/csharp/Resources/Balance.txt
Normal file
1
30_Cube/csharp/Resources/Balance.txt
Normal file
@@ -0,0 +1 @@
|
||||
You now have {0} dollars.
|
||||
4
30_Cube/csharp/Resources/Bang.txt
Normal file
4
30_Cube/csharp/Resources/Bang.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
******BANG******
|
||||
You lose!
|
||||
|
||||
|
||||
1
30_Cube/csharp/Resources/BetAgain.txt
Normal file
1
30_Cube/csharp/Resources/BetAgain.txt
Normal file
@@ -0,0 +1 @@
|
||||
Tried to fool me; bet again
|
||||
1
30_Cube/csharp/Resources/Bust.txt
Normal file
1
30_Cube/csharp/Resources/Bust.txt
Normal file
@@ -0,0 +1 @@
|
||||
You bust.
|
||||
1
30_Cube/csharp/Resources/Congratulations.txt
Normal file
1
30_Cube/csharp/Resources/Congratulations.txt
Normal file
@@ -0,0 +1 @@
|
||||
Congratulations!
|
||||
3
30_Cube/csharp/Resources/Goodbye.txt
Normal file
3
30_Cube/csharp/Resources/Goodbye.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Tough luck!
|
||||
|
||||
Goodbye.
|
||||
1
30_Cube/csharp/Resources/HowMuch.txt
Normal file
1
30_Cube/csharp/Resources/HowMuch.txt
Normal file
@@ -0,0 +1 @@
|
||||
How much
|
||||
2
30_Cube/csharp/Resources/IllegalMove.txt
Normal file
2
30_Cube/csharp/Resources/IllegalMove.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
Illegal move. You lose.
|
||||
24
30_Cube/csharp/Resources/Instructions.txt
Normal file
24
30_Cube/csharp/Resources/Instructions.txt
Normal 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!
|
||||
6
30_Cube/csharp/Resources/Introduction.txt
Normal file
6
30_Cube/csharp/Resources/Introduction.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
Cube
|
||||
Creative Computing Morristown, New Jersey
|
||||
|
||||
|
||||
|
||||
Do you want to see the instructions? (Yes--1,No--0)
|
||||
1
30_Cube/csharp/Resources/NextMove.txt
Normal file
1
30_Cube/csharp/Resources/NextMove.txt
Normal file
@@ -0,0 +1 @@
|
||||
Next move:
|
||||
44
30_Cube/csharp/Resources/Resource.cs
Normal file
44
30_Cube/csharp/Resources/Resource.cs
Normal 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}'.");
|
||||
}
|
||||
1
30_Cube/csharp/Resources/TryAgain.txt
Normal file
1
30_Cube/csharp/Resources/TryAgain.txt
Normal file
@@ -0,0 +1 @@
|
||||
Do you want to try again
|
||||
1
30_Cube/csharp/Resources/Wager.txt
Normal file
1
30_Cube/csharp/Resources/Wager.txt
Normal file
@@ -0,0 +1 @@
|
||||
Want to make a wager
|
||||
2
30_Cube/csharp/Resources/YourMove.txt
Normal file
2
30_Cube/csharp/Resources/YourMove.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
It's your move:
|
||||
Reference in New Issue
Block a user