mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-04-28 11:53:21 -07:00
Setup game skeleton
This commit is contained in:
19
71_Poker/csharp/Games.cs
Normal file
19
71_Poker/csharp/Games.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Poker.Resources;
|
||||
|
||||
internal class Game
|
||||
{
|
||||
private readonly IReadWrite _io;
|
||||
private readonly IRandom _random;
|
||||
|
||||
public Game(IReadWrite io, IRandom random)
|
||||
{
|
||||
_io = io;
|
||||
_random = random;
|
||||
}
|
||||
|
||||
internal void Play()
|
||||
{
|
||||
_io.Write(Resource.Streams.Title);
|
||||
_io.Write(Resource.Streams.Instructions);
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
4
71_Poker/csharp/Program.cs
Normal file
4
71_Poker/csharp/Program.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
global using Games.Common.IO;
|
||||
global using Games.Common.Randomness;
|
||||
|
||||
new Game(new ConsoleIO(), new RandomNumberGenerator()).Play();
|
||||
5
71_Poker/csharp/Resources/Instructions.txt
Normal file
5
71_Poker/csharp/Resources/Instructions.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Welcome to the casino. We each have $200.
|
||||
I will open the betting before the draw; you open after.
|
||||
To fold bet 0; to check bet .5.
|
||||
Enough talk -- Let's get down to business.
|
||||
|
||||
17
71_Poker/csharp/Resources/Resource.cs
Normal file
17
71_Poker/csharp/Resources/Resource.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Poker.Resources;
|
||||
|
||||
internal static class Resource
|
||||
{
|
||||
internal static class Streams
|
||||
{
|
||||
public static Stream Instructions => GetStream();
|
||||
public static Stream Title => GetStream();
|
||||
}
|
||||
|
||||
private static Stream GetStream([CallerMemberName] string? name = null)
|
||||
=> Assembly.GetExecutingAssembly().GetManifestResourceStream($"Poker.Resources.{name}.txt")
|
||||
?? throw new ArgumentException($"Resource stream {name} does not exist", nameof(name));
|
||||
}
|
||||
5
71_Poker/csharp/Resources/Title.txt
Normal file
5
71_Poker/csharp/Resources/Title.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
Poker
|
||||
Creative Computing Morristown, New Jersey
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user