Setup game skeleton

This commit is contained in:
Andrew Cooper
2022-04-19 07:47:20 +10:00
parent 89dba2e3f8
commit 62a4d0b5f1
6 changed files with 58 additions and 0 deletions

19
71_Poker/csharp/Games.cs Normal file
View 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);
}
}

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,4 @@
global using Games.Common.IO;
global using Games.Common.Randomness;
new Game(new ConsoleIO(), new RandomNumberGenerator()).Play();

View 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.

View 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));
}

View File

@@ -0,0 +1,5 @@
Poker
Creative Computing Morristown, New Jersey