Add game loop

This commit is contained in:
Andrew Cooper
2022-07-17 16:59:53 +10:00
parent 203f930e12
commit 68c7d13c57
2 changed files with 32 additions and 0 deletions

27
26_Chomp/csharp/Game.cs Normal file
View File

@@ -0,0 +1,27 @@
namespace Chomp;
internal class Game
{
private readonly IReadWrite _io;
public Game(IReadWrite io)
{
_io = io;
}
internal void Play()
{
_io.Write(Resource.Streams.Introduction);
if (_io.ReadNumber("Do you want the rules (1=Yes, 0=No!)") != 0)
{
_io.Write(Resource.Streams.Rules);
}
while (true)
{
_io.Write(Resource.Streams.HereWeGo);
if (_io.ReadNumber("Again (1=Yes, 0=No!)") != 1) { break; }
}
}
}

View File

@@ -0,0 +1,5 @@
global using Games.Common.IO;
global using Chomp.Resources;
using Chomp;
new Game(new ConsoleIO()).Play();