From 62a4d0b5f12ef5c944454069045cb54a7312e972 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 19 Apr 2022 07:47:20 +1000 Subject: [PATCH] Setup game skeleton --- 71_Poker/csharp/Games.cs | 19 +++++++++++++++++++ 71_Poker/csharp/Poker.csproj | 8 ++++++++ 71_Poker/csharp/Program.cs | 4 ++++ 71_Poker/csharp/Resources/Instructions.txt | 5 +++++ 71_Poker/csharp/Resources/Resource.cs | 17 +++++++++++++++++ 71_Poker/csharp/Resources/Title.txt | 5 +++++ 6 files changed, 58 insertions(+) create mode 100644 71_Poker/csharp/Games.cs create mode 100644 71_Poker/csharp/Program.cs create mode 100644 71_Poker/csharp/Resources/Instructions.txt create mode 100644 71_Poker/csharp/Resources/Resource.cs create mode 100644 71_Poker/csharp/Resources/Title.txt diff --git a/71_Poker/csharp/Games.cs b/71_Poker/csharp/Games.cs new file mode 100644 index 00000000..b72b4002 --- /dev/null +++ b/71_Poker/csharp/Games.cs @@ -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); + } +} \ No newline at end of file diff --git a/71_Poker/csharp/Poker.csproj b/71_Poker/csharp/Poker.csproj index d3fe4757..3870320c 100644 --- a/71_Poker/csharp/Poker.csproj +++ b/71_Poker/csharp/Poker.csproj @@ -6,4 +6,12 @@ enable enable + + + + + + + + diff --git a/71_Poker/csharp/Program.cs b/71_Poker/csharp/Program.cs new file mode 100644 index 00000000..b1f36179 --- /dev/null +++ b/71_Poker/csharp/Program.cs @@ -0,0 +1,4 @@ +global using Games.Common.IO; +global using Games.Common.Randomness; + +new Game(new ConsoleIO(), new RandomNumberGenerator()).Play(); \ No newline at end of file diff --git a/71_Poker/csharp/Resources/Instructions.txt b/71_Poker/csharp/Resources/Instructions.txt new file mode 100644 index 00000000..7f82c07e --- /dev/null +++ b/71_Poker/csharp/Resources/Instructions.txt @@ -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. + diff --git a/71_Poker/csharp/Resources/Resource.cs b/71_Poker/csharp/Resources/Resource.cs new file mode 100644 index 00000000..0ceddb0d --- /dev/null +++ b/71_Poker/csharp/Resources/Resource.cs @@ -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)); +} \ No newline at end of file diff --git a/71_Poker/csharp/Resources/Title.txt b/71_Poker/csharp/Resources/Title.txt new file mode 100644 index 00000000..2f5c6aa2 --- /dev/null +++ b/71_Poker/csharp/Resources/Title.txt @@ -0,0 +1,5 @@ + Poker + Creative Computing Morristown, New Jersey + + +