mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 15:37:51 -08:00
Add game intro
This commit is contained in:
18
67_One_Check/csharp/Board.cs
Normal file
18
67_One_Check/csharp/Board.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace OneCheck;
|
||||
|
||||
internal class Board
|
||||
{
|
||||
private readonly int[][] _checkers;
|
||||
|
||||
public Board()
|
||||
{
|
||||
_checkers =
|
||||
Enumerable.Range(0, 8)
|
||||
.Select(r => Enumerable.Range(0, 8)
|
||||
.Select(c => r > 1 && r < 6 && c > 1 && c < 6 ? 0 : 1).ToArray())
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
string.Join(Environment.NewLine, _checkers.Select(r => string.Join(" ", r.Select(c => $" {c}"))));
|
||||
}
|
||||
20
67_One_Check/csharp/Game.cs
Normal file
20
67_One_Check/csharp/Game.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace OneCheck;
|
||||
|
||||
internal class Game
|
||||
{
|
||||
private readonly IReadWrite _io;
|
||||
private readonly Board _board;
|
||||
|
||||
public Game(IReadWrite io)
|
||||
{
|
||||
_io = io;
|
||||
_board = new Board();
|
||||
}
|
||||
|
||||
public void Play()
|
||||
{
|
||||
_io.Write(Streams.Introduction);
|
||||
|
||||
_io.WriteLine(_board);
|
||||
}
|
||||
}
|
||||
5
67_One_Check/csharp/Program.cs
Normal file
5
67_One_Check/csharp/Program.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
global using Games.Common.IO;
|
||||
global using static OneCheck.Resources.Resource;
|
||||
using OneCheck;
|
||||
|
||||
new Game(new ConsoleIO()).Play();
|
||||
@@ -27,3 +27,4 @@ Here is the numerical board:
|
||||
57 58 59 60 61 62 63 64
|
||||
|
||||
And here is the opening position of the checkers.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user